TCP/IP Detailed learning Note--UDP protocol

Source: Internet
Author: User

Tag: Send protocol data in UDP format

Basic introduction to UDP Protocol 1. Basic concepts

UDP is a simple packet-oriented Transport layer protocol: each output of the process produces exactly one UDP datagram and is assembled into an IP datagram to be sent, unlike the stream character protocol, such as TCP, where the entire data generated by the application is not associated with a single IP datagram that is actually sent. UDP provides unreliable services, and its datagram format is as shown in

        UDP数据报
IP Header UDP Header UDP Data
2.UDP Header
16-bit source port number 16-bit destination port number
16-bit UDP length 16-bit UDP checksum
Data Data

The port number represents the sending process and the receiving process, and the TCP port number is independent from the UDP port number, so we can bind both UDP and TCP with the same port. The UDP length field specifies the length of the UDP header and UDP data

3.UDP Checksum

UDP inspection and is an end-to-end inspection and, it is calculated by the sender, and then by the receiver to verify that the purpose is to find the UDP header and data between the sending end to the receiving end of any changes

4.IP Shards

At any time the IP layer receives a copy of the IP data, it is to determine which interface to send data (routing), and query the interface of the MTU,IP to compare the MTU with the length of the datagram, if you need to Shard, the Shard can occur on the original sending side of the host, can also occur in the intermediate route
After a copy of the IP datagram is fragmented, the reorganization is performed only at the destination, and the reorganization is done by the IP layer of the target, and the fragmented datagram may be re-fragmented
For each IP datagram on the sending side, the Marked field contains a unique value that is copied to each slice when the datagram is fragmented, with one of the bite to denote more slices, except for the last one, each of which is to place 1, the slice offset field is the position at which the slice is offset from the beginning of the original datagram
There is a bite in the flag segment called Do not fragment field, if the field is set to 1,ip will not Shard, instead of the datagram discarded, send an ICMP error message
Although the IP shard process is transparent, there is one thing that you do not want to use, even if you just lose one piece of data, you have to retransmit the entire datagram

Interaction between 5.UDP and ARP

After the IP shard, each piece will produce ARP requests, but the ARP reply will only answer the last piece, after the first datagram arrives, the IP layer must start a timer, if the data in the specified time not all arrived, the datagram will be discarded

6.UDP Server Design (1) Customer IP address and port number
来自客户的是UDP数据报。IP首部包含源端和目地端IP地址,UDP包含了源端和目的端的端口号,当应用程序接收到UDP数据报时,操作系统不许告诉它是谁发来的消息,即IP和端口号
(2) Destination IP address

Some applications need to know who the datagram is sent to, that is, the destination IP

(3) UDP input Queue

Typically, each UDP port used by the program is associated with a finite size input queue. This means that requests from different customers that arrive at the same time will have UDP automatically queued, and the received UDP datagrams are given to the application in the order in which they are received

Broadcast and multicast 1. Basic Concepts

Broadcast and multicast are used only for UDP, and sometimes a host sends frames to all hosts on the network, which is broadcast, multicast is between unicast and broadcast, and frames are sent only to all hosts that belong to the multicast group

2. Broadcast (1) Restricted broadcasts

The restricted broadcast address is 255.255.255.255. This address is used for the destination address of the IP datagram during host configuration. At this point, the host may not know the network mask of its network, or even its IP address. In any case, the router does not forward datagrams with the destination address as a restricted broadcast address, so that the datagram only appears on the local network

(2) Broadcast to network

The broadcast address to the network is the address of the host number 1, and the Class A broadcast address is netid.255.255.255
A router must forward a broadcast that points to a network, but it must also have a choice not to forward

(3) Broadcast to subnet

The broadcast address to the subnet is an address with a host number of 1 and a specific subnet number

(4) Broadcasts that point to all subnets

Broadcasts that point to all subnets also need to know the subnet mask of the destination network so that it is separate from the broadcast address that points to the network, for example, IP 128.1.255.255 is a broadcast address that points to all subnets, and of course, the network does not divide subnets, which is a broadcast to the network

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

TCP/IP Detailed learning Note--UDP protocol

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.