Lecture_07_CN214 Transport Layer UDP
Lecture_07_CN214 Transport Layer UDP
log
Transport protocols actions in
ica
end systems:
le
n d-
Sender: breaks application
e nd
local or
messages into segments,
tra
regional ISP
nsp
passes to network layer
ort
home network content
Receiver: reassembles provider
network datacenter
segments into messages, application
transport
network
Sender:
Sender:
application is passed an application- app. msg
application
layer message
TThtranspor
app. msg
transport determines segment h
Al Hasa Riyad
Postal-service
Ahmed mail carrier Mohammed
Ahmed & Mohammed - responsible
for mail collection, distribution, and Postal service – carries the mails from
communicating with postal service house to house
9
CCSIT/KFU Transport Layer 9
Transport Layer vs. Network Layer
10
CCSIT/KFU Transport Layer 10
Transport Layer vs. Network Layer
Their services are constrained by the possible
services that the postal service provides
•T
hosts (also called end systems) = houses
processes = cousins
application messages = letters in envelope
transport layer protocol = Ahmed & Mohammed
network layer protocol = postal service (including mail
persons)
It may so happen that their uncles
could get sick, and so other people
may take over – analogously, the
computer network may provide
multiple transport protocols
Transport Layer
11
CCSIT/KFU 11
Two Transport Layer Protocol
TCP: Transmission Control application
transport
network
mobile network
Protocol data link
physical
national or global ISP
• Reliable, in-order delivery
log
• Congestion control
ica
le
• Flow control
n d-
e nd
• Connection setup local or
tra
regional ISP
UDP: User Datagram Protocol
nsp
ort
• Unreliable, unordered delivery home network content
provider
• No-frills extension of “best- network
application
datacenter
network
transport
effort” IP network
data link
enterprise
• Delay guarantees network
• Bandwidth guarantees
CCSIT/KFU Transport Layer 12
Transport Protocol Services
TCP Services
Reliable transport between sending and receiving process
Connection-oriented: setup required between client and server
processes
Flow control: sender won’t overwhelm receiver
Congestion control: throttle sender when network overloaded
Does not provide timing, minimum throughput guarantee,
security
UDP Services
Unreliable data transfer between sending and receiving process
Does not provide reliability, flow control, congestion control,
timing, throughput guarantee, security, or connection setup
It is a faster and connectionless protocol
CCSIT/KFU Transport Layer 13
HTTP server
client
application application
HTTP
msg
transport
transport
Hn Ht HTTP
msg
User Datagram Protocol (UDP)
“No frills,” “bare bones” Internet transport
protocol
“Best effort” service, UDP segments may be:
Lost
Delivered out-of-order to application
Connectionless:
No handshaking between UDP sender & receiver
Each UDP segment handled independently of others
application application
transport transport
(UDP) (UDP)
(UDP)
segment header fields t
values (UDP)
network
network (IP)
link
creates UDP segment (IP)
link
passes segment to IP physical
physical
application
length, in bytes of
data
UDP segment,
(payload) including header
data to/from
UDP segment format application layer
Transmitted: 5 6 11
Received: 4 6 11
receiver-computed
checksum
= sender-computed
checksum (as received)
sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
Even though
numbers have
changed (bit
flips), no change
in checksum!
CCSIT/KFU Transport Layer 28
Checksum: Example
Suppose our data is a list of five 4-bit numbers that we want to
send to a destination. In addition to sending these numbers, we
send the sum of the numbers. For example, if the set of numbers is
(7, 11, 12, 0, 6), we send (7 , 11 , 1 2 , 0 , 6 , 3 6 ) , where 36 is the
sum of the original numbers. The receiver adds the five numbers
and compares the result with the sum. If the two are the same, the
receiver assumes no error, accepts the five numbers, and discards
the sum. Otherwise, there is an error somewhere and the data are
not accepted.
We can make the job of the receiver easier if we send the
negative (complement) of the sum, called the checksum. In
this case, we send (7, 11, 12, 0, 6, −36). The receiver can add
all the numbers received (including the checksum). If the
result is 0, it assumes no error;
CCSIT/KFU otherwise,
Transport Layer there is an error. 29
Example (1’s Complement)
Q1: How can we represent the number 21 in one’s
complement arithmetic using only four bits?
Solution: The number 21 in binary is 10101 (it needs five bits).
We can wrap the leftmost bit and add it to the four rightmost
bits. We have (0101 + 1) = 0110 or 6.
Q2: How can we represent the number −6 in one’s
complement arithmetic using only four bits?
Solution: In one’s complement arithmetic, the negative or
complement of a number is found by inverting all bits. Positive
6 is 0110; negative 6 is 1001. If we consider only unsigned
numbers, this is 9. In other words, the complement of 6 is 9.
Another way to find the complement of a number in one’s
complement arithmetic is to subtract the number from 2n − 1
(16 − 1 in this case).
CCSIT/KFU Transport Layer 30
Example
Let us redo Exercise 10.19 using one’s complement
arithmetic. Figure 10.24 shows the process at the sender
and at the receiver. The sender initializes the checksum to
0 and adds all data items and the checksum (the checksum
is considered as one data item and is shown in color). The
result is 36. However, 36 cannot be expressed in 4 bits.
The extra two bits are wrapped and added with the sum to
create the wrapped sum value 6. In the figure, we have
shown the details in binary. The sum is then
complemented, resulting in the checksum value 9 (15 − 6
= 9). The sender now sends six data items to the receiver
including the checksum 9.
CCSIT/KFU Transport Layer 31
Example (Cont’d)
The receiver follows the same procedure as the sender. It
adds all data items (including the checksum); the result is
45. The sum is wrapped and becomes 15. The wrapped
sum is complemented and becomes 0. Since the value of
the checksum is 0, this means that the data is not
corrupted. The receiver drops the checksum and keeps the
other data items. If the checksum is not zero, the entire
packet is dropped.
transport
application