Teaching material: Computer Network (7th edition) xie Xiren edition

The application layer

1. Network application architecture:

1.1 C/S

C: client, S: server

Server:

  • Always online
  • Has a fixed, well-known IP address
  • Use the data center to provide uninterrupted service

Client:

  • Communicate only with the server
  • You can connect to the server intermittently
  • You can have dynamic IP addresses
  • They don’t communicate with each other

1.2 peer-to-peer (P2P)

  • No need for always-on servers
  • Any end system communicates directly
  • Peers request services from each other and provide them
  • The peers connect intermittently and are allowed to change IP addresses

2. Domain name structure

Any router or host connected to the Internet has a unique hierarchical name, called a domain name. A domain name is a logical concept. It does not represent the physical address of a host or router.

There are three top-level domains:

  1. National top-level domain: cn for China, US for the United States, UK for the United Kingdom
  2. Generic top-level domains: com for corporations, net for Web services, org for nonprofits, int for international organizations,
  3. Infrastructure top-level domain name: ARPA, used for reverse domain name resolution, hence also called reverse domain name.

There are two types of secondary domain names:

  1. Category domain: AC, edu, gov, etc
  2. District domain name: bj, fj

3. Domain name resolution process

Local serverThe iterationThe queryLocal serverrecursiveThe querySuppose a host whose domain name is m.xyz.com wants to know the IP address of another host whose domain name is Y.abc.com. There are several query steps:

  1. The host m.xyz.com first performs a recursive query to the local DOMAIN name server dns.xyz.com.
  2. The local DNS server uses iterative query. It starts with a root DNS server.
  3. The root DNS server tells the local DNS server the IP address of dns.com to be queried next time.
  4. The local DNS server queries the DNS server from dns.com.
  5. The top-level DNS server dNS.com tells the local DNS server that the IP address of the DNS server dns.abc.com should be queried next.
  6. The local DNS server queries the domain name server dns.abc.com.
  7. Permission DNS server dns.abc.com tells the local DNS server the IP address of the host to be queried next time.
  8. The local DNS server finally sends the results to the host, m.xyz.com.

Note that these eight steps use a total of eight UDP user datagram packets. After three iterations of query, the local DNS server obtains the IP address of y.abc.com from the domain name server dns.abc.com and returns the result to the host m.xyz.com.

4. The world wide web

The World Wide Web is a massive, online repository of information.

4.1 the URL

Uniform Resource Locator URL:

Used to represent the location of resources obtained from the Internet and methods of accessing these resources.

URL: < agreement > : / / < host > : < port > / < path > for example: http://127.0.0.1:5000/index deal: / / host: port/path

4.2 HTTP

Hypertext transfer Protocol HTTP HTTP is a transaction-oriented application layer protocol. HTTP itself is connectionless and stateless.HTTP Message Structure

  • The request message

The request packet is sent from the client to the server

  • The response message

Answer from the server to the client

Because HTTP is text-oriented, each field in a packet is an ASCII string, and therefore the length of each field is uncertain. An HTTP request packet and a response packet are composed of three parts.

  1. The start line is used to distinguish between request packets and response packets. The start line in the request packet is called the request line, and the start line in the response packet is called the status line. CR and LF stand for carriage return and line feed respectively
  2. The header line, which describes some information about the browser, server, or message body, ends each line with a carriage return and line feed.
  3. This field is usually not used in request packets and may not be present in response packets.

4.3 Static Page

Static pages, or static web pages, are real, loaded directly into the client browser and displayed without having to be compiled by the server.

Static pages need to occupy a certain amount of server space, and they cannot manage and publish updated pages independently. If you want to update the content of the web page, you need to use FTP software to DOWN the file and use web page making software to modify (with exceptions such as FSO). Common examples of static pages are.html extensions,.htm extensions.

4.4 Dynamic Page

The content of the document is created dynamically by the application only when the browser accesses the World Wide Web server.

Corresponding to the static web page, can interact with the background database, data transfer. That is to say, the suffix of the web URL is not.htm,.html,.shtml,.xml and other common static web pages, but.aspx,.asp,.jsp,.php,.perl,.cgi and other forms. And there is an iconic symbol in the dynamic web address – “?”

4.5 Active Page

The technique is to shift all the work to the browser. Every time the rogue requests an active document, the server returns a copy of the active document program and runs it on the browser side. At this point, the content of the active document program can be continuously changed. And can continuously change the screen display. The content of an active document can be continuously changed as long as the user runs the active document program. Since active document technology does not require continuous line transfers from servers, the network bandwidth requirements are not too high.

4.6 Search Engine

A tool for searching on the World Wide Web.

  • Vertical search engine

  • Meta search engine

5. Main protocol of E-mail system, content transmission coding

There are two important standards in email: SIMPLE mail Transfer Protocol (SMTP) and Internet text message format

User agent UA is the interface between the user and the E-mail system. In most cases, it is a program running on the user’s computer. Therefore, user agent is also called email client software. User agents provide users with a friendly (currently mostly window-friendly) interface to send and receive mail. Existing user agents such as Foxmail, Outlook Express and so on should have at least the following four functions:

  1. writing
  2. According to
  3. To deal with
  4. communication

5.1 SMTP

SMTP specifies how information should be exchanged between two SMTP processes that communicate with each other. Because SMTP uses client server mode, the SMTP process responsible for sending mail is an SMTP client.

Here are the three phases of SMTP communication between the sender and the recipient’s mail server.

  1. Establish a connection

SMTP does not use an intermediate mail server. No matter how far apart the two mail servers are, and no matter how many routers the mail passes through, a TCP connection is always established directly between the two mail servers. When the receiver mail server fails and is not working, the sender mail server can only wait a certain period of time before attempting to establish a TCP connection with the mail server, rather than first finding an intermediate mail server TCP connection. 2. MAIL delivery MAIL delivery starts with the MAIL command. The MAIL command is followed by the sender’s address. 3. After the connection release email is sent, the SMTP customer should send the QUIT command. The SMTP server returns message 221 (service down), indicating that SMTP agrees to release the TCP connection. The whole process of mail transmission is over.

6. Protocols related to network applications and their port numbers

Network protocol The name of the protocol The port number
Telnet Remote login protocol 23 port
SMTP Simple Mail Delivery Protocol Port 25
POP3 Post Office protocol version 3 Port number 110
HTTP Hypertext Transfer Protocol Port number 80
DNS Domain Name Resolution No. 53 ports
SNMP Simple Network Management protocol Port number 161
TFTP Simple file transfer protocol Port number 69
FTP File transfer Protocol 21 on the server; The client side is 20
DHCP protocol Dynamic Host Configuration Protocol 67 on the server; The client side is 68
HTTP Hypertext transfer Protocol 80
HTTPS Hypertext Transfer Security Protocol 443

7. Socket programming interface

Two types of shipping services are provided through the socket API:

  • UDP: Unreliable datagram
  • TCP: Reliable, byte stream oriented

Example: client-server app

  1. The client sends a line of characters from standard input to the server via a socket.
  2. The server reads the line from the socket
  3. The server converts all the characters to uppercase and sends them to the client
  4. The client reads and prints the lines that have been modified from the socket

The client must contact the server

  • The server process must run in advance
  • The server must have generated the socket to welcome the client’s contact

The client contacts the server by:

  • Create the client local TCP socket
  • Define the IP address and port number of the server process
  • When a socket is generated by a client: client TCP creates a link to server TCP.

When the client contacts, server TCP generates a new socket for the server process to communicate with the client

  • Allows the server to talk to multiple clients
  • The source port number identifies different clients