Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Analysis of IP Protocol and TCP Protocol

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

First, an overview of the TCP/IP protocol stack

The TCP/IP protocol stack was created by the U.S. Department of Defense (DoD) in the 1960s (earlier than the OSI model) and is a concrete implementation standard.

It is divided into four layers: network access layer (link layer), Internet layer (network layer), host to host layer (transport layer), and application layer.

Because there are many knowledge points involved in TCP/IP protocol stack, and the most important protocols are IP protocol and TCP protocol, this paper mainly analyzes IP and TCP protocols, and other knowledge points are added later.

Second, IP protocol

IP (Internet Protocol, Internet Protocol) is the most important protocol (located in the network layer) in the TCP/IP protocol stack, which is used to realize unreliable data-oriented connectionless communication, three-layer data encapsulation and IP addressing.

What is unreliable?

Unreliable means that it cannot guarantee that the IP packet will reach its destination 100%.

What is connectionless?

This means that I P does not maintain any status information about subsequent datagrams. Each Datagram is processed independently of each other. IP datagrams can be received out of the sending order. If a source sends two consecutive datagrams (first A, then B) to the same destination, each Datagram is routed independently and may choose a different route, so B may arrive before An arrives.

1.IP header format

(1) version

4bit, used to mark the version of the IP protocol. IPv4---- > 4 config. 6. Musi-6.

(2) head length

4bit, the maximum decimal that can be represented is 15. 0. Indicates the length of the IP header, indicating the end position of the IP header or the start position of the data

The receiver knows how to unpack according to the length of the header.

(3) Service type

ToS,8bit, which provides QoS quality of service technology for traffic marking

(4) Total length

The total length refers to the length of the sum of the header and the data, in bytes. Field 16bit.

(5) Identifier

16bit, which is used to mark the process of sharding

(6) Marker

3bit, the first bit 0: reserved or unused; the second bit DF: DF=1, indicating that the packet should not be segmented; and DF=0, indicating that the packet can be segmented as needed. The third bit MF bit: indicates that the segment is the last segment (bit 0) or followed by more segments (bit 1).

(7) slice offset

13bit, which is used to inform the receiver of the location of each shard from the IP header in order to reassemble in an orderly manner

(8) survival time

The maximum value of 8bit TTL is 255; mark the path and guard against ring.

(9) Agreement

8bit, marking the upper layer protocol

(10) head examination and

16bit, verifying the integrity of the packet

(11) Source IP address

32bit, the IP address of the sender

(12) destination IP address

32bit, the IP address of the recipient

(13) option

Options, variable length this field is optional

Common: record routing options, timestamp options, and routing options to enhance traceroute programs

(14) fill

Padding, variable length, if the IP header size is not an integer multiple of 32 bits, the header will be filled with 0 to 32 bits

(15) data

Variable length, which is data transmitted in an IP packet and identified by a protocol field

Third, TCP protocol

TCP (Transmission Control Protocol, Transmission Control Protocol) is the most important protocol (located in the transport layer) with the most algorithms and the most complex functions in the TCP/IP protocol stack.

Features provided by TCP

Connection-oriented (three handshakes, four waves)

Reliable transmission (timeout retransmission, fast retransmission)

Flow control (sliding window, congestion control)

Multiplexing (socket, Socket)

two。 Principle

2.1 connection-oriented (three-way handshake, four-wave)

Three-way handshake: (shown below)

Note: the three-way handshake is a session establishment process in which there is no formal delivery of data packets.

SYN (synchronization bit) is used to implement port request, and ACK (confirmation bit) is used to implement port reply.

Wave four times (see figure below):

Question: why close it four times instead of three times?

Because at the end of data transmission on one side, the other party may still be transmitting data, so it needs to be done four times.

2.2 reliable transmission

See the following figure:

Use Seq (serial number) and ACK (confirmation number) to ensure reliable transmission.

2.3 flow control

Use sliding window to achieve flow control

2.4 Multiplexing

Use socket socket to achieve multiplexing, socket=ip+port. For example, multiple clients need multiplexing if they want to connect to the same server.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report