TCP/IP packet Structure specific explanation

Source: Internet
Author: User

[ keywords ] TCP IP Packet architecture specifically interprets network protocols

In general, network programming we just need to call some packaged functions or components to complete most of the work, but in some special cases, we need to understand deeply

The structure of network packets, and protocol analysis. such as: network monitoring, troubleshooting, etc...

IP packet is not secure, but it is the foundation of the Internet, in all aspects have a wide range of applications. There are 10 of protocol families derived from the IP protocol (as far as I know).

Many other IP-based protocols ...

Let's start with the actual situation!

In general, we talk about the speed of the Internet, the professional use of bandwidth to describe the narrative, in fact, regardless of speed or bandwidth is not accurate, hehe. Analogy: 1 trillion, 512K ...

Some students in the school, may have doubts, clearly my business is 1M, why download speed to 100K will not go up? 512K Why is 50 more K capped? ...

The 1M referred to here refers to 1Mbps = 1 Million bits per Second, which is 1M bits/second, that is, a second transmission of 1,048,576 bits. We know of a byte

is a 8-bits.

OK, here comes the question again. Even so, 1m=1048756÷8=131072÷1024=128k. That should also have 128K ah, why download speed is still very little to 120K,

110K all thank goodness. After reading this article, your account is right ...

IP Packet Structure :

, a scale represents 1 bits (bits).

1-1. Version number 4 bit, indicating the version number, the most widespread is 4=b1000, that is often said IPv4; believe that IPV6 will be widely used later, it can give every button in the world assigned

An IP address.

1-2. Head length 4 bits, data Baotou Minister degree. It indicates how many 32-bit long integers the packet header contains, that is, how many 4-byte data. No option is 5 (red part).

1-3. Service type, contains 8 bits, each bit of meaning such as the following:

Procedure field: 3 bits, sets the importance of the packet, the larger the value, the more important the value range is: 0 (normal) ~ 7 (Network control)

Delay field: 1-bit, value: 0 (normal), 1 (period low delay)

Traffic field: 1 bits, Value: 0 (normal), 1 (Period of high traffic)

Reliability field: 1-bit, value: 0 (normal), 1 (period extra high reliability)

Cost field: 1-bit, value: 0 (normal), 1 (period min cost)

Reserved fields: 1-bit, not used

1-4. The total length of the package is 16 bits, the current packet size, in bytes. Of course, the maximum is only 65535, and 64KB.

2-1. The reorganization identifies 16 bits, sending the identity assigned by the host so that the receiver can perform the Shard reorganization.

2-2. Sign 3 bits, their respective meanings for example the following:

Retention field (2): 1-bit, not used

No division (1): 1 bits, Value: 0 (Consent datagram segmented), 1 (datagram cannot be segmented)

Many other fields (0): 1 bits, Value: 0 (no packets behind the packet, the package is the last package), 1 (there are many other packages behind the packet)

2-3. Segment offset 13 Bits, combined with many other fields, help the receiver to combine segments of the message in bytes.

3-1. Survival time 8 bits, often ping command to see the TTL (Time to Live) is this, each through a router, the value is reduced by one, to zero drop.

3-2. Protocol code 8 BITS, indicating the use of the package upper layer protocol, such as TCP=6,ICMP=1,UDP=17.

3-3. Head inspection and 16-bit, is the checksum of the IPV4 Data header section.

4-1. Source start Address, 32 bits 4 bytes, we often see the IP is to separate each byte with a dot (.), that's all.

5-1. Destination address, 32 digits, ibid.

6-1. Optional options, mainly for special situations, often safe routing is filtered out as an attack, and Puling (tp_link) tl-er5110 routing can do so.

7-1. User data.

TCP Packet Structure :

1-1. Source starting port16 bit, range of course is 0-65535.

1-2. Destination port, ibid.

2-1. Data sequence 32 bits, TCP for each byte sent to a number, where the current packet data is stored in the first byte ordinal.

3-1. Confirm the serial number 32 bits, for security, TCP tells the recipient that he wants to receive the first byte ordinal of the packet next time.

4-1. Offset 4 bits, similar to IP, indicates how many 32 bits of data are from the header .

4-2. Reserved 6 bits, unused, zero should be placed.

4-3. Emergency bit urg-when urg=1, indicates that the emergency pointer field is valid. It tells the system that there are emergency data in this segment and should be transmitted as soon as possible (equivalent to high-priority data).

4-3. Confirm that bit ack-only has the Confirm Number field when Ack=1 is valid. The confirmation number is invalid when ack=0. TCP Three-time handshake

4-4. Reset-When rst=1 indicates a serious error in the TCP connection (such as a host crash or other reason), the connection must be released and then again

Establish a transport connection. TCP Three-time handshake

4-5. Synchronous bit syn-synchronous bit SYN is set to 1, which means that this is a connection request or a connection acceptance message. TCP Three-time handshake

4-6. Terminating bit fin (FINal)-Used to release a connection. When Fin=1, it indicates that the data of the sending end of this segment has been sent and the transport connection is released.

4-7. form field 16-bit, the form field is used to control the amount of data sent by the other, in bytes. One end of a TCP connection determines its own receive form based on the size of the cache space set

Size, and then notify the other party to determine the upper limit of the sending form.

5-1. Package checksum 16-bit, including the header and data of the two parts. In the calculation of the test and, the TCP message segment to precede the 12-byte pseudo-header.

5-2. Emergency pointer 16-bit, emergency pointer indicates the last byte ordinal of the emergency data in this section.

6-1. Optional option 24-bit, similar to IP, is optional.

6-2. Fill 8 bits to make the options 32 bits.

7-1. User Data ...

Can be seen, each IP packet at least 20 bytes of head length, these are not related to the download, plus the current majority of transmission, including the HTTP protocol (ie direct download), are based on

TCP protocol, so the IP package will also be deducted from user data 20 bytes of TCP header, here is already 40 bytes, plus other program connection, status confirmation and so on package, because

And the calculation is smaller than the theoretical value.

In addition, the network environment (including the stability factor and the transmission node's forwarding rate) is also the important factor that affects the download speed ...

Oh, good, so much!

TCP/IP packet Structure specific explanation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.