- 论坛徽章:
- 0
|
UDP:User Datagram Protocol
1:UDP is a simple,i, transport layer protocol: each output operation by a process produces exactly one UDP datagram, which causes one IP datagram to be sent.
2:UDP provides no reliability: it sends the datagrams that the application writes to the IP layer, but there is no guarantee that they ever reach their destination.
3:The application needs to worry about the size of the resulting IP datagram. If it exceeds the network's path MTU, the IP datagram is fragmented.
UDP encapsulation:
||
||
| IP header | UDP header | UDP data |
| 20 bytes | 8bytes | |
UDP header:
| 16bit Source port | 16bit Destination port |
| 16bit UDP length | 16bit UDP chechsum |
| |
| data |
| |
1:The port numbers identify the sending process and the receiving process.
2:The UDP length field is the length of the UDP header and the UDP data in bytes. The minimum value for this field is 8 bytes.
3:The caculating of UDP checksum:
1):The UDP checksum covers the UDP header and the UDP data;
2):The checksum in the IP header only covers the IP header, it does not cover any data in the IP datagram;
3):The checksum of UDP is optional,but the checksum of TCP is necessary.If the transmitted checksum is 0, it indicates that the sender did not compute the checksum;
4):Pseudo-header includes certain fields from the IP header, it's length is 12bytes.
5):The length of the UDP datagram can be an odd number of bytes, while the checksum algorithm adds 16-bit words. The solution is to append a pad byte of 0 to the end, if necessary, just for the checksum computation. (That is, this possible pad byte is not transmitted.)
6):This UDP checksum is an end-to-end checksum. It is calculated by the sender, and then verified by the receiver. It is designed to catch any modification of the UDP header or data anywhere between the sender and receiver.
Else:If the sender did compute a checksum and the receiver detects a checksum error, the UDP datagram is silently discarded. No error message is generated. (This is what happens if an IP header checksum error is detected by IP.)
IP Fragmentation
1:Whenever the IP layer receives an IP datagram to send, it determines which local interface the datagram is being sent on (routing), and queries that interface to obtain its MTU. IP compares the MTU with the datagram size and performs fragmentation, if necessary. Fragmentation can take place either at the original sending host or at an intermediate router;
2:When an IP datagram is fragmented, it is not reassembled until it reaches its final destination;It is also possible for the fragment of a datagram to again be fragmented (possibly more than once). The information maintained in the IP header for fragmentation and reassembly provides enough information to do this;
3:The fragmentation and reassembly is transparent to transport layer(TCP and UDP).
4:The identification field contains a unique value for each IP datagram that the sender transmits. This number is copied into each fragment of a particular datagram.
5:The flags field uses one bit as the "more fragments" bit(MF). This bit is turned on for each fragment comprising a datagram except the final fragment.
6:The fragment offset field contains the offset of this fragment from the beginning of the original datagram. Also, when a datagram is fragmented the total length field of each fragment is changed to be the size of that fragment.
7:When an IP datagram is fragmented, each fragment becomes its own packet, with its own IP header, and is routed independently of any other packets. This makes it possible for the fragments of a datagram to arrive at the final destination out of order, but there is enough information in the IP header to allow the receiver to reassemble the fragments correctly.
8:one of the bits in the flags field is called the "don't fragment" bit. If this is turned on, IP will not fragment the datagram. Instead the datagram is thrown away and an ICMP error ("fragmentation needed but don't fragment bit set,") is sent to the originator; For this reason alone, fragmentation is often avoided.
9:If one fragment is lost the entire datagram must be retransmitted;There is no way to resend only one fragment of a datagram.
10:The transport layer information is only appears in the first fragment.
11:Fragmentation requires that the data portion of the generated fragments (that is, everything excluding the IP header) be a multiple of 8 bytes for all fragments other than the final one.
# 2009-09-17 17:00
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/104229/showart_2056415.html |
|