TCP/Socket learning-UDP segment format

Source: Internet
Author: User
Tags ftp protocol

TCP/Socket learning-UDP segment format 16-bit source port number 16-bit destination port number 16-bit UDP Length 16-bit UDP test and the above eight bytes of data (if any) Case Analysis: next we will analyze a UDP-based TFTP protocol frame. Ethernet header 0000: 00 05 5d 67 d0 b1 00 05 5d 61 58 a8 08 00 IP header 0000: 45 000010: 00 53 93 25 00 00 80 11 25 ec c0 a8 00 37 c0 a80020: 00 01UDP header 0020: 05 d4 00 45 00 3f ac 40TFTP protocol 0020: 00 01 'C '': ''\ ''q'0030: 'w''e'' r''q ''. ''q'' w''e'00 'n' ''e'' 't''a' s ''c' 'I 0040: 'I '00' B' l ''k'' s ''I ''z'' e '00' 5 '1' 2 '00' t' I '2017: 'M' 'E' o 'U''t '00 '1' 1 '0' 00' t 's' I 'z' e '00' 0' 0060: 00 Ethernet header: source MAC address: 00: 05: 5d: 61: 58: a8, destination The MAC address is 00: 05: 5d: 67: d0: b1. The upper-layer protocol type 0x0800 indicates the IP address. IP header: each byte 0x45 contains four version numbers and four header lengths. The version number is 4, that is, IPv4, And the header length is 5. This indicates that the IP header does not contain an option field. The service type is 0 and no service is used. The total length of the 16-bit field (including the length of the IP header and the payload of the IP layer) is 0x0053, that is, 83 bytes. The length of the entire frame is 97 bytes in addition to the 14 bytes of the Ethernet header. The IP packet ID is 0x9325, the flag field and the part offset field are set to 0x0000, that is, DF = 0 allows the part, MF = 0, this datagram has no more parts, there is no sharding offset. TTL is 0x80, that is, 128. The upper-Layer Protocol 0x11 indicates the UDP protocol. The IP header checksum is 0x25ec, the source host IP address is c0 a8 00 37 (192.168.0.55), and the target host IP address is c0 a8 00 01 (192.168.0.1 ). UDP header: The Source Port Number 0x05d4 (1492) is the client port number, and the destination port number 0x0045 (69) is the well-known port number of the TFTP service. The UDP packet length is 0x003f, Which is 63 bytes, including the length of UDP header and UDP layer payload. The payload checksum of the UDP header and UDP layer is 0xac40. TFTP is a text-based protocol. fields are separated by byte 0. The header 00 01 indicates that a file is requested to be read. The following fields are: c: \ qwerq. qwenetasciiblksize 512 timeout 10 tsize 0 the general process of the network communication protocol is as follows: the general network communication is like the TFTP protocol, the two sides of the communication are the client and server, respectively, the client initiates a request (in the preceding example, the request frame initiated by the client), while the server passively waits, receives, and responds to the request. The IP address and port number of the client uniquely identify the TFTP client process on the host. The IP address and port number of the server uniquely identify the TFTP service process on the host, because the client is the party that initiates the request, it must know the IP address of the server and the port number of the TFTP service process. Therefore, some common network protocols have the default server port, for example, the HTTP service defaults to port 80 of the TCP protocol, the FTP service defaults to port 21 of the TCP protocol, and the TFTP service defaults to port 69 of the UDP protocol (as shown in the example above ). When using a client program, you must specify the host name or IP address of the server. If you do not specify the port number explicitly, the default port is used. Read the man page of ftp, tftp, and other programs to learn how to specify the port number. The Protocol corresponding to the port is the address in the Local Machine:/etc/services lists all well-known service ports and the corresponding transport layer protocol, which is composed of IANA (Internet Assigned Numbers Authority) some services can use both TCP and UDP. For clarity, IANA stipulates that such services use the same TCP or UDP default port number, in addition, the same port numbers of TCP and UDP correspond to different services. As mentioned above, the UDP protocol is not connection-oriented and does not guarantee the reliability of transmission. For example: the UDP protocol layer of the sending end only encapsulates the data transmitted from the application layer into segments and passes the data to the IP protocol layer to complete the task. If the data cannot be sent to the other party due to network faults, the UDP protocol layer does not return any error information to the application layer. For the acceptor, The UDP protocol layer of the acceptor only delivers the received data to the corresponding application based on the port number, even if the task is completed, if the sender sends multiple data packets and goes through different routes on the network, the order at the receiver is disordered, the UDP protocol layer does not guarantee that packet loss is sent to the application layer in the order of sending: generally, the UDP protocol layer of the acceptor places the received data in a fixed buffer and waits for the application to extract and process the data. If the application extracts and processes the data slowly, however, when the sender sends data packets quickly, the UDP protocol layer does not report such errors. Therefore, UDP-enabled applications must consider these potential problems and implement appropriate solutions, such as waiting for response, re-sending timeout, data packet numbers, and traffic control. Generally, the application implementation using UDP protocol is relatively simple, but it only sends messages that do not have high reliability requirements, rather than sending a large amount of data. For example, the UDP-based TFTP protocol is generally only used to transmit small files (so it is called trivial ftp), and the TCP-based FTP protocol is suitable for transmission of various files.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.