What is IP or Internet Protocol?

The Internet Protocol (Internet Protocol) is a general term for a protocol cluster, which is not any protocol itself. There are generally file transfer protocols, e-mail protocols, hypertext transfer protocols, and communication protocols.

Internet Protocol

The Internet Protocol (Internet Protocol) is a general term for a protocol cluster, which is not any protocol itself. There are generally file transfer protocols,
File transfer protocol
Internet header format
The header format is as follows:
Version: 4 digits
This field indicates the format of the header. Let's take IP version 4 as an example.
IHL: 4 digits
The length of the Internet header is a header length marked in 32-bit units. It points to the beginning of the data.
Service type: 8-bit
It is a number of parameters indicating the quality of service, these parameters are used to indicate the required service in a particular network. Some networks provide priority services. The basic principle of selection is a trade-off between the following three: low latency, high reliability, and high throughput.
0-2 priority
3 0 = Normal delay 1 = Low delay
4 0 = normal throughput 1 = high throughput
5 0 = Normal reliability 1 = High reliability
6-7 Reserved
The priority is explained as follows:
111-Network Control
110-Internetwork Control
101-CRITICECP
100-Flash Override
011-Flash
010-Immediate
001-Priority
000-Routine
If latency (D) is used, throughput (T) and reliability (R) options can increase quality of service. This varies from network to network and is not universal. Except for very special cases, setting up to two parameters is sufficient. The service type is used to indicate how to treat datagrams transmitted in the network. Network control priority was originally used in one network, but in practice it is applied to each network. Interconnection control is used for gateway control. If these parameters are implemented in only one network, that network must control access to them within its own scope.
Total length: 16 bits
The total length refers to the length of the datagram, measured in bytes, including the data and header. The allowed datagram size is 64K. Such a large datagram is not suitable for most hosts and networks. However, all hosts must be able to receive datagrams larger than 576 bytes, whether they come together or in fragments. If you know that the host can receive datagrams larger than 576 bytes, it is best not to send datagrams smaller than 576 bytes when sending. 576 was chosen because 576 = 512 (data) +64 (header). The maximum length of the header is 60 bytes, which is usually 20 bytes.
Identification: 16-bit
Tags are sent to help reassemble fragments.
Mark: 3 digits
0 Reserved, must be 0
1 (DF) 0 = segmentable, 1 = not segmentable
Bit 2 (MF) 0 = last segment, 1 = more segments
0
1
2
0
D
F
M
F
Segment offset: 13 bits
This field indicates where the segment should be in the datagram. It is calculated in 64-bit units and the offset of the first segment is zero.
Lifetime: 8 digits
This field indicates the maximum time that a datagram can survive in the Internet system. If the value of this field is zero, the datagram is discarded. This field is processed at the same time as the header. Time is measured in seconds, but each processing unit decrements the TTL by at least one, even if the time is less than one second.
Protocol: 8-bit
This field indicates the next layer protocol used for the data portion of the datagram.
Head check code: 16 bits
The check code is only in the header, so the header field will change during processing, so the header will change frequently. This verification method is relatively easy to calculate, and experiments have proven that it is also applicable, but it may be replaced by the CRC verification process in the future.
Source address and destination address: 32 bits, please see below for details.
Options: variable length
There may or may not be options in the datagram, but the IP module must have the option to process the options. In some cases, a security option is required. Its length is indeterminate, it can be none or more. Options have two formats:
1 single option type byte
2 an option type byte, an option length byte and the actual option data byte
The option length is the option type, the length itself, and the length of the data. Option types can be viewed as having three fields:
1 digit copy mark
2-bit option class
5-digit option number
The copy flag indicates that this option is to be present in all segments in the segment.
0 = do not copy
1 = copy
The option classes are:
0 = control
1 = reserved
2 = scheduling and measurement
3 = reserved
Here are the specific options:
CLASS
NUMBER
LENGTH
DESCRIPTION
0
0
-
The list of options ends. Only one byte, no length byte
0
1
-
No action. Only one byte, no length byte
0
2
11
Security, used to transmit security, comparison, processing group restriction code for user group (TCC) and DOD rules
0
3
lengthen
Loose source address routing, using the information provided by the source address for routing
0
9
lengthen
Tight source address routing, using the information provided by the source address for routing
0
7
lengthen
Record route to track the route taken by the datagram
0
8
4
Stream ID, used to carry the stream tag
2
4
lengthen
Internet timestamp
Specific option definition
Options table ends
+ -------- +
00000000
+ -------- +
Type = 0
This option indicates the end of the option table. It is not necessarily the same as the end point of the header. It is used to indicate the end of the option table instead of the end of each option. It can be copied, introduced or deleted while segmenting.
No operation
+ -------- +
00000001
+ -------- +
Type = 1
This option can be used between options, it can be copied, introduced or deleted during segmentation.
Safety
This option provides the host with a way to send security, apartmentation, handle restrictions and TCC parameters. The format of this option is:
Type = 130 Length = 11
Security (S domain): 16 bits
Safety is divided into 16 levels and 8 levels are reserved.
00000000 00000000-Uncategorized
11110001 00110101-Confidential
01111000 10011010-EFTO
10111100 01001101-MMMM
01011110 00100110-PROG
10101111 00010011-restricted
11010111 10001000-Secret
01101011 11000101-absolutely confidential
00110101 11100010-Reserved
10011010 11110001-Reserved
01001101 01111000-Reserved
00100100 10111101-Reserved
00010011 01011110-Reserved
10001001 10101111-Reserved
11000100 11010110-Reserved
11100010 01101011-reserved
Compartments (C field): 16 bits
All zeros indicate that the information transmitted is non-compartmental.
Processing limit (H field): 16 bits
The control value and version mark are composed of letters and numbers, please refer to other materials for details.
Transmission control code (TCC domain): 24 bits
Provides methods for controlling traffic. The TCC value is a three-letter word and is described in HQ DCA Code 530. It must be copied during segmentation.
Song source address and record routing
+ -------- + -------- + -------- + ----------------- +
10000011 length pointer route data
+ -------- + -------- + -------- + ----------------- +
Type = 131
Loose source address and record routing (LSRR) can provide routing information and record routing information from the source address. This option starts with the option type code. The second bit is the option length, and the third bit is a pointer to the next source address in the routing data to be processed. Its minimum value is 4. The routing data is composed of a series of addresses, each address is 32 bits. If the pointer is greater than the length, the source route is empty (the recorded route is full), and the route is performed according to the destination address field.
If the destination address has been reached and the pointer is not greater than the length, the next address in the source route replaces the address in the destination address field, while the recorded route address replaces the used source address, and the pointer is increased by 4. This process of replacing source routing with recorded routing means that the option (with the IP header as a whole) datagram is processed in the network to maintain a fixed length. It is called loose source address routing because the gateway or host IP can use multiple intermediate gateways when it reaches the next address of the route. It must be copied when segmenting.
Tight source address and record routing
+ -------- + -------- + -------- + ----------------- +
10001001 length pointer route data
+ -------- + -------- + -------- + ----------------- +
Type = 137
The tight source address and record routing (SSRR) option can provide routing information and record routing information from the source address. This option starts with the option type code. The second bit is the option length, and the third bit is a pointer to the next source address in the routing data to be processed. Its minimum value is 4. The routing data is composed of a series of addresses, each address is 32 bits. If the pointer is greater than the length, the source route is empty (the recorded route is full), and the route is performed according to the destination address field.
If the destination address has been reached and the pointer is not greater than the length, the next address in the source route replaces the address in the destination address field, while the recorded route address replaces the used source address, and the pointer is increased by 4. This process of replacing source routing with recorded routing means that the option (with the IP header as a whole) datagram is processed in the network to maintain a fixed length. It is called tight source address routing because the gateway or host IP cannot use an intermediate gateway when it reaches the next address of the route. It must be copied when segmenting.
Record routing
+ -------- + -------- + -------- + ----------------- +
00000111 length pointer route data
+ -------- + -------- + -------- + ----------------- +
Type = 7
This option provides a method for recording datagram routes. This option starts with the option type code. The second bit is the option length, and the third bit is a pointer to the next source address in the routing data to be processed. Its minimum value is 4. The recorded route is composed of a series of IP addresses, each IP address is 32 bits. If the pointer is greater than the length, the record routing data field is full. The source host must allocate enough space for this option. After the space is allocated, it will not increase due to adding addresses. The initial content must be 0.
When the IP module processes the datagram, it checks if there is a record routing option, and if it does, it places its own IP address in the record routing address space, adding 4 to the pointer value. If the address space is full, the module will not add its own IP address; if the space is not full, but the entire address is not enough, the module will consider the source datagram as an error and discard it. In the above two cases, ICMP parameter information messages are sent to the source host. It is not copied during segmentation, but only exists in the first segment.
Stream tag
10001000
00000010
Stream ID
Type = 136 Length = 4
This option provides a method for transmitting 16-bit SATNET stream tags in networks that do not support streaming. Must be copied when segmenting.
Internet timestamp
01000100
length
pointer
oflw tag
IP address
Timestamp
...
Type = 68
The option length is the type, length, pointer, and size of the overflow token bytes within the option. The pointer is the number of bytes from the beginning of the option to the end of the timestamp plus one. The minimum value is 5. The timestamp field is full when the pointer is greater than the length. Overflow (oflw) (4 bits in size) is the IP module number. This module cannot register a timestamp due to the default space. Its values are:
0-only timestamp, stored in consecutive 32-bit words;
1-the IP address of the registration unit before each timestamp;
3-The IP address field is specified in advance. If the address of the IP module is the same as the next specified IP address, register its own time stamp.
The timestamp is calculated in milliseconds from the UT midnight time. If the time is not calculated in milliseconds or cannot be based on the UT midnight, then any time can be used, as long as the highest bit of the timestamp is set to 1, indicating that this A standard value will do. The source host must allocate enough space for this option. After the space is allocated, it will not increase due to adding addresses. The initial value must be an even pair such as zero or IP address zero. If the space is full, the module does not add a timestamp when transmitting the datagram, but the overflow count is still incremented by one.
If the remaining space does not allow a complete timestamp to be added, or the overflow count overflows, the source datagram is incorrect and discarded. ICMP parameter information messages are sent to the source host. This option is not copied during segmentation, only appears in the first segment.
Fill: variable length
The header field padding is used to ensure that the header is a multiple of 32 bits. The padding value is 0.
discuss
The implementation of the protocol must be robust, and each implementation must be compatible with other implementations. Usually an implementation should follow a more conservative strategy when sending, but it need not be conservative when receiving. In other words, send a well-formed packet and receive a packet that you can explain (some errors will be resolved).
The basic Interent service is datagram-oriented. The gateway can provide datagram segmentation and reassembly services at the destination host. Of course, it is also possible to segment and reorganize within a network or between gateways of a network due to compliance with private protocols, because this is transparent to IP protocols and higher-level protocols. This transparent segmentation is called network-based segmentation and will not be discussed here. IP addresses distinguish source and destination addresses at the host level.
Addressing
In order to allow flexible control over the size of the network, IP addresses provide several types of addresses. One is a network that can accommodate more hosts. Class addresses, Class C addresses are proposed for use in networks of different sizes. Here are some address formats:
Highest position
format
class
0
7-bit network, 24-bit host
a
10
14-bit network, 16-bit host
b
110
21-bit network, 8-bit host
c
111
Extended address mode
If the network domain is zero, it means this network. This method is only used in specific ICMP messages; the extended address model is undefined.
The local address specified by the local network must take into account that a single host can be used as a different network host. In other words, a mapping must be made between the network host address and the network host interface. This interface allows several IP addresses to correspond to one interface. At the same time, it should be considered that a host has multiple processing interfaces, and the information received from different receivers should be regarded as coming from the same IP address.
Segmentation and reorganization
The Internet tag domain (ID), source address, destination address, and protocol domain are used together to confirm datagram fragmentation and reassembly. If the datagram is not the last segment, a multi-segment flag (MF) is set. The segment offset field marks the segment position relative to the datagram when it is not fragmented. Segments are in 8-byte units. Such a segmentation strategy enables non-fragmented datagrams to have all-zero segmentation information (MF = 0, segment offset = 0). If segmentation is performed, the boundary must be a multiple of 8 bytes. This format allows 2 to the 13th power (8192) 8-byte segments. The maximum length of a datagram is exactly the same as the data indicated by the length field of 64K. During segmentation, some options are copied and some are not.
Each IP block must be able to transfer 68-byte datagrams without fragmentation. This is because the IP packet header will reach 60 bytes, and the minimum data segment length is 8, 68 = 60 + 8; and it must be able to receive 576 bytes of data, regardless of whether the data is unfragmented or fragmented.
Domains affected by segmentation include:
Option field
Multi-segment marker
Segment offset
Internet header length field
Total length field
Baotou check code
If the non-fragmentation flag (DF) is set, fragmentation is not possible, even if the datagram is discarded as a result. This bit needs to be set if the receiving host cannot perform reassembly. When we do diskless boot, we need to set this bit. The following example illustrates this process. Where # is not equal, X to Y refers to all data including X, but not Y.
The largest datagram that can be transmitted on the next network is called the maximum transmission unit (MTU). If the length of the datagram is less than or equal to MTU, proceed to the next step; otherwise, it is divided into two segments. The size of the first segment is equal to MTU, and the second segment is the remaining length. The first segment is transmitted. If the second segment is still larger than MTU, then Repeat the segmentation process until it can be sent. Below we give a definition:
FO-Segment Offset
IHL-Internet header length
DF-No Segment Marker
MF-Multi-Segment Marker
TL-total length
OFO-original offset
OIHL-Original Internet header length
OMF-Original Multi-Segment Marker
OTL-original total length
NFB-Number of segments
MTU-Maximum Transmission Unit
process:
IF TL = MTU THEN submit this datagram to the next processing stage
ELSE IF DF = 1 THEN
ELSE produces the first paragraph:
Copy source internet header;
OIHL-IHL; OTL-TL; OFO-FO; OMF-MF;
NFB-(MTU-IHL4) 8;
Append the first NFB8 data bytes;
Correct the header: MF-1; TL-(IHL4) + (NFB8); recalculate the check code;
(I) Submit data segments to the next datagram processing stage;
If you want to produce a second segment:
Copy the internet headers selectively;
(I) Additional residual data;
Correct the header: IHL-(((OIHL4)-(Unreplicated option length)) + 3) 4;
TL-OTL-NFB8-(OIHL-IHL) 4);
FO-OFO + NFB; MF-OMF; recalculate the check code;
Submit this paragraph to segment detection; end.
Except for the last section in the above example, all other sections have reached the MTU size. Various implementations are different, as long as the available sections are less than or equal to the MTU.
Reorganization process example
For each datagram, the buffer tag is identified by the source address, destination address, protocol, and tag fields. If the datagram is not fragmented, then no reorganization is required, and processing proceeds to the next stage. The data structures required for reorganization are: data buffer, packet header buffer, segment block bit table, data length field, and counter. The data in the segment is placed in the corresponding position according to the segment offset and length, and the corresponding bit in the segment block standard table is set according to the received segment block.
If it is the first segment (segment offset is 0), put the header in the header buffer; if it is the last segment (multi-segment mark is 0), calculate the total data length. If the entire datagram is received, proceed to the next processing stage; if it is not received, set the counter value to the current counter and the survival time saved in this segment, and the reorganization function gives up control. If timeout all buffers are released. The initial value of the counter is the lower limit of the reassembly wait time. Because if the survival time in the arrival segment is greater than the counter's current value, the waiting time increases, and if it is less then it does not decrease. The maximum time of the counter can reach the maximum survival time (about 4.25 points). It may be better to set it to 15 seconds, of course, this value may change with practice. The selection of this value is related to the size of the buffer and the transmission medium. The transmission speed multiplied by the counter value is equal to the buffer size.
definition:
FO-Segment Offset
IHL-Internet header length
MF-Multi-Segment Marker
TTL-time to live
NFB-number of segments
TL-total length
TDL-total data length
BUFID-buffer tag
RCVBT-Segment Receive Bit Table
TLB-Low Counter
process:
If some or all of the data in the arriving data segment is the same, the above process will use the latest version of the data.
mark
Tagging is to provide unique tagging for a particular datagram segment. If the datagrams have the same source address, destination address, protocol, and tag, the IP module will identify them as the same datagram. Anything selected is the responsibility of the sender. The sending protocol module needs to maintain a tag table, and each destination address maintains an entry. However, because the tag field allows 65536 different values, some hosts can still achieve the unique purpose of tagging regardless of the destination. Higher-level protocols can also use tags.
Service type
The type of service (TOS) is the choice of network service quality. The service type is a combination of priority, latency, throughput, and reliability determined by abstract parameters. These parameters correspond to some actual corresponding network services. For the definition of what is delay and what is throughput, I won't say much here.
Time to live
The lifetime is set by the sender and is the longest lifetime of the datagram in the network. If it times out, the datagram will be discarded. Each node in the network processes the time to live in the header. The minimum reduction in this field is 1 in seconds. Therefore, the longest survival time is 255 seconds. Each processing module must decrement the TTL by one, even if the elapsed time is less than one second. The high-level reliable connection protocol is based on the fact that the original duplicate datagram will not arrive after a certain time, and TTL exists to satisfy this assumption.
Option
Datagrams in the options are optional, but must be present in the implementation. It is the sender who decides whether there are any options. Each IP module must be able to analyze each option. Each option field has multiple options. Options may not reach the 32-bit boundary, and insufficient ones are padded with zeros to achieve multiples of 32-bits.
Check code
If the header changes, the header check code must be recalculated. The check code can prevent transmission errors to a certain extent. Some applications allow errors in datagrams. If IP emphasizes data correctness, similar applications will not work.
error
IP protocol errors can be reported by the ICMP protocol.
interface
The description of the interface is functional, and the specific implementation mechanism of this description will vary depending on the operating system. Different IP implementations will have different user interfaces. But at least a subset is required for all implementations. This section describes this basic subset. The IP protocol has two interfaces, one is for the local network, and the other is for higher-level protocols or applications. We call the latter interface the user. Although the IP protocol is a datagram protocol, there are very few resources (memory) for saving state.
The following is an example of a high-level interface:
SEND (src, dst, prot, TOS, TTL, BufPTR, len, Id, DF, opt = result)
In the above formula:
src = source address
dst = destination address
prot = protocol
TOS = service type
TTL = time to live
BufPTR = buffer pointer
len = buffer length
Id = mark
DF = not segmented
opt = option data
result = response, the response is divided into OK and Error;
OK = Sent successfully
Error = Parameter error or local network error
Priority and security parameters are passed in options.
RECV (BufPTR, prot, = result, src, dst, TOS, len, opt)
In the above formula:
BufPTR = buffer pointer
prot = protocol
result = response, the response is divided into OK and Error;
OK = Sent successfully
Error = parameter error
len = buffer length
src = source address
dst = destination address
TOS = service type
opt = option data
When the user sends a datagram, he executes the SEND command. When the IP module receives the call, it checks the transmitted parameters and prepares to send data. If the parameters are valid and the local network receives data normally, the return is successful. If the parameters are invalid or the local network does not receive data, the return is unsuccessful. Reports are returned when unsuccessful, and the content of the report varies depending on the implementation.
When the datagram arrives at the IP module, there is either a RECV call or no. If there is this call, it will send the message to the user; if not, it will notify the user that the message has arrived. If no user should be found, an ICMP error is returned and the data is discarded. The user can be notified by a false interrupt or similar mechanism, which depends on the operating system. The source address is included in the send call, and the IP module can check whether the source address is a valid address.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?