Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Linux Network Programming --TCP and UDP datagram type Explanation     - Spring Data MongoDB combat (Database)

- Installation of network monitoring ntopng under CentOS 6.4 (Linux)

- Use py2exe to generate exe files Python script (Programming)

- Debian 7 and Debian 8 users how to install Oracle Java 8 (Linux)

- How to use SHA256 checksum files download (Linux)

- Installation JDK 1.8 under CentOS7 (Linux)

- Hibernate Search and Lucene quick introduction (Linux)

- You must ask yourself four questions before deploying Docker (Server)

- OpenDaylight Helium version installed (Linux)

- To achieve a two-way static NAT stateless available modules on Linux (Linux)

- Scope of variables in Object-C (Programming)

- OpenGL Superb Learning Notes - New Patterns (Programming)

- PostgreSQL Select source code analysis (Database)

- Security Features Linux and Unix operating system, programming (Linux)

- Apache POI Excel Document Processing (Linux)

- Advanced Search Oracle study notes (Database)

- CentOS 6.6 install JDK7 (Linux)

- Boost-- time and date - (1) timer library introduction (Programming)

- Using Vagrant create cross-platform development environment (Linux)

- Clojure programming languages: take full advantage of the Clojure plug-in Eclipse (Programming)

 
         
  Linux Network Programming --TCP and UDP datagram type Explanation
     
  Add Date : 2018-11-21      
         
         
         
  TCP (Transmission Control Protocol Transmission Control Protocol) is a connection-oriented, reliable, based on the transport layer protocol byte stream.

TCP segment header has 10 required fields and one optional field. Header is at least 20 bytes. Header subsequent data is optional.

1) Source port (16)

Identification of the sending computer port or process packets. A TCP segment must include the source port number, so that the destination host should know where to send the confirmation message.

2) destination port (16)

Receiving an identification of the destination host port of a packet or process.

3) number (also called the serial number) (32)

For identifying each segment, so that the destination host to acknowledge receipt of data packets designated segment. When the source host for multiple segment sends a packet, even if the order of these packets to the destination host is not the same, the serial number is also possible to order them according to the destination host.

When SYN flag is not set, the field indicates the user data area in the first byte of the serial number; when the SYN flag is set, this field indicates the serial number of initial transmission.

The first segment at the time of establishing a connection to send, both to provide an initial sequence number. TCP standard recommended to 4ms interval increments a counter value of 1 as the initial value of the serial number. Using the counter to prevent the same serial number appears when the connection is closed and re-connection.

For segments that contain data, the number of segments in the first data byte is the initial sequence number, followed by data bytes are numbered sequentially. If the source host uses the same connection to send another segment, then the segment sequence number is equal to the previous segment sequence number to the previous segment of the number of data bytes and. For example, assume that the source host to send three segments, each segment has 100 bytes of data, and the first segment of the serial number is 1000, then the second segment of the serial number is 1100 ( 1000 + 100), and the third segment is the sequence number 1200 (1100 + 100).

If the serial number is increased to a maximum value will be reset to zero.

4) confirmation number (32)

The destination host will return confirmation number, so that the source host knows one or several segments have been received. If the ACK control bit is set to 1, then the field is valid. Serial number is equal to the value of the order is received to confirm the last segment of the serial number plus 1, which is the hope that the next destination host received message segment. After the return confirmation number, the computer thinks it has received the acknowledgment number less than all of the data.

For example, the sequence number equal to the number of the previous segment sequence number to the previous segment and the data bytes. For example, assume that the source host to send three segments, each segment has 100 bytes of data, and the first segment of the serial number is 1000, then after receiving the first segment, the destination host Back acknowledgment number 1100 containing the header. Receive the second segment (with serial number 1100), the destination host returns confirmation number 1200. Upon receipt of the third segment, the destination host returns confirmation number 1300.

Not necessarily the destination host after each received message segment return confirmation number. In the example above, the destination host may wait until all three segments are received, and then returns a confirmation number containing segment 1300, showing it has received all of 1200 bytes of data. But before then, if the destination host sends back a confirmation number you wait too long, the panel will consider the data source does not reach the destination host, and automatically re-issued.

The above example, the first segment 1000. If the destination host receives the segment number and a segment number is the last segment of 1200, it can return a confirmation number 1100, but then return confirmation number 1300 before, we should wait for segment No. 1100 intermediate segment.

5) data offset (header length) (4)

Data at the start of the TCP packet segment how far that is from the TCP header length packets at the beginning of the segment. Since the length of the TCP header with different TCP options field content changes, so the header contains a field to specify header fields. The field of 32-bit units, so the header length must be an integer multiple of 32 bits, sometimes at the end of the header 0s. If there is no TCP header options field, the header length is 5, indicating a header of 160 bits, or 20 bytes.

6) Reserved bit (6)

6 with the offset field in the data after configuration, all 0s.

7) control bit (6)

Emergency URG: this bit, indicating urgent pointer field is valid, it tells the system has urgent data in this segment, to be transmitted as soon as possible.

Confirm ACK: ACK = 1 only when the confirmation number field is valid, TCP provides segment after the connection must all convey the ACK set.

Push PSH: When two application processes for interactive communication, sometimes at one end of the application process in hope immediately after typing a command will be able to receive any response. In this case, you can use TCP push (push) operation, then the sender of the TCP PSH set and immediately create a segment sent, the recipient receives PSH = segment 1, it as soon as possible (ie "push" forward) delivered to the receiving application process, rather than wait until after the delivery of the entire cache are filled up.

Reset RST: to reset the corresponding TCP connection

Synchronization SYN: In the three-way handshake to establish a TCP connection is valid only. When SYN = ACK = 0 and 1, indicating that this is a connection request segment, if the other party agrees to establish a connection, you should use the corresponding segment of the SYN = 1 and ACK = 1. Therefore, SYN is set to indicate a connection request or connection acceptance message.

Termination FIN: used to release a connection. When FIN = 1, it indicates that the data sender of this segment has been sent, and demanded the release of the transport connection.

8) Window (16)

This field is used for traffic control, this value is the number of bytes received at this unit expects that the send window size data. Tell each other without waiting for confirmation of how much data can be sent. The maximum length shown here is 2 ^ 16--1 = 65535, such as the need to use a larger window size, use the options window scale factor option.

It refers to a segment of the newspaper to send one of the receive window (rather than send its own window).

9) checksum (16)

Source and destination hosts checksum is calculated based on the content of TCP segments and pseudo-header. It holds the length of the information from the IP header and TCP segment in the pseudo header. Like the UDP pseudo header is not transmitted over the network, and is included in the checksum pseudo-header purpose it is to prevent the destination host received in error there is a routing error datagrams.

Pseudo-header, also known as pseudo-header (Pseudo Header): refers to the TCP segment or UDP datagram format, a data packet header added to the preceding source IP address, destination IP address, protocol field of the IP packet, TCP or the total length of the UDP datagram, a total of 12 bytes, consisting of extended header structure. This pseudo header is a temporary structure that is neither up nor down pass, just to ensure that you can verify the correctness of the socket.

10) Urgent Pointer (16)

URG = 1 only when meaningful, it indicates the number of (emergency data end is the common data) newspaper paper segment urgent data byte that indicates the end position of urgent data in the packet, pay attention: You can also send urgent data even when the window is zero.

If URG is 1, the urgent pointer marks the end of urgent data. The value is the last urgent data byte serial number, serial number indicates segment offset. For example, if the segment number is 1000, the first 8 bytes of data are urgent, less urgent pointer is 8. Urgent pointer general purpose is to enable the user to abort the process.

11) option, padding field

May include "window scale factor" "timestamp" and other options. Variable length, up to 40 bytes, when no options, TCP header length is 20 bytes.

Padding is used to ensure any option 32bit integer multiple.

12) Data (variable length)

Section after the end of the TCP header

UDP packet format

UDP is the User Datagram Protocol short, the Chinese name is the User Datagram Protocol is a connectionless transport layer protocol provides transaction-oriented messaging service simply unreliable.

1) the source port (2 bytes): port number of the sender

2) destination port (2 bytes): port number of the recipient

3) packet length (2 bytes): The total length of the UDP user datagram in bytes.

4) checksum (2 bytes): detecting UDP user datagram transmission is wrong, wrong is discarded.

For the digital section and check UDP datagram containing UDP datagram header "pseudo-header."

Pseudo-header, also known as pseudo-header (Pseudo Header): refers to the TCP segment or UDP datagram format, a data packet header added to the preceding source IP address, destination IP address, protocol field of the IP packet, TCP or the total length of the UDP datagram, a total of 12 bytes, consisting of extended header structure. This pseudo header is a temporary structure that is neither up nor down pass, just to ensure that you can verify the correctness of the socket.

5) Data: UDP data portion is not even required if filled with zeros, that is, if the data length is an odd number, data length plus "a."
     
         
         
         
  More:      
 
- How to deploy Python Web application: Heroku deployment process complete records (Server)
- How to install Bugzilla 4.4 on Ubuntu / CentOS 6.x (Linux)
- Oracle Client + PL SQL Developer enables remote access to the Oracle database (Database)
- Linux kernel RCU (Read Copy Update) lock Brief - prequel (Linux)
- Linux user directory (Linux)
- Firewall settings oracle remote connection in Linux systems (Linux)
- Error: Unable to establish connection with FTP SFTP server (Server)
- Use Spring cache and ehcache (Programming)
- Shell array: Define Shell array, the array length (Programming)
- Oracle bug Ora-04043 (Database)
- Linux kernel TCP / IP parameters analysis and tuning (Linux)
- LAMP environment to build Apache, MySQL, PHP under Ubuntu (Server)
- MySQL main and backup replication structures (using mysqld_multi) (Database)
- Netfilter / Iptables Comments (Linux)
- Search Linux commands and files - which, whereis, locate, find (Linux)
- JDK installation under CentOS (Linux)
- ctop: monitor container performance Linux command line artifact (Linux)
- Debian GNU / Linux service list acquisition, shutting down services or run (Linux)
- Go Languages Reviews (Programming)
- OS X CAOpenGLLayer how to enable OpenGL 3.2 core profile (Programming)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.