Computer networks and the Internet

1.1 What is Internet? What is an agreement?

First of all, answer what is Internet from two perspectives:

1. Specific structure description

  • The Internet is a worldwide computer network that connects billions of computing devices around the world. These devices are called hosts (or end systems)
  • The end system accesses the Internet through an Internet Service provider (ISP)
  • The end systems are connected to a packet switch through a communication link

2. Service Description From the perspective of the infrastructure that provides services to the application:

  • Today’s applications for E-mail, music, movies, online video, and so on all involve end systems that exchange data with each other, hence the term distributed applications.
  • End systems connected to the Internet provide a socket interface that specifies how a program running on one end system requests the Internet infrastructure to interact with data to a specific target program running on another end system.

Protocol-side systems, packet interactions, and other Internet components all need to run a set of protocols that control the receiving and sending of information on the Internet.

  • Protocols define the format and order of messages exchanged between two or more communication entities, as well as the actions taken to send and/or receive a message or other event.
  • Protocols are widely used on the Internet, and different protocols are used to accomplish different communication tasks.

1.2 Network Structure

The structure of network includes network edge, network core and access network

1.2.1 Network Edge

Above we learned what hosts are, and because they are at the edge of the Internet, they are called end systems.

  • Host = end system
  • Hosts are sometimes further divided into two categories: clients and servers

1.2.2 access network

A network that physically connects end systems to their edge routers

1.2.3 Network core

A mesh network consisting of packet switches and links of internet-side systems. There are two ways to move data over network links and switches: circuit switching and packet switching.

1. Circuit switching

In circuit switching, resources (cache, link transmission rate) required for communication between end systems are reserved during the communication session between end systems

2. Packet switch

(1) Process

  • End systems exchange packets with each other
  • The source divides the long packet into smaller data blocks, which are called packets.
  • Between the source and destination, each packet passes through a communication link and a packet switch
  • There are two main types of switches: routers and link layer switches
  • Packets are transmitted through a communication link at a rate equal to the link’s maximum transmission rate

(2) Queuing delay and packet loss When a packet arrives at the packet switch and finds that the link is transmitting other packets, it needs to enter the waiting state, that is, queuing delay. Because the cache space is limited, packet loss may occur in packets.

(3) Forwarding table and Routing selection protocol Considering the above process, we then consider a question, when the packet painstaking to the router, then the router he should forward to which link?

  • Each end system has an IP address
  • IP addresses are hierarchical structures
  • Each router has a forwarding table that maps the destination address (or part of the destination address) into an output link.
  • The router checks part of the destination IP address of the packet and forwards reshuffles to neighboring routers

3. Comparison between packet switching and circuit switching

  • Packet switching is not suitable for real-time services, such as telephone and video services, because its end-to-end latency is variable and unpredictable
  • But packet switching offers better bandwidth sharing than circuit switching
  • Packet switching is simpler, more efficient, and less costly than circuit switching

1.3 Protocol hierarchy and service model

1.3.1 Protocol Layer

Network designers organize protocols in a layered manner, implementing these western networking hardware and software. Each protocol belongs to a layer, and we focus on the services it provides at the layer above it, the so-called one-layer service model. The Internet protocol stack consists of five layers: the physical layer, the link layer, the network layer, the transport layer, and the application layer.

1. Application layer:

Data units are packets that provide services for users and application processes, including protocols:

  • HTTP: Web document request and delivery
  • SMTP: Transfer of email packets
  • FTP: Living fossil, file transfer between two end systems
  • P2P: Different from the previous C/S mode
  • DNS: domain name resolution, distributed database

2. Transport Layer:

Data units are message segments that transmit application messages between application endpoints. There are two transport protocols:

(1) the TCP

  • Connection-oriented services are provided

(2) the UDP

  • Provide connectionless services to applications, a service that does not provide unnecessary services
  • No reliability, no flow control, no congestion control

3. Network layer:

The network layer of the Internet is responsible for transferring network layer packets called datagrams from one host to another

4. Link layer:

Point-to-point, data is transmitted in frames

5. Physical Layer:

Conversion between digital data and physical signals in units of bits

2. The application layer

2.1 Principles of Application-layer Protocols

The core of developing network applications is to write programs that can run on different end systems and communicate with each other over the network.

  • In a Web application, two different programs communicate with each other:
    • One is a browser program that runs on the user’s host
    • The other is a Web server program running on a Web server host
  • P2P file sharing system, each host that participates in the sharing community has a program

2.1.1 Network application Architecture

1. C/S architecture

A host that is always on is called a server, and it serves requests from many other hosts called clients.

Limitations: A single server can’t keep up with its ability to manipulate customer requests

2. P2P architecture

The P2P architecture has minimal dependency on dedicated servers in the data center and uses direct communication between applications. One of its most intriguing features is self-extensibility

Limitations: Security, performance, and reliability challenges

2.1.2 Process Communication

With an operating system, it is actually the process, not the program, that communicates. A process can be thought of as a program running on an end system, where processes on two different end systems communicate by exchanging messages across a computer network.

  • The sending process generates packets and sends them to the network
  • The receiving process receives these messages and responds by sending back messages

1. Customers and service processes

  • Client process: The end that initiates the process
  • Server process: The process waiting to connect

2. Interface between process and computer network

Processes send and receive packets to and from the network through a software interface called a Socket.

  • A socket is an interface between the application layer and the transport layer in the same host.
  • The application developer can control everything about the socket on the application side, but has little control over the transport layer. In addition to: ① select transport layer protocol ② set several transport layer parameters

3. Process location

  • Hosts are identified by IP addresses
  • To send to a process on a host at the specified IP address, you also need to determine the port number. The default port for a common Web server is port 80

2.1.3 Provide transportation services used by the Program

The services that transport layer protocols provide to the applications that invoke them can be divided into four categories: reliable data transfer, throughput, timing, and security

  • Reliable data. Chapter 1 discusses the possibility of packet loss during packet switching. If a protocol ensures the correctness, order, and integrity of data, it is considered to provide reliable data transmission. (1) The loss of application data such as email, file, and Web document transmission may cause serious consequences. (2) Audio and video data can withstand certain data loss

  • Throughput: Rate at which bits are delivered between two processes

  • Timing: Ensures data transmission within a certain period of time

  • Security: As the name implies, the protection of data transmitted in the process

2.1.4 Transportation services provided on the Internet

1. The TCP service

(1) Connection-oriented services

  • Connection-oriented services: TCP lets the client and server exchange transport layer control information with each other before packets flow.
  • This so-called handshake process alerts the client and server to prepare them for the arrival of a large number of packets
  • After a TCP connection is established between the socket of two processes, both parties can send and receive packets on the connection
  • When the packet relaxation ends, the connection must be removed.

(2) Reliable data transmission service

  • Communication processes rely on TCP to deliver all data error-free and in the proper order

(3) Congestion control Mechanism When the network between the sender and the receiver is congested, the TCP congestion control mechanism keeps sending packets.

2. The UDP service

UDP is a lightweight transport protocol that provides minimal services without unnecessary services. It is connectionless and provides unreliable data transmission.

3. Security service, throughput service and timing service

  • Neither TCP nor UDP provided any encryption mechanism, so the Internet developed an enhanced version of TCP calledSecure Socket layer(SSL)
    • Process-to-process security services are provided through SSL, including data encryption, data integrity, and endpoint authentication
    • Note that SSL is an enhancement of TCP and not a protocol
    • SSL is implemented at the application layer
  • Throughput services and timing services, although not explicitly specified in the transport protocol, are ensured as much as possible by all current designs.

2.1.5 Application Layer Protocols

Application layer protocols define how application processes running on different end systems pass messages to each other:

  • Type of the exchanged packet
  • Syntax of various packet types
  • Semantics of fields
  • Rules for when and how a process sends and responds to messages

2.1.6 Network Applications

Five important network applications: web, file transfer, E-mail, directory services, streaming video, and P2P

2.2 the HTTP protocol

2.2.1 HTTP overview

Profile 1.

  • HTTP: Hypertext transfer protocol
  • C/S architecture: Web client and Web server
  • HTTP defines how web clients request Web pages from web servers and how servers send Web pages to clients

2. Transportation services

HTTP uses TCP as its supporting transport protocol

  • The client initiates a connection to the server
  • Once the connection is established, a process between the browser and the server can access TCP through a socket interface
  • The client sends HTTP request packets through the socket and receives HTTP response packets from the socket
  • TCP provides reliable data transmission services
  • The response packet from the server is returned to the client intact

Note: HTTP is a stateless protocol. The server sends the requested file to the client without storing any state information about the client

2.2.2 Non-continuous connection and continuous connection

1. HTTP for non-persistent connections

Each request/response between the client and the server is sent over a separate TCP connection

Disadvantages:

  • A new connection must be established for each request object, and TCP buffers and TCP variables must be allocated between the client and the server, placing a heavy burden on the server
  • Each object suffers twice the delivery delay of RTT, one for establishing TCP and one for requesting and receiving an object

2. HTTP for persistent connections

(1) HTTP Persistent Connections (also called HTTP keep-alive)

In the HTTP1.1 persistent connection scenario, the server keeps the TCP connection open after sending the response. Subsequent request packets and response packets can be transmitted over the same TCP connection.

(2) pipelining

Persistent connections make it possible to pipelinize — to make the next request without waiting for the next one to respond

2.2.3 Format of HTTP Packets

accesshackr.jpIs the header information of the request packet

1.HTTP request packets

  • Request line: Request method + URI + protocol version

    • GET, POST, PUT, HEAD, OPTIONS, TRACT, CONNECT, LINK, UNLINK
    methods instructions Supported HTTP version
    Get Access to resources 1.0, 1.1,
    POST Transport entity body 1.0, 1.1,
    PUT Transfer files 1.0, 1.1,
    HEAD Obtaining packet header 1.0, 1.1,
    DELETE Delete the file 1.1
    OPTIONS Ask for supported methods 1.1
    TRACK Tracking path 1.1
    CONNECT The tunnel protocol connection agent is required 1.1
    LINK Establish relationships with resources 1.0
    UNLINK Disconnection relation 1.0
    • URI

N/A Protocol: HTTP and HTTPS N/A Login information: Optional. Set the username and password as the login information for obtaining data from the server. N/A Server ADDRESS: a common URL that is resolved to a unique HOST IP address through the DNS. Access the server socket, the web server default port number is 80 – level file path: specifies the path of the specific file on the server for resources – check out characters: optional, to have the specified file path can use the resources in the query string – fragment identifier: optional, mark has access to resources of subresource – protocol version: Http0.9, http1.0, http1.1

  • Header field: see below
  • Packet Entity Content

2.HTTP response packets

  • Status line: protocol version + status code + status code cause phrase

    • Protocol versions: HTTP0.9, HTTP1.0, and http1.1
    • Status code:

    -200 OK: Normal processing. -204 No Content: The received request was successfully processed, but the response packet returned does not contain the body of the entity. -206 Partial Content: -301 Moved Permanently: Permanently redirected Permanently, indicating that the requested resource has been assigned a new URI-302 Found: Temporary redirection: the requested resource has been assigned a new URI. -303 See Other: The requested resource has another URI. -307 Temporary Redirect: indicates a Temporary redirection. -400 Bad Request: Indicates that a syntax error occurs in the Request packet. -401 Unauthorized: -403 Forbidden: The requested resource is rejected by the Server. -404 Not Found: The requested resource cannot be Found on the Server. -500 Internal Server Error: An error occurred while the server was executing the request – 503 Service Unavailable: The server is overloaded or is down for maintenance

  • Header field: see below

  • The main body

3. Header field

  • Generic header field

  • Request header field

  • Response header field

  • Entity head field

2.2.4 Cookie (HTML5: localStorage, sessionStorage)

1.cookie

We learned earlier that the HTTP server is stateless. A Web site usually wants to be able to identify a user, and HTTP uses cookies for this purpose.

  • Request in the state without Cookie information

– Request message– Response packet

  • A request with Cookie information in it

– Request message

2. LoaclStorage and sessionStorage

Reference article: Introduction to localStorage and sessionStorage

SessionStorage and sessionStorage are two new features of HTML5, these two features are mainly used as sessionStorage and local storage to use, solve the problem of insufficient cookie storage space;

  • localStorage

    • An object Storage that allows access to a Document source accesses data from the current source
    • Can only be manually cleared, otherwise it has been stored in localStorage
  • sessionStorage

    • Allows access to a session Storage object
    • Cleared at the end of the page, the page session is saved for as long as the browser is open
(1) Similarities
  • The storage capacity is about 5MB
  • The same origin policy cannot be accessed across domains
  • Data is stored only on the client and does not participate in communication with the server
  • Store data in the form of keys and values. The value must be a string. If the value is not a string, it will be automatically converted (if the value is an object, it must be converted to JSON for storage).
(2) Differences
  • LocalStorage can only be manually cleared; otherwise, it is always stored in localStorage. The sessionStorage page clears at the end, and the page session is saved for as long as the browser is open
  • As long as localStorage in the same browser can share data, can read each other, overwrite, clear (note the same browser, the same origin); SessionStorage data is restricted to same-browser, same-origin, same-page.

2.2.5 Proxy server: Web cache

A Web cache, also known as a proxy server, satisfies the web entities of HTTP requests on behalf of the original Web server.

2.2.6 HTTP Append Protocol

Due to the limitations of HTTP protocol and its limited performance, Web browsers based on HTTP have been all over the world. So some of the new protocols are based on HTTP and add some new functionality on top of that.

1. SPDY to eliminate HTTP bottlenecks

Some of the HTTP standards become a bottleneck in implementing the functionality needed for the Web.

  • Only one request can be sent on a connection.
  • Requests can only start from the client.
  • The client cannot accept instructions other than responses.
  • Request/response sent uncompressed. The more headers, the greater the delay.
  • Send lengthy headers. Sending the same header each time causes more waste.
  • You can choose any data compression format. Uncompressed send.
(1) Ajax (Asynchronous JavaScript and XML)

Ajax is an asynchronous communication method that effectively leverages JavaScript and DOM operations to achieve partial Web page replacement loading.

  • Core technology: XMLHttpRequest API, through JavaScript scripting language call and server HTTP communication
  • Advantages: Only a portion of the page is updated, reducing the number of transports in the response
  • Question:
    • May generate a large number of requests
    • The HTTP protocol itself has not been solved
(2) the Comet

Once something is updated on the server side, Comet does not let the request wait and returns a response to the client. This is a delay through the implementation of the simulation server to the client push function.

  • How it works: Usually the server receives a request and immediately returns a response after processing it. But for pushing, Comet suspends the response and returns it when something is updated on the server. Therefore, as soon as there is an update on the server side, it can be immediately reported back to the client side.
  • Advantages: Achieved real-time update
  • Question:
    • In order to save the response, a response time is longer, and more resources are consumed to maintain the connection during that time.
    • The HTTP protocol itself still has not solved the problem
(3) Design and function of SPDY

In the seven-tier model, SPDY belongs to the session layer and is intended to address HTTP bottlenecksFunctions:

  • Multiplexed streams: Unlimited processing of multiple HTTP requests over a single TCP connection. All requests are processed on a single TCP connection, so TCP processing is more efficient.
  • Prioritize requests: Not only can SPDY process requests concurrently without limit, but it can also prioritize requests one by one. This is mainly to solve the problem of slow response due to low bandwidth when multiple requests are sent.
  • Compressing HTTP headers: Compressing HTTP request and response headers. As a result, fewer packets are generated and fewer bytes are sent.
  • Push function: The server actively pushes data to the client. This way, the server can send data directly without waiting for the client to request it.
  • Server prompt function: the server can actively prompt the client to request the required resources. Because the existence of a resource is known before the client discovers it, unwanted requests can be avoided, for example, if the resource is cached.
(4) WebSocket: full-duplex communication standard between Web browser and Web server.

Using Ajax and Comet technologies to communicate can speed up Web browsing. However, the problem is that if HTTP protocol is used for communication, it cannot completely solve the bottleneck problem. WebSocket network technology is a new protocol and API to solve these problems.

2.2.7 HTTPS

2.3 the DNS protocol

What happens between entering a URL from the browser and the browser rendering the page? This is a common question and the answer is as follows:

  • If not, the browser will complete your protocol number and port for you.
  • The browser then analyzes the protocol number, domain name, and port of the address. Against the domain names in the cache.
  • If they are the same, get the IP address directly.
  • If no, go to the local DNS server. Others get an IP address.
  • If not, go directly to the root DNS server. At this point, the root DNS server either gives the IP address or indicates which DNS server to look for. Until we find an IP address. This process is called DNS resolution.
  • Once you have the IP address, you need to communicate with it. Therefore, the TCP connection is established through the three-way handshake.
    • The client sends a packet to the server indicating that I want to request a connection.
    • When the server receives the request, it sends a packet back to the client indicating that I have received your request.
    • The client sends another packet to indicate that the handshake ends
  • The client sent a request packet. Procedure
  • The server processes request packets and sends response packets.
  • The browser receives the response message and the rendering process starts rendering the page.
    • Parsing the HTML generates a DOM tree.
    • Parsing CSS generates a CSSOM tree.
    • Combine the DOM and CSSOM trees to generate a render tree.
    • Traverse the render tree to start the layout, calculating the location and size of each node and other information.
    • Draws each node of the render tree to the screen.
  • The browser renders and closes the connection with four waves.
    • The browser sends a packet requesting disconnection.
    • The server sends a packet to the client indicating that I have received your request.
    • The server sends the packet to the client again, indicating that I also want to disconnect.
    • The client sends a packet to the server indicating that I have received your shutdown request. The connection is then closed and the communication ends.

2.3.1 What is the DNS protocol

There are two ways to identify a host: IP address and domain name

  • An IP address is hierarchical data, which is easy to search on the network
  • Domain name: a host name for easy memorization

To meet these two requirements, the DNS uses the Domain Name System (DNS) to map Domain names to IP addresses

The last four questions found a well-written blog on the Nuggets

2.3.2 Domain names and DNS servers

2.3.3 DNS Query Methods

2.3.4 DNS Cache

2.3.5 Complete Domain name resolution process

3. The transport layer

The transport layer lies between the application layer and the network layer. In Internet protocols, we focus on TCP and UDP

3.1 Overview and Transport Layer services

  • Transport layer protocols provide logical communication between different processes running.
  • Application processes send messages to each other using logical communication capabilities provided by the transport layer, regardless of the details of the physical infrastructure that hosts these messages
  • The transport layer protocol is implemented in the end system:
    • At the sender, the transport layer converts the message received from the application process into a message segment
    • Add a transport layer header to each packet segment to generate a transport layer packet segment
    • These segments are passed to the network layer
    • The network layer encapsulates the packet and sends it to the destination
    • At the receiving end, the network layer extracts the transport layer segment from the packet and submits it to the upper transport layer
    • The transport layer processes the received message segment
    • The data in the packet segment is used by the receiving application process

3.1.1 Relationship between transport Layer and network Layer

  • The transport layer is above the network layer
  • The network layer provides logical communication between hosts
  • The transport layer provides logical communication between different processes between hosts
  • The services that the transport layer can provide are often constrained by the services of the network layer
  • Transport-layer protocols can provide some services even if the underlying network layer does not

3.1.2 Overview of the Internet Transport layer

A few concepts:

  • The transport layer groups are called packet segments
  • IP protocol at the network layer provides logical communication between hosts
  • IP protocol is an unreliable service, and its service model is to do its best to deliver the service, that is, it does not ensure the delivery of the packet segment, does not guarantee the sequential delivery of the packet segment, and does not guarantee the integrity of the data in the packet segment
  • Each host has only one IP address

1. Service model provided by UPD and TCP

  • Multiplex and multiplex decomposition of transport layer
  • Provide integrity checks

2. Additional TCP services

  • Reliable data transfer service
  • Congestion control

3.2 Multiplexing and multiplexing

Extend the host-to-host delivery services provided by the network layer to provide process-to-process delivery services for applications running on the host.

  • Multiplexing: The source host collects data blocks from different sockets, adds header information to each data block to generate message segments, and sends the message segments to the network layer
  • Multiplexing: The receiver, the transport layer checks these fields, identifies the receiving socket, and directs the message segment to that socket.

3.3 Connectionless Transport: UDP

3.3.1 Features of UDP

  • Best service
    • The loss of
    • out-of-order
  • There is no connection
    • There is no handshake between the UDP sender and receiver
    • Each message segment is processed individually
  • The application of UDP
    • Streaming media, not loss sensitive, but speed sensitive
    • DNS
    • SNMP

3.3.2 UDP Packet Segment Structure

Reason for existence:

  • No connection is established to reduce latency
  • Simple, no connection state
  • The header cost of the packet segment is small
  • Without congestion control or traffic control, UDP packets can be sent as quickly as possible

3.3.3 UDP Checksum

Detects errors in the transmitted message segment

3.4 Connection-oriented Transport Service: TCP

3.4.1 track TCP

Summary:

  • Point-to-point: one sender and one receiver
  • Reliable sequential byte stream
  • Pipelining: Set the window size for TCP congestion control and flow control
  • Send and receive caches
  • Full-duplex data: Data flows in both directions
  • Connection-oriented: Connections are made before transmission
  • There is flow control: sending does not overwhelm the receiver

1. TCP connection management

The three-way handshake of TCP and the four-way handshake of TCP and the three-way handshake of TCP

(1) TCP is called connection-oriented because two processes must shake hands before one process can send data to the other. That is, they must send some preparatory message segments to each other to establish parameters to ensure data transmission. What we call the three handshakes:

  • The client sends a SYN to indicate that it wants to establish a connection to the server. And with the serial ISN
  • The server returns an ACK (serial number: client serial number +1) as an acknowledgement. Also send a SYN as a reply (the SYN sequence number is unique to the server)
  • The client sends an ACK to acknowledge receipt of the reply (serial number is server serial number +1)

1. Why three handshakes, not two or four?

Because TCP connections are full-duplex, data can be transmitted in both directions simultaneously. So you want to make sure that both parties can send and receive data at the same time

  • First handshake: prove that data can only be sent by sender
  • Second handshake: ACK ensures that the recipient can receive data, syn ensures that the recipient can send data
  • Third handshake: data can only be received after sending
  • Four handshakes are wasted. Two handshakes cannot guarantee “both parties have the sending and receiving function”.

2. Why does the client send a confirmation at the end? The main purpose is to prevent the invalid connection request message segment from suddenly being sent to the server, resulting in an error.

(2) Once a TCP connection is established, the two processes can send data to each other

  • The client process passes the data stream through the socket
  • TCP boots this data into the connection’s send cache (established during the handshake)
  • TCP fetches a piece of data from the send cache and adds a TCP header to it to form a TCP packet segment and send the data to the network layer.
    • The TCP specification does not explicitly say when TCP should be sent
    • MSS: Indicates the amount of data that TCP can retrieve from the cache and put into the packet segment

(3) The so-called quadruple wave is the release (disconnection) of the TCP connection. The connection must be released actively on one side and passively on the other.

  • The closing party sends the FIN to unilaterally shut down data transmission
  • Upon receiving the FIN, the server sends an ACK (serial number +1) as an acknowledgement.
  • After data transmission is complete, the server also sends a FIN identifier to disable data transmission in this direction
  • The client replies with an ACK to confirm the reply

Why is a wave four times and a handshake three times? The “four wave” is required for TCP connection release because the FIN release packet and ACK acknowledge packet are transmitted through the second and third handshake respectively. Why are connections made together and released separately?

  • When establishing a connection, the passive server completes the CLOSED phase and enters the Handshake phase without any preparation. It can directly return SYN and ACK packets to start establishing a connection.
  • When releasing a connection, the passive server receives a request from the active client to release the connection but cannot release the connection immediately because necessary data needs to be processed. Therefore, the server sends an ACK message to confirm receipt of the packet and then returns a FIN packet to release the connection after the close-wait phase is complete.

2.TCP packet segment structure

  • Source port, destination port: used for multiplexing and multiplexing
  • 32 bit serial number field and 32 bit confirmation number field: used for reliable data transmission
  • 16-bit receive window field: used for flow control
  • 4-bit header length field: indicates the length of the TCP header
  • Optional and variable length option field: Indicates the maximum number of packets negotiated between the sender and the receiver, or used as a window regulator on a high-speed network.
  • 6 bit flag field:
    • ACK: Verifies that the value in the field is valid
    • RST, SYN, AND FIN: Connects, establishes, and disconnects
    • CWR, ECE: used in explicit congestion notices
    • PSH: Set to indicate that the receiver should immediately submit data to the upper layer
    • URG: indicates that the packet segment contains data whose upper-layer entity of the sending end is set to Critical
      • Emergency data pointer field: The last byte of emergency data

3.4.2 Principle of reliable data transmission

1. Rdt1.0 agreement

Consider the simplest case first, where the underlying communication channel is completely reliable

  • The sender
    • Rdt_send (data) : receives data from a higher level
    • Make_pkt (data) : Generates a group containing this data
    • Send packets to a channel
  • The receiving end
    • Rdt_rcv: Accepts a packet from the underlying channel
    • Extract (packet, data) : Extract data from a packet
    • Deliver_data (data) : Sends data to higher levels

2. Rdt2.0 agreement

The first protocol is the case when the data is considered completely reliable, but in the real model is the model in which the bits in the grouping may be damaged.

  • The sender

    • Condition 1:
      • The sending protocol waits for data to be transmitted from the upper layer
      • Rdt_send (data) : Receives data from higher levels, with validation and
      • Make_pkt (data) : Generates a group containing this data
      • Udt_send (SNDPKT) : sends the packet
    • Condition 2:
      • Wait for an ACK or NAK packet from the receiver
      • Rdt_rcv (RCVPKT) && isACK(RCVPKT) : indicates that the receiver has correctly received the packet and the status changes to waiting for upper-layer call
      • Rdt_rcv (RCVPKT) &&isNAK(RCVPKT) : indicates that the response of the previous packet receiver is retransmission, re-uploads the packet and waits for ACK and NAK sent back by the receiver
  • The receiving party

    • The packet is not damaged, return ACK
    • Packet damaged, return NAK

3. Rdt2.1 agreement

Rdt2.0 appears to work, but has a fatal flaw that does not take into account the possibility of ACK or NAK corruption. So ordinals were introduced on top of RDT2.0.

The senderThe receiving party

4. RDT 3.0

In addition to the bit damage, we also consider the situation of packet loss in the underlying channel in the computer network.

Set a reverse tech timer

  • A timer is started each time a packet is sent
  • Response timer interrupt
  • Stop timer

5. Line

Rdt3.0 is a well-functioning transport protocol, but the special performance of its stop-wait protocol (waiting for an ACK from the receiver before entering the state of waiting for a call from the upper layer) causes inefficiencies.

Workaround: Does not run in a pause mode, allowing the sender to send multiple packets without waiting for confirmation. This technique is calledAssembly line.

The impact of assembly line:

  • The ordinal range must be increased because each group must have a unique identifier
  • The sender and receiver of the protocol must cache multiple packets
  • The buffering requirements of the desired sequence number range depend on how the data transfer protocol handles lost, corrupted, and delayed packets. There are two basic methods to solve pipeline error recovery: N step back (GBN) and selective retransmission (SR)

6. Roll back the N-step protocol

N Step rollback protocol (GBN, sliding window protocol) : allows sending sending multiple packets without waiting for confirmation. However, the number of unconfirmed packets cannot exceed a certain maximum value N.

The reason for setting N is traffic control and congestion control

GBK protocol responds to three kinds of events:

  • The sender:

    • When the upper layer calls
      • The window is full. Tell the sender to wait
      • The window is full, a packet is generated and transmitted
    • Received an ACK
      • The window slides to the right
    • Timeout event
      • If an ACK is received but the previous packet is not acknowledged, restart the timer
  • Receiver:

    • The packet numbered N is received correctly and, in order, an ACK is issued for n
    • In all other cases, the receiver discards the packet and resends the ACK by selecting the packet with the closest sequence

7. Select retransmission Protocol (SR)

In order to ensure the correct order of grouping, the sliding window protocol retransmits data, but considering the large window length and bandwidth, it will cause efficiency problems caused by repeated transmission.

Option retransmission: Lets the sender retransmit only those packets that it suspects are in error at the receiver, avoiding unnecessary retransmission.

8. Reliable data transmission in TCP

The network layer service (IP service) of the Internet is unreliable, that is, it does not guarantee the delivery of data, the sequential delivery of packets, and the integrity of packets. TCP creates a reliable data transfer service, which ensures that the data transferred to the other end is not corrupted, no gap, non-redundant, and delivered sequentially.

We will explain how TCP achieves reliable data transmission based on the above principles:

  1. If the data from the underlying layer is completely reliable, according to RDT1.0 TCP only needs to transfer the data.
  2. Unfortunately, bits are often lost during network transmission, so according to RDT2.0, a checksum is added to ensure data correctness
  3. It seems that the above protocol is perfect, but there is still the problem of packet loss in network transportation. According to RDT3.0, a timer is introduced. When a packet is not sent after a period of time, the packet will be sent again and the timer will restart
  4. However, there is still a problem with timers. If the response packets are only delayed, how can they be distinguished from other packets? So we introduced the serial number. In this way, the receiver can determine whether the data is coming or retransmitted according to the byte number of the data.
  5. According to RDT, some protocols solve the problem of reliable transmission, but this is a stop-wait protocol, that is, in the process of transmission, if the response is not received, the upper-layer application has to wait, which is too low efficiency. Therefore, pipelining is introduced to send multiple packets without waiting for response packets.
  6. Networks are flooded with acknowledgements as much as packets are sent, because for every packet sent, there must be an acknowledgement. The way to improve network efficiency is: cumulative validation. The receiver does not need to reply one by one, but after accumulating a certain number of packets, tells the sender that all the data before this packet has been received. For example, if 1234 is received, the receiver only needs to tell the sender that I received 4, and the sender knows that 1234 was received.
  7. Cumulative confirmation improves network efficiency. However, in the case of packet loss, the GBN method is adopted, which retransmits all packets from the lost packet. Although this ensures the order of packets, it will cause serious resource waste once the packets are framed and the traffic is heavy. Therefore, you can set the received packet segment in the option field of a TCP packet. Each packet segment requires two boundaries. This allows the sender to retransmit only lost data based on the option field. This approach looks a lot like SR, so we say that TCP’s error-recovery mechanism for reliable data transmission is a hybrid of GBN and SR.
  8. Can I send indefinitely until all the data in the buffer is sent? Can’t. Because you need to consider the receiver buffer and the ability to read the data. If the packet is sent too fast for the receiver to accept, the packet is retransmitted frequently, wasting network resources. Therefore, the range of data sent by the sender needs to take into account the situation of the receiver buffer. This is TCP traffic control. The solution: sliding Windows.

3.4.3 Principle of congestion control

TCP congestion control algorithm and TCP congestion control: packet conservation, slow start, congestion avoidance, fast retransmission

TCP congestion control through maintaining a congestion window, congestion control principle is, as long as does not appear in the network congestion, the value of the congestion window can increase more, in order to get more data packets sent, but as long as the network congestion, the value of the congestion window should reduce some, to cut into the number of packets in a network.

During the development of TCP congestion control algorithm, several different ideas appeared as follows:

  • Congestion control based on packet loss: regard packet loss as congestion, adopt slow detection method, gradually increase the congestion window, when packet loss occurs, reduce the congestion window, such as Reno, Cubic, etc.

  • Delay based congestion control: the delay increase is regarded as congestion. When the delay increases, the congestion window increases, and when the delay decreases, the congestion window decreases, such as Vegas and FastTCP.

  • Congestion control based on link capacity: Measure network bandwidth and delay in real time. Congestion occurs when the total number of packets on the network is greater than the product of bandwidth and delay, such as BBR.

  • Learning-based congestion control: There is no specific congestion signal, but with the help of evaluation function, based on training data, using machine learning methods to form a control strategy, such as Remy.

The core of congestion control algorithm is to choose an effective strategy to control the change of congestion window