Chapter VIII of the socket network programming (1): Network protocol basis

What network is:

  • Internet Protocol: Internet communication in order to develop unity and agreement, as long as the procedures to follow this standard organizational data, you can communicate with any objects

  • Internet Protocol (sub-process may be split into different layers 4,5,7):
    • OSI7 layer protocol:
      1. Application layer
      2. Presentation layer
      3. Session Layer
      4. Transport Layer
      5. Network layer
      6. data link layer
      7. Physical Layer
    • Layer 4 TCP / IP protocol:
      1. application
      2. Transport Layer
      3. Network layer
      4. Interface Layer
    • 5-layer protocol:
      1. Application Layer: generating data
        • Processing of the data packet: generating a header and application layer data
        • You can use any protocol: http, ftp, custom protocols, etc.
      2. Transport Layer:
        • Processing of the data packet: the first port to see the data and the data layer as the data, and then add a port (transport layer) header
        • Using TCP / UDP port protocol:
        • Port: port range (0 to 65535), each start a software on a computer will correspond to a port. IP and port so you can determine the specific computer software specific
      3. Network layer:
        • Processing of the data packet: the first port and transport layer data as a data look, then add an IP header
        • IP protocol:
          • Data into IP protocol IP header (source IP address, destination IP address, the data description information) and a data portion
        • Using the ARP protocol: Get MAC address IP
      4. Data Link Layer: The electrical physical layer packet, it makes sense to do this using the Ethernet protocol
        • Processing of the data packets: the IP header of the network layer and the data look as data, and a header added to the data link layer
        • Use Agreement Ethernet (Ethernet):
          • A set of electrical signals referred to as data packets / frames
          • A datagram is divided into header (Source Address: 6 -MAC byte address, destination address: Address 6 bytes -MAC, description data: 6 bytes, a total of 18 bytes) and a data portion

            MAC address can only guarantee card

          • Mode of operation: a broadcast mode based on the MAC address, to complete the data transfer. → only on a local area network
      5. The physical layer: an electrical signal through a physical device for transmitting data (01010101), receiving an electric signal

    Whatever the layer length of the header data should be fixed, specific length of the layer may vary by

IP + MAC can determine the world's unique card
ARP (Address Resolution Protocol) protocol: Get a physical address of TCP / IP protocol based on IP address. (Available through broadcast, and will remain for some time in the cache)

Retransmission data packet: header adding process received data hold: demolition process header

The client and server:
+ server must continue to provide service
+ server IP and port can not just change, the client does not need a fixed IP and port

Guess you like

Origin www.cnblogs.com/py-xiaoqiang/p/11298953.html