Computer Networking (Application Layer)

  1. What’s Application Layer?
  2. Web and HTTP
  3. Internet-Email
  4. What’s DNS?
  5. What’s CDN?
  6. Socket Programing (Python)

What’s Application Layer?

Being the topmost layer in OSI model, performs several kinds of functions which are requirement in any kind of application or commuication process.

The application layer of the OSI model is the layer that you will be most familiar with. This familiarity is because the application layer is the layer in which protocols and rules are in place to determine how the user should interact with data sent or received.

Network Application Architectures

  1. client-server architecture (CS) [Need data center as server]
  2. peer-to-peer (P2P) [Everyone in the internet is server and client]

In a client-server architecture, there is an always-on host, called the server, which services requests from many other hosts, called clients. Web application needs to run in web server for servicing requests from clients hosts.

In a P2P architecture, there is minimal (or no) reliance on dedicated servers in data centers. Instead the application exploits direct communication between pairs of intermittently connected hosts, called peers.

The interface Between the Process and the Computer Network

We should send messages to server through a software interface called a socket.
It also refered to as the Application Programming Interface(API) between the application and the network.

Transport Services Provided by the Internet

[Key Point]

  1. TCP Service
  2. UDP Service

TCP Service

  • Stream Delivery Service
  • Sending and Receiving Buffers
  • Bytes and Segments
  • Full Duplex Service
  • Connection Oriented Service
  • Reliable Service

We can image a tube which TCP deliver the bytes in it.
(We will talk TCP later in Chapter3)

UDP Service

UDP is a communication protocol used across the internet for especially time-sensitive transmissions such as video playback or DNS lookups. It speeds up communication by not formally establishing a connection before data is transferred.
This allows data to be transferred very quickly, but it can also cause packets to become lost in transit - and create opportunities for exploitation in the form of DDos attacks.

Web and HTTP

The HyperText Transfer Protocol (HTTP), the Web’s application-layer protocol, is at the heart of the Web.

A Web page (also called a document) consists of objects. An object is simply a file—such as an HTML file, a JPEG image, a Javascrpt file, a CCS style sheet file, or a video clip—that is addressable by a single URL.

HTTP defines how Web clients request Web pages from Web servers and how servers transfer Web pages to clients.

HTTP uses TCP as its underlying transport protocol (rather than running on top of UDP). The HTTP client first initiates a TCP connection with the server.

HTTP Non-Persistent and Persistent Connection

Non-persistent connections have some shortcomings. First, a brand-new connection must be established and maintained for each requested object. For each of these connections, TCP buffers must be allocated and TCP variables must be kept in both the client and server

With HTTP/1.1 persistent connections, the server leaves the TCP connection open after sending a response. Subsequent requests and responses between the same client and server can be sent over the same connection.

User-Server Interaction: Cookies

Cookie is often desirable for a Web site to identify users.

Keeping user state with cookies

Electronic Mail in the Internet

We need 3 major components in E-mail : **user-agent, mail-server, **and the SMTP (Simple Mail Transfer Protocol)
**Mail Servers **form the core of the e-mail infrastructure. Each recipient has a mailbox located in one of mail servers.

How we send and read the E-mail?

  1. As a user agent, after we write the email, when we click the send(if we have written the recipient address), the email will be sent to the local Mail server.
  2. The Mail server will sent ours email with SMTP to recipient  Mail Server.
  3. The recipient can read our email in his Mail server.

The procedure of sending email.

We send the email to mail server by SMTP or HTTP services, and the mail server deliver the email by SMTP service.

DNS- The Internet’s Directory Service

We human beings tend to be identified name rather than a bunch of number. That’s the reason why DNS here. We should thank to DNS which let us visit the website with the website hostname instead of a bunch of number.

How it works?

When we input the hostname in the browser (www.baidu.com), the router will send the hostname to the local DNS server to seek the ‘Baidu’. If the local DNS server does not find it, it will be sent to higher DNS servers until the Root DNS servers. The root servers will resent the messages to local servers and tell it should find the com servers.
The details of seeking hostname procedures are below.


Above Figure, the host cse.nyu.edu first sends a DNS query message to its local DNS server, dns.nyu.edu. The query message contains the hostname to be translated, namely, gaia.cs.umass.edu. The local DNS server forwards the query message to a root DNS server. The root DNS server takes note of the edu suffix and returns to the local DNS server a list of IP addresses for TLD servers responsible for edu. The local DNS server then resends the query message to one of these TLD servers. The TLD server takes note of the umass.edu suffix and responds with the IP address of the authoritative DNS server for the University of Massachusetts, namely, dns.umass.edu. Finally, the local DNS server resends the query message directly to dns.umass.edu, which responds with the IP address of gaia.cs.umass.edu. Note that in this example, in order to obtain the mapping for one hostname, eight DNS messages were sent: four query messages and four reply messages! We’ll soon see how DNS caching reduces this query traffic.

DNS Caching

If we search each hostname above, it will waste time and consume the network resource. So we introduce the concept of DNS Caching. If we dig a hostname that does not save in the local server before, the local servers will save its IP and traits to save time and resources when we want to revisit the website.

What’s CDN?

Have you ever thought about the question, if we watch a youtube video, how can YouTube react quickly? And how can YouTube sustains millions of users visiting its website every day?

Today, many Internet video companies are distributing on-demand multi-Mbps streams to millions of users daily to meet the challenge of distributing massive amounts of video data to users worldwide.
Almost all major video-streaming companies make use of Content Distribution Networks(CDNS). A CDN manages servers in multiple geographically distributed locations, stores copies of the videos (and other types of Web content, including documents, images, and audio etc.) in its servers, and attempts to direct each user request to a CDN location that will provide the best user experience.

How CDN works?

  1. The user visits the Web page at NetCinema.
  2. When the user clicks on the link [http://video.netcinema.com/6Y7B23V], the user’s host sends a DNS query for video.netcinema.com.
  3. The user’s Local DNS Server (LDNS) relays the DNS query to an authoritative DNS server for NetCinema, which observes the string “video” in the hostname video.netcinema.com. To “hand over” the DNS query to KingCDN, instead of returning an IP address, the NetCinema authoritative DNS server returns to the LDNS a hostname in the KingCDN’s domain, for example, a1105.kingcdn.com.
  4. From this point on, the DNS query enters into KingCDN’s private DNS infrastructure. The user’s LDNS then sends a second query, now for a1105.kingcdn.com, and KingCDN’s DNS system eventually returns the IP addresses of a KingCDN content server to the LDNS. It is thus here, within the KingCDN’s DNS system, that the CDN server from which the client will receive its content is specified.
  5. The LDNS forwards the IP address of the content-serving CDN node to the user’s host.
  6. Once the client receives the IP address for a KingCDN content server, it establishes a direct TCP connection with the server at that IP address and issues an HTTP GET request for the video. If DASH is used, the server will first send to the client a manifest file with a list of URLs, one for each version of the video, and the client will dynamically select chunks from the different versions.

Python UDP && TCP program