08- The UDP transport layer protocol

A: UDP works

User Datagram Protocol (User Datagram Protocol, UDP) is a transport layer protocol. In TCP / IP networks, the TCP protocol as that for processing the data packet, a connectionless protocol

When TCP protocol during data transmission, the need to establish a connection, and the data required for each transmission acknowledgment. When no transmission data, but also you need to disconnect. Although the security to do so, but less efficient. UDP, however, precisely to avoid these processes, it is a complex control not to provide communication services connectionless protocol.

UDP protocol has the following features:

  • No various connections: connection need not be established before the data transmission, but also to avoid subsequent disconnection.
  • Not reorder: for out of sequence packets arrive not reorder.
  • No confirmation: send data packets without waiting for the other to confirm. Therefore, the use of UDP protocol can send data at any time, but can not guarantee the success of the data is received target host

Two: UDP packet format

Each UDP packet into two parts UDP header and UDP data area. Header of four 16-bit length (2 bytes) fields, respectively illustrate the packet source port, destination port, packet length, and check value

UDP packet format shown in FIG.

 

 UDP packet meaning of each field is as follows

Source port : This field occupies 16 bits UDP packet header, typically comprising transmission data packets UDP port used by the application. Receiving end application uses this value as a destination address field of the response is sent. This field is optional, the transmitting side application will necessarily own port number written in the field. If you do not write the port number, put this field is set to 0. Thus, the receiving application can not send a response

Destination port : the port on the receiving end computer software UDP, occupies 16 bits.

Length : This field occupies 16 bits, indicates the length of the UDP datagram, comprising a UDP header and UDP data length. Because UDP header is 8 bytes in length, so the minimum value is 8.

Check value : This field occupies 16 bits can be checked whether the data is corrupted during transmission

Three: Analysis of UDP packets

After the client establishes communication connection with the server, in addition to using the TCP protocol, the UDP protocol may be used. netwox tool provides related modules for establishing and UDP server UDP client realize the data exchange protocol based on UDP.

[Example] A known hosts IP address 192.168.59.132, IP address of the host B is 192.168.59.135. It was established on both the host server and UDP client and connect, listening for traffic on the specified port. Specific steps are as follows:

1) establish a UDP server on the host A, set listening port 80, run the following command:

root@daxueba:~# netwox 90 -P 80

After executing the command, no output information, but successfully established UDP server.

2) based on the client host B UDP, UDP server port 80 are connected, run the following command:

root@daxueba:~# netwox 88 -i 192.168.59.135 -p 80

After Run no output, but the UDP is successfully connected to the server, the communication content can be entered here.

3) to communicate with the UDP server, the client inputs hi:

root@daxueba:~# netwox 88 -i 192.168.59.135 -p 80
hi

4) the server can see that the client sent the following message:

root@daxueba:~#  netwox 90 -P 80
hi

5) To verify message transmitted using the UDP protocol, can be viewed through the capture, as shown in FIG.

 

 A first data packet may be seen from the figure, the UDP client (source IP address of 192.168.59.132) to the UDP server (the destination IP address of 192.168.59.135) UDP data packets sent to the source port using random 47203 port, destination port 80 (UDP port monitored by the server).

Shows the details of UDP packets in User Datagram Protocol section. Can see the source port, destination port, and the packet length is 11 bytes, parity and other information is 0xf878.

6) When the server sends a message to the client, the UDP protocol is used. For example, the server replies to the client, enter hello:

root@daxueba:~# netwox 90 -P 80
hi
hello

7) capture verification by using the UDP protocol, shown in FIG.

 

 14 can be seen from the data packet, the source IP address is 192.168.59.135, 192.168.59.132 destination IP address, source port is 80, the destination port is a random port 47203. The UDP packet is just the server replies to the client's UDP packet. In the User Datagram Protocol section can see details

Guess you like

Origin www.cnblogs.com/nealfeng/p/12605876.html