You are on page 1of 16

2020/21 COMP3234A

 UDP
 UDP provides a simple end-to-end data transfer service
 Unreliable & connectionless

 Internet Checksum
 An error-detection mechanism used by UDP and TCP (and IP)

Computer and Communication Networks 2


 [ILO2 - Technologies and Protocols] be able to describe the working
principles behind key network protocols – UDP and Internet Checksum
 ILO 2a - Transport Layer: comprehend the challenges and explain the principles in
providing reliable communication in an unreliable medium.

Computer and Communication Networks 3


 Required Reading
 Chapter 3 of Computer Networking – A Top-Down Approach Featuring the Internet 7th
Edition, by J. Kurose et. Al
 Sections 3.1.2, 3.3

Computer and Communication Networks 4


 UDP
 Just a minimal extension of the “best-effort” unreliable service of IP
 Support end-to-end (or process-to-process) data delivery with or without error checking
 No guarantee on (1) data delivery and (2) arrival order of segments

 TCP
 Reliable data transfer service
 Ensure that data is delivered from sender to receiver in-order and correctly
 Error checking, sequencing, acknowledgment, retransmission
 Flow control
 Prevent overflowing the buffer at receiving host
 Congestion control
 Prevents any one TCP connection from generating excessive traffic and overflowing the buffer resources in
packet switches along communication path
 Connection management
 Services not offered
 delay guarantees
 bandwidth guarantees

Computer and Communication Networks 5


 "no-frills bare-bones" Internet transport protocol
 almost raw IP except providing :
 Multiplexing & demultiplexing
 Allow multiple processes in a host to use the IP network for data communication
 i.e., extending the IP host-to-host delivery to process-to-process delivery
 [Optional] Error checking
 UDP segments may be
 Lost or delivered out of order – because IP is unreliable

 Connectionless
 no need to set up a connection between UDP sender & receiver
 If sender wants to send, just sends
 As connectionless, a UDP peer (socket) can send to and receive from any UDP peer (socket)
 Less overhead in managing this logical communication channel

Computer and Communication Networks 6


 UDP segments sent or received via the UDP socket may deliver to or come
from different peers
 Each UDP segment is treated and handled independently
 e.g., for each outgoing UDP segment, we need to provide receiver’s address
 e.g., for each incoming UDP segment, we can find out the sender’s address

 Small UDP header


 No flow and congestion control
 UDP can blast away as fast as desired; thus, application-level has more control in the
transmission speed when compare to TCP

 Good for some applications do not need a reliable transfer


 Because these applications can tolerate certain degree of losses
 e.g., real-time multimedia applications

Computer and Communication Networks 7


 UDP header consists of 32 bits
 Source and destination port numbers (16-bit each)

8 bytes
 UDP length (16-bit)
 Total number of bytes in segment (including header)
 8 bytes ≤ length ≤ 216
 Checksum (16-bit)
 Based on Internet Checksum calculation

 UDP multiplexing & demultiplexing


 We can identify a UDP endpoint by 2-tuple:
(destination IP address, destination port)
 When a host receives UDP segment
 checks destination port number
 directs UDP segment to a socket associated with that port number
 Source port number is not used in demultiplexing
 Segments with different source IP addresses and/or source port numbers can be sent to same
destination UDP socket at the same time
Computer and Communication Networks 8
Transmitter
At the receiving end, the
error detection value is
recalculated and
checked against the
received value

If they differ, an error has


occurred
Receiver

Error detection uses the concept of redundancy,


which means adding extra bits for detecting errors
at the destination

An error detection value is first calculated by the


sender and transmitted along with the data

Computer and Communication Networks 9


 Several Internet protocols (e.g. IP, TCP, UDP) include extra “check
bits” to detect bit errors in transmission
 A checksum is calculated and included in a special field in the header

The algorithm that used by IP, TCP & UDP is called Internet Checksum,
which is selected because of
 Ease of implementation in software
 Is easy to recompute the checksum if there are minor changes in the packet

Computer and Communication Networks 10


 This scheme views a message M (with k bits) as a M = b0b1b2...bL-1
sequence of 16-bit strings (assume k is divisible by 8)
X = ( b0 + b1 + b2+ ...+ bL-1 )
 Add all these 16-bit strings using ones complement addition
1010
 Ones complement addition, like standard addition but carryout
1100
from most significant bit is added to result
10110
 Then take the ones complement of the summation result 1
 In ones complement, converts all the zeros to ones and all the ones 0111
to zeros

 Resulting 16-bit number is the Internet checksum ~(0111) → 1000

Computer and Communication Networks 11


Send the message M together with the checksum to the receiver, i.e.,
M + ~X = M'
 On the receiver side, receiver receives message M’
 which should be just M + ~X if didn’t encounter transmission error
 Apply the same checksum operation on the entire received message M’
~(M’)
= ~(M + ~X)
= ~(b0 + b1 + b2+ ...+ bL-1 + ~X)
= ~(X + ~X)
= ~(all ones)
= zero

 The result should be zero if no transmission error; otherwise, the message is corrupted

Computer and Communication Networks 12


Suppose the following three 16-bit blocks are to be sent using Internet Checksum.
0011000000111001
0101101110100000
1000011100000111

The numbers are added using one’s complement


0011000000111001 12345
0101101110100000 23456
1000011100000111 34567
----------------
10001001011100000 70368
1 -65535
----------------
Sum 0001001011100001 4833
Checksum 1110110100011110 60702 (65535-4833)
The transmitted pattern is
0011000000111001
0101101110100000
1000011100000111
1110110100011110
Computer and Communication Networks 13
Now suppose the receiver receives the pattern and there is no error.
0011000000111001 12345
0101101110100000 23456
1000011100000111 34567
1110110100011110 60702
When the receiver adds the four sections,
0011000000111001 12345
0101101110100000 23456
1000011100000111 34567
1110110100011110 60702
----------------
11111111111111110 131070
1 - 65535
---------------- -------
1111111111111111 65535
Take ones complement
0000000000000000 (65535-65535)

That is, it gets all 1s, which, after complementing, is all 0s and shows that there is no
error.

Computer and Communication Networks 14


Now suppose there is an (burst) error of length 5 that affects 4 bits.
0011000000111001 12345
0101101110100110 23462
0100011100000111 18183
1110110100011110 60702
When the receiver adds the four sections,

12345 + 23462 + 18183 + 60702 = 114692 – 65535 = 49157

After complementing, we get 65535-49157=16378 (0011111111111010), which is


not zero. We conclude that the pattern is corrupted.

Computer and Communication Networks 15


 UDP only provides minimal transport layer services
 Process-to-process communication – multiplexing and demultiplexing amongst
processes in the same host
 Error checking – using Internet Checksum

 UDP has a small header; thus, relatively smaller header overhead

 Checksum is an error-detecting scheme that applicable to messages of


any length
 Split the message into “piece” of 16-bit, add the pieces by one’s complement arithmetic
to form the 16-bit Checksum

Computer and Communication Networks 16

You might also like