Current location - Quotes Website - Collection of slogans - Which field in the ip header between the first and second fragment has changed?
Which field in the ip header between the first and second fragment has changed?
Fundamentals of network programming 1. ISO/OSI Reference Model 1 and OSI (Open Systems Interconnection) are the network hierarchical models defined by ISO (International Organization for Standardization), which have seven layers. 2.Q PhysicalLayer: The physical layer defines the specifications of all electronic and physical devices, and provides physical media for upper layer transmission. The unit of data transmission in this layer is bits. The specifications defined in this layer include EIA/TIA RS-232, EIA/TIA RS-449, V.35, RJ-45, etc. , and the actual use of equipment, such as network cards, belong to this layer. Data Link Layer: Frames the bit stream received by the physical layer. Provide reliable data transmission service and realize error-free data transmission. The unit of data in the data link layer is a frame. The specifications defined in this layer include SDLC, HDLC, PPP, STP, Frame Relay, etc. , and the actual use of equipment, such as switches, belongs to this layer. Network layer: The network layer is responsible for routing, grouping and reorganizing data between subnets. The data transmission unit of this layer is packet. The specifications defined in this layer include IP, IPX, RIP, OSPF, ICMP, IGMP, etc. Devices in actual use, such as routers, belong to this layer. Q TransportLayer: provides reliable data transmission service, detects the packets discarded by the router, and then generates retransmission requests, which can reorder the received out-of-order packets. Q SessionLayer: Manage the session process between hosts, including session establishment, termination and management during the session. Q presentation layer: the presentation layer converts the data transmitted by the network, so that the information transmitted between multiple hosts can understand each other, including data compression, encryption, format conversion, etc. Q application layer: the application layer communicates with the application program interface to achieve the purpose of showing it to users. Common protocols here are: HTTP, HTTPS, FTP, TELNET, SSH, SMTP, POP3, etc. Two-layer model, TCP/IP four-layer model, peer-to-peer communication encapsulation demultiplexing port Q, well-known ports: from 0 to 1023, these ports are allocated and controlled by IANA, and they are closely bound to some services. Usually, the communication of these ports clearly indicates the protocol of a certain service. For example, port 2 1 is an ftp service port. Q Registration ports: from 1024 to 49 15 1. These ports are not controlled by IANA, but are registered by IANA and provide a list of use. They are loosely bound to some services. In other words, many services are bound to these ports, and these ports are also used for many other purposes. For example: 1433 Microsoft SQL service port Q Dynamicor private port: from 49 152 to 65535. IANA doesn't care about these ports. In fact, machines usually allocate dynamic ports from 1024. But there are exceptions: SUN's RPC port starts at 32768. 02TCP/IP fragment (2) 1. Both MTU Ethernet and IEEE 802.3 have limitations on the length of data frames, and the maximum values are 1500 and 1492 bytes respectively. This limitation is called the maximum transmission unit (MTU). If the IP layer has datagrams to transmit and the data length is greater than the MTU of the link layer, then IP. When two hosts on a network communicate with each other, they will pass through multiple networks, and the link layer of each network may have different MTU, among which the smallest MTU in the paths of two communication hosts is called the path MTU. 2. Ethernet frame format III. ICMP IV。 ARP V. Data transmission process in the network Step A: Using ping will determine whether the host name or IP address is sent, and call the function gethostbyname () to parse the host B and convert the host name into a 32-bit IP address. This process is called DNS domain name resolution. Step B: Ping sends an ICMP response packet to the destination IP address. Step c: Convert the IP address of the destination host into a 48-bit hardware address, and send an ARP request broadcast in the local area network to find the hardware address of host B. Step d: After receiving the ARP request from host A, the ARP protocol layer of host B fills in the hardware address of the host and sends the ARP reply to host A. Step e: Send an Internet control message protocol to host B. Step f: Host B receives the ICMP message from host A and sends a response message. Step g: Host A receives the internet control message protocol response packet from Host B ... intransitive verb RARP03TCP/IP basics (3) 1. IP datagram format 1. Version a) IP protocol version number, with a length of 4 digits. For IPv4, the value of this field is 4; For IPv6, the value of this field is 62. Header length a) The length of this field is 4 bits, and the maximum value is 15, so the header length. This field contains a 3-bit priority (now ignored), a 4-bit service type subfield, and a 1 bit reserved bit (which must be set to 0). The four-bit service types are respectively minimum delay (D), maximum throughput (T), maximum reliability (R) and minimum cost (F). 4.5. Total length a) The length of this field is 16 bits, in bytes, and the length of this field includes the header and data part of IP. The maximum size of an IP datagram is 65535 bytes. 6. Identification a) 16 bit identification, which is used to identify IP packets. Every time this value is sent, 17 is added. Identification and chip offset a) 3-bit identification, in which the first bit is not used and every two bits DF(Don? TFragment), if this bit is 1, if the datagram sent exceeds the maximum transmission unit, the datagram will be discarded and an ICMP error message will be sent. The third MF(More Fragment) indicates whether there are still fragments, which is 1, indicating that there will be fragments in the future. The last MF is 0. B) After IP fragmentation, each packet has its own header, but the chip offset value is different, and the receiving end can reassemble the IP packet by the chip offset value. 8. TTLA TTL (Time to Live) indicates the maximum number of routers that a datagram can pass through. Every time the datagram passes through the router, TTL is reduced by 1, and when it is reduced to 0, it is discarded, and an ICMP message is sent to inform the source host. TTL can prevent datagrams from constantly circulating between routers. 9. Protocol type a) indicates which advanced protocol is carried by the IP layer. In the process of encapsulation and sharing, the protocol stack knows which layer to hand over to. 1 icmp 2 igmp 6 TCP 17 UDP 10。 Header checksum a) The data integrity of the datagram header is guaranteed, but the checksum does not include the data part. This has two purposes: first, all high-level protocols that encapsulate data in IP packets contain checksums covering the whole data, so there is no need to check the data part carried by IP datagrams. Secondly, every time the router passes by, the header of the IP datagram will change, while the data part will remain unchanged, so it is obviously not a waste of time to check only the changed header. In order to reduce the calculation time, CRC is generally not used, but a simpler Internet checksum is used. 1 1.ttla) TTL (Time to Live) indicates the maximum number of routers that a datagram can pass through. Every time the datagram passes through the router, TTL is reduced by 1, and when it is reduced to 0, it is discarded, and an ICMP message is sent to inform the source host. TTL can prevent datagrams from constantly circulating between routers. 12. Protocol type a) indicates which advanced protocol is carried by the IP layer. In the process of encapsulation and sharing, the protocol stack knows which layer to hand over to. 1 icmp 2 igmp 6 TCP 17 UDP 13。 Header checksum a) The data integrity of the datagram header is guaranteed, but the checksum does not include the data part. This has two purposes: first, all high-level protocols that encapsulate data in IP packets contain checksums covering the whole data, so there is no need to check the data part carried by IP datagrams. Secondly, every time the router passes by, the header of the IP datagram will change, while the data part will remain unchanged, so it is obviously not a waste of time to check only the changed header. In order to reduce the calculation time, CRC is generally not used, but a simpler Internet checksum is used. 14. Source IP address a) IP address of the host sending data 15. Destination IP address a) IP address of the host receiving data 16. Option and padding (the option is an integer multiple of 4 bytes, otherwise padding is 0) a) security and processing restrictions b) path recording: recording the IP address experienced by the router c) timestamp: recording the IP address and time experienced by the router d) loose source station routing: specifying the IP address that the data message must go through, which can be through an unspecified IP address. E) Strict source station routing: specify the IP address that the data message must pass through, but not the unspecified IP address. Second, Internet Checksum, the English full name (Internet checksum) The sender divides the data to be sent into many word sequences of 16 bits (if the number of bytes of data is odd, add a byte 0 at the end to make it even. ) sum the inverse codes of these sequences to get a checksum. If there is no error in data transmission, the checksum calculation result of the receiver should be 1. If the result is not all 1 (i.e. checksum error). 3.TCP/IP routing foundation 04 (4) 1. The characteristics of TCP are basically connection-oriented, reliable transmission, buffered transmission and full-duplex flow control 2. TCP segment format 1. Source and destination port numbers a) The source and destination port numbers, together with the source and destination IP addresses of the IP header, uniquely determine the TCP connection. 2. Sequence number a) The sequence number indicates the sequence number of the first data byte in the message segment. 3. The confirmation number a) is only valid when the ACK flag is 1. The acknowledgement number indicates the sequence number of the next byte expected to be received. 4. The header length a) is 4 bits, and the TCP header is 60 bytes at most. Reserved bit a) 6 bits, which must be 06. 6 flag bits: a)urg- emergency pointer is valid; B)ack- confirm that the serial number is valid; C)psh- The receiver shall hand over the message segment to the application layer as soon as possible; D)rst- connection reset; E) the synchronization serial number is used to initiate the connection; F)fin- indicates that the connection will be terminated; 7. Window size 8. The flow control is realized by the window size. 9. Checksum 10. Check the tcp header and data 1 1. The emergency pointer a) is a positive offset that is added to the value in the sequence number field to indicate the sequence number of the last byte of emergency data. The emergency mode of TCP is a way for the sender to send emergency data to the other end. 12. Option and padding (the option is an integer multiple of 4 bytes, otherwise padding with 0) a) The most common optional field is MSS (maximum segment size), and each connecting party usually indicates this option in the first message segment of the communication. It represents the maximum length of a message segment that a local terminal can receive. If this option is not set, it defaults to 536 (IP datagram with 20+20+536 = 576 bytes). 3. three-way handshake for connection establishment. 4. Four handshakes when the connection is terminated. 5. How does 5.TCP ensure reliability? Application data is divided into data blocks that TCP thinks are most suitable for transmission, which is called segmented transmission to IP layer. When TCP sends out a segment, it starts a timer and waits for the destination to acknowledge receipt of the segment. If the acknowledgement is not received in time, the message segment will be retransmitted. When TCP receives data from the other end of the TCP connection, it sends an acknowledgement message. This confirmation is not sent immediately and is usually delayed by a fraction of a second. TCP will keep the checksum of its header and data. This is an end-to-end checksum used to detect any changes in data during transmission. If there is an error in the checksum of the received message segment, TCP will discard the message segment, and will not confirm (causing the other party to retransmit overtime) that TCP is transmitted by IP datagram, and the arrival of IP datagram may be out of order, so the arrival of TCP segment may also be out of order. TCP will reorder the received data. The IP datagram will be copied, and the receiver of TCP must discard the copied data. TCP can also provide flow control. Each end of TCP connection has a certain buffer space. 05TCP/IP basics (5) 1. Sliding Window Protocol Notification Receiving Window (rwnd): prevents the data sent by the application from exceeding the buffer of the other party. Flow Control Congestion Window (cwnd) used by the receiver: prevents the application from sending more data than the network can bear. The flow control transmission window used by the sender takes ssthresh: the smaller value of the slow start threshold). Slow start-up phase: cwnd grows exponentially from 1 until the congestion avoidance phase of ssthresh; Cwnd grows linearly until congestion, cwnd= 1, and SSThresh is halved.