Network Basics 2-3 --- UDP protocol at the transport layer: the characteristics of DP, the protocol format of UDP, the application of UDP

Table of contents

1. The tcpdump command

2. UDP protocol

foreword

2.1. Features of UDP protocol:

2.2, UDP protocol format

16-bit UDP length:

Combined with the packet capture tool: analyze the UDP protocol, and use the udp_socket programming we wrote before

16-bit checksum:

2.3. Application of UDP:


1. The tcpdump command

We can use the tcp-sock code we wrote before to capture packets and practice it

tcpdump universal formula:

tcpdum -i any port [port number] -s 0 -w 123.dat

-w means to put the data obtained by capturing the packet into the file 123.dat

Premise: When the tcpdump command is executed, the root user needs to be used

 At this time, we go to the browser to send a request to the server, and the requested data can be obtained on the 123.dat file

After we send the request, we close tcpdump, and we can find that 17 data packets have been obtained

 When we open the 123.dat file at this time, we will find that it is full of things we cannot understand, because all the captured things are binary

 At this time, we can use the wireshark tool to let him analyze it for us

We can see the analyzed content:

2. UDP protocol

foreword

The transport layer is responsible for the transmission between end-to-end, and the end refers to the port (port); both the TCP protocol and the UDP protocol are protocols of the transport layer

In the transport layer, the source port and destination port need to be agreed.

2.1. Features of UDP protocol:

        Connectionless, unreliable, datagram-oriented

2.2, UDP protocol format

16-bit UDP length :

                                         What is saved is the total length of UDP data (udp header part + data), the unit is byte;

Consider:   The maximum number that can be represented by 16 bits is 65536, that is to say, the maximum total length of udp is 15536 ​​bytes

A single piece of udp data will not exceed 65536 bytes, if it exceeds, what should I do?

Combined with the packet capture tool: analyze the UDP protocol, and use the udp_socket programming we wrote before

Open wire shark to analyze the data we captured

 We can open one of the UDP messages for analysis:

 Compared with the format of the UDP protocol, we can better understand the content sent:

16-bit checksum:

In order to verify whether the data is distorted during transmission,

The sender will mark the checksum, and the receiver will pass the checksum verification

2.3. Application of UDP:

   

Supongo que te gusta

Origin blog.csdn.net/flyingcloud6/article/details/128835584
Recomendado
Clasificación