Sk_buff-> iPhone Dr
/Usr/src/linux-2.6.19/include/Linux/IP. h
StructIPhone Dr{
# If defined (_ little_endian_bitfield)
_ U8 IHL: 4,
Version: 4;
# Elif defined (_ big_endian_bitfield)
_ U8 version: 4,
IHL: 4;
# Else
# Error "Please fix <ASM/byteorder. h>"
# Endif
_ U8 TOS;
_ Be16-tot_len;
_ Be16-ID;
_ Be16-frag_off;
_ U8 TTL;
_ U8 protocol;
_ Be16-check;
_ Be32-saddr;
_ Be32-daddr;
};
31 0
| ---- | ------ | -- | ------------------- | ----------
| Ver | IHL |-tos |-| tot_len |
| ---- | ------ | -- | ------------------- |
| ID | frag_off-|
| --------- | ------------------- |
| TTL | Protocol | check | 20 bytes
| --------- | ------------------- |
| Saddr |
| --------------------------------------- |
| Daddr |
| --------------------------------------- | ----------
|
-| Options | 40 bytes
|
| --------------------------------------- |
IPv4 (internel protocol) Header
IPhone dr-> Version
Version (4 bits). The current Protocol version is 4, so the IP address is also called IPv4.
IPhone dr-> IHL
Header Length (4 digits ):The Header Length refers to the number of 32-bit characters in the IP layer header (that is, the number of 4 bytes in the IP layer header-32 bits), Including any options. Because it is a 4-bit field, the header is up to 60 bytes. The value of the common IP datagram (no choice) field is 5 <=>
5*32/8 = 5*4 = 20 bytes
IPhone dr-> TOS
Service type field (8 bits): the service type field (ToS) includes a 3-bit priority subfield (ignored now ), the 4-bit TOS subfield and the 1-bit unused bit must be set to 0. The 4-bit TOS sub-fields represent the minimum latency, maximum throughput, maximum reliability, and maximum throughput.
Small cost. Only 1 bit can be set in 4 bits. If all 4 bits are 0, it means a General Service.
Iphdr-> tot_len
The total length field (16 bits) refers to the length of the entire IP datagram, in bytes. By using the header length field and the total length field, you can know the start position and length of the data content in the IP datagram. Because this field is 16 bits in length, the maximum IP datagram length is 65535 bytes.
The total length field is necessary in the IP header, because some data links (such as Ethernet) need to fill in some data to reach the minimum length. Although the minimum frame length of Ethernet is 46 bytes, the IP data may be shorter. If there is no total length field, the IP layer does not know how many of the 46 bytes are IP datagram content.
IPhone dr-> ID
The ID field (16 bits) uniquely identifies each datagram sent by the host. Generally, the value of each sent packet is increased by 1.
IPhone dr-> frag_off (16 bits)
The 13-bit lower part of the frag_off field-the Fragment offset field specifies the position of the segment in the current datagram. Except for the last segment of a datagram, allThe segment must be a multiple of 8 bytes.. This is an 8-byte basic unit of segmentation. Because this field has 13 digits, each datagram has a maximum of 8192 segments. Therefore, the maximum datagram length is 65,536 bytes, which is 1 larger than that of the iphdr-> tot_len domain.
The height of the iPhone dr-> frag_off is 3 bits.
(1) Bit 0 is reserved and must be 0;
(2) bit 1 indicates "more shards" (MF -- More Fragment. Except for the last piece, the bit must be set to 1 for each piece of data.
(3) Bit 2 indicates "not sharding" (DF -- Don't fragment). If this bit is set to 1, the IP address will not partition the datagram, if a part-based datagram arrives, the datagram is discarded and an ICMP error message is sent to the start end.
| --- | ------------- |
| Dm0 | offset |
| --- | ------------- |
15 1312 0
Iphdr-> TTL
TTL (time-to-live) -- 8-bit. The TTL field sets the maximum number of routers that can pass through the datagram. It specifies the survival time of the datagram. The initial value of TTL is set by the source host (usually 32 or 64). Once a router processes it, its value is equal to 1. When the value of this field is 0, the datagram is discarded and an ICMP message is sent to the source host.
The TTL (time to live) domain is a counter used to limit the lifetime of a group. The count time is measured in seconds, so the maximum lifetime is 255 seconds. In each hop, the counter must be decreased. In addition, when the datagram queue time on a vro is long, the counter must be decreased multiple times. In practice, it is only a hop counter. When it decreases to 0, the group is discarded, and the router sends a warning group to the source host. This feature prevents the datagram from staying in the network for a long time. Sometimes, when the route table is damaged, this kind of thing may happen.
Iphdr-> Protocol
Protocol field (8 bits): identifies which Protocol transmits data to an IP address.
After the network layer assembles a complete datagram, it needs to know how to process it. The protocol field specifies the transfer process to which it is handed over. TCP is a possibility, but UDP or other protocols are also possible.
IPhone dr-> check
The header check field (16 bits) is the verification code calculated based on the IP header. It does not calculate the data after the header. ICMP, IGMP, UDP, and TCP contain both header and data verification code in their respective headers.
In order to calculate the IP address check of a datagram, the test field is set to 0. Then, calculate the binary inverse sum of each 16 bit in the header (the whole header is regarded as composed of a string of 16 bit characters), and the result is included in the test field. After receiving an IP datagram, the system also sums each 16 bit in the header with a binary inverse code. Because the receiver contains a checksum in the sender's header during the computation process, if the header has no errors during transmission, the receiver's computation result should be 1 in total. If the result is not all 1 (namely, check and error), the IP address discards the received datagram. However, no error messages are generated. The upper layer discovers the lost data packets and re-transmits them.
IPhone dr-> saddr
32-bit source IP address
Iphdr-> daddr
32-bit destination IP address
Network byte order
The 32-bit values of four bytes are transmitted in the following order: the first is 0 ~ 7 bit, followed by 8 ~ 15bit, then 16 ~ 23bit, last 24 ~ 31 bit. This transmission order is called the Big endian byte order. Because all the binary integers in the TCP/IP Header must be transmitted in this order, it is also called the network byte order.