This is the 19th day of my participation in the Gwen Challenge.More article challenges

Fourth, network layer

4.1 The network layer provides only simple and flexible, connectionless, best-effort delivery datagram services

4.2 Internet Protocol IP

  • Address resolution protocol ARP

    • IP address —-> Physical address
  • Reverse address resolution protocol RARP

    • Physical address —->IP address
  • Internet Control Message Protocol, ICMP

    • Improve the chances of successful IP datagram delivery

    • Message types

      • Error report message

        • Out of reach
        • For more than
        • Parameters of the problem
        • Changing routes (redirection)
        • Source point inhibition
      • Ask a message

        • Echo request and reply
        • Timestamp request and reply
    • Four situations in which ICMP error report messages should not be sent

  • Internet Group management protocol IGMP

4.3 IP Address Division

  • Two IP addresses: Network number + host number

    • classification

      • A: 8 (1~126) +24

        • There are many hosts per network
      • B:16 (128~191) +16

        • 65534
      • C:24 (192~223) +8

        • 254
      • D: 1110 +… (Multicast address)

      • E: 1111 +…

    • Matters needing attention

      • The network id and host ID are all 0 or 1

      • Private IP address

        • 10.0.0.0 – those
        • Along ~ 172.31.255.255
        • 192.168.0.0~192.168.255.255
  • Tier 3 IP address: Network number + subnet NUMBER (generated by the host NUMBER) + host NUMBER

    • Subnet mask: Use consecutive 1s

    • Network address = Subnet mask &IP address

      • Different masks may yield the same network address
      • However, different masks have different effects and support different numbers of hosts

4.4 IP datagram

  • The first

    • Fixed part

      • version

        • It is a 4-bit IP protocol version
      • The length of the first

      • Distinguish between service

      • The total length

        • The length of the sum of the header and data
      • logo

        • A 16-bit counter used to generate the identity of a datagram
      • mark

        • Three. Only the first two are meaningful so far
        • The lowest value in the flag field is MF
        • MF=1, which means we have more fragments, and MF=0, which means we have the last one
        • When DF=0, sharding is allowed
      • Slice offset

        • The offset unit is 8 bytes
      • TTL TTL

        • The maximum number of routers that can pass through. This is the lifetime of datagrams in the network
      • agreement

      • Head check sum

      • Source address

      • The destination address

    • Optional part

  • Data section

4.5 IP Layer Forwarding groups

  • Destination network address, next-hop address

  • Looking up the Routing table

    • Only when it reaches the last router does it attempt to deliver directly to the destination host

4.6 Autonomous System

  • Internal Gateway protocol

    • RIP

      • Distributed routing protocol based on distance vector

      • The distance from a router to the network to which it is directly connected is defined as 1

      • A path can contain a maximum of 15 routers. A distance of 16 is unreachable

      • The fewer routers, the better

      • Applicable to small networks

      • RIP characteristics

        • Exchange information only with neighboring networks
        • The exchange information is all the information known by the current router, that is, the routing table in which the router resides
        • Exchange information at regular intervals
        • Good news is fast, bad news is slow (hence the network overhead)
        • The implementation is simple and the overhead is low, but…. As the size of the network grows, so does the overhead
    • OSPF: Open shortest path preference

      • Distributed link state protocol

      • The three main points

        • Send information to all routers in the autonomous system – flood method
        • Send message: Indicates the link status of all neighboring routers
        • The router sends this message to all routers by flooding only when the link status changes
      • Link state database – topology diagram of the whole network

      • OSPF divides an AS into several smaller areas or areas

      • OSPF transmits directly using IP datagrams

      • There are five OSPF group types

        • greetings
        • Database Description
        • Link state request
        • Link status update
        • Link status Confirmation
  • External Gateway protocol

    • BGP

      • A protocol for exchanging routing information between routers of different autonomous systems
      • The boundary Gateway protocol (BGP) is only trying to find a good route to the destination network (without going around in circles), not the best route

4.7 VPN

  • Establish a secure link (tunnel) on the public network for remote users to access the Intranet securely

4.8 NAT (Network Address Translation)

  • All hosts using local addresses must translate their local addresses into IPG on the NAT router to connect to the Internet when communicating with the outside world

5. Transport layer

5.1 Related Concepts

  • Communication between application processes (end-to-end communication)

  • The main function

    • Provides end-to-end logical communication between applications

      • Network layer: provides logical communication between hosts
    • Performs error detection on received packets

    • Two transport protocols

      • TCP

        • connection-oriented

          • Transmission control protocol
      • UDP

        • There is no connection

          • User datagram protocol

5.2 the UDP

  • There is no connection
  • Deliver with utmost effort
  • For a message
  • One on one, one on many, many-to-many…
  • The first overhead is small, taking only 8 bytes

5.3 the TCP

  • connection-oriented
  • Each TCP connection can have only two ports (point-to-point)
  • Reliable delivery of services
  • Full duplex communication
  • Word oriented stream

5.4 Format of UDP and TCP

  • UDP

    • The first field

      • Source port
      • Destination port
      • The length of the
      • Inspection and
    • The data fields

  • TCP

    • The first field

      • Source port

      • Destination port

      • The serial number

      • Confirmation no.

      • Data offset (header length) : Indicates the distance between the data and the start of the TCP segment

      • Keep field

      • Six status codes

        • Emergency URG

          • URG=1, indicating that the emergency pointer field is valid, i.e., equivalent to high priority
        • Confirm ACK

          • ACK=1, confirm that the field is valid
        • Push PSH

          • Receiving TCP Receives the packet segment with PSH = 1 and delivers the packet to the receiving application process as soon as possible
        • Reset RST

          • RST=1: indicates that a serious error occurs in the TCP connection. You must release the connection immediately and re-establish the transmission connection
        • Synchronous SYN

          • Synchronous SYN = 1 indicates that this is a connection request or connection accept message
        • Termination of the FIN

          • Used to release a connection. FIN =1 Indicates that the data on the sender end of the packet segment has been sent and the transport connection is released
      • window

        • The basis for setting the sending port
      • Inspection and

        • Inspection and inspection scope includes: header and data
      • Emergency pointer field

        • The number of bytes of emergency data in this paragraph
      • Option field

        • Initial: MSS (Maximum packet segment length) : The maximum data length of a packet segment is MSS bytes
    • The data fields

5.5 Common TCP Ports

  • 20: indicates the FTP data port
  • 21: FTP control port
  • 23: Indicates the Telnet port
  • 25: SMTP port
  • 53: indicates the DNS port
  • 80: INDICATES the HTTP port
  • 443: HTTPS port

5.6 TCP Traffic Control and TCP congestion control

  • Flow control

  • Congestion control

    • Congestion control VS flow control

      • Flow control

        • Control of point-to-point traffic is an end-to-end problem (receiver controls sender)
        • Inhibits the rate at which the sender sends data so that the receiver can receive it in time
      • Congestion control

        • Is a global process involving all hosts, all routers, all factors…
        • Prerequisite: The network can bear the current network load
    • Cause of congestion control

      • The total number of required resources on the network is greater than the available resources
    • General principles of congestion control

      • Packet loss is a symptom of congestion, but not a cause
    • Congestion control classification

      • Open loop control

        • The network is designed to take congestion into account beforehand
      • Closed-loop control

      • Based on the concept of feedback loops

    • TCP congestion Control Method (Closed-loop Control)

      • The basic concept

        • TCP Windows – based congestion control

        • The sender maintains a congestion window CWND

        • Real sending window value =min (receiving window of the receiver’s announcement window, congestion window value)

        • Control congestion window principle

          • As long as there is no congestion, make the window bigger
          • If congestion occurs, turn the window down
        • Congestion judgment

          • The retransmission timer timed out
          • Three identical (duplicate) Acks were received
      • TCP congestion control algorithm

        • Slow start

          • The value of congestion window increases gradually from small to large
          • Congestion window control method: After receiving the confirmation of a new packet segment, you can increase the congestion window by a maximum of one SMSS value
        • Congestion avoidance algorithm

          • Linear growth
        • Fast retransmission

          • Perform retransmission directly
        • Fast recovery

          • After receiving three consecutive acknowledgements, the sender considers that the current network is not congested and does not perform slow start but fast recovery
          • Fast start threshold = Current congested window /2
          • New Congestion window = fast start threshold
          • Start performing the congestion avoidance algorithm to make the congestion window

5.7 TCP Transport Connection Management

  • Three stages of transport connection

    • Connection is established

      • The TCP connection process is called handshake

        • The handshake requires sending three TCP segments between the client and server

        • Three-message handshake (three-way handshake

          • Prevents an error when an invalid connection request segment is suddenly sent again
          • Third time: Reconfirmation of confirmation is very important
    • Data transfer

    • Connection release

      • Four times to wave

      • A must wait 2MSL

        • Set a time long enough for all network resources to be released
  • Transport connection management: the release and management of transport connections can be carried out normally

5.8 Three handshakes

5.9 IP Data Segment = Header + Data (TCP/UDP Header + Data Fields)

5.10 pay attention to

  • A connection is a virtual one, not a real physical one

  • The port of a TCP connection is a socket or socket

  • IP address + port number = socket

  • ARQ: automatically requests for retransmission

  • CRC: cyclic redundancy check

    Features: Strong error detection ability; Overhead is minimal; Easy to implement

5.11 Generation of FCS code

  • Select a divisor (a polynomial)

    • The highest and lowest bits of the polynomial must exist
  • Fill 0

    • The length of the polynomial is reduced by one
  • Do division

  • Subtract (xor operation)

  • The remainder is 1 less than the divisor and stops

5.12 CRC is an error-checking method, while FCS is a redundant code added to the end of data