AU2023 Lect 3 - Transport Layer
AU2023 Lect 3 - Transport Layer
Ante Prodan
School of Computer, Data and
Mathematical Sciences
1
Housekeeping
Case Study Report
Have you chosen your topic?
Deadline by the end of the next week
I can list your name and contact
detail during the lecture if you need a
partner and I can put the list on
screen during the break
Next tutorial good opportunity to find
partner and select your topic…
2
Housekeeping
For your study use resources on vUWS
Learning guide
Lecture notes
Study questions
Multimedia
URLs
Video Resources accessible by using web
links provided and videos accessible via
vUWS
3
Comparing OSI and TCP/IP
models
Layer OSI Model TCP/IP Model
I
7 Application M
6 Presentation Application P
5 Session O
R !!!
4 Transport Transport T
3 Network Internet A
2 Data link N
Link T
1 Physical
OSI: Open Systems Interconnection (OSI) model (ISO/IEC 7498-1)
TCP/IP: Internet protocol suite is the set of communications protocols used for
the Internet and similar networks (names of the layers from RFC 1122)
Encapsulation of application data
descending through the TCP/IP
layers
I
M
TCP TCP P
header data or O
R
T
A
N
T
Multiplexing / Demultiplexing
IMPORTANT 6
Important Concepts
Logical communication between two processes.
transport-layer protocol provides logical communication
between processes
network-layer protocol provides logical communication
between hosts
Multiplexing and demultiplexing
Connectionless and connection-oriented
demultiplexing
Reliable data transfer (RDT)
Because packets can have bit errors as well as be lost, RDT
protocols are surprisingly complicated, requiring
acknowledgements, timers, checksums, sequence numbers,
and acknowledgement numbers.
Pipelined reliable data transfer
Flow control
Congestion control
7
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
segment structure
3.2 Multiplexing and
reliable data transfer
demultiplexing
flow control
3.3 Connectionless connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable congestion control
data transfer
3.7 TCP congestion
control
8
Transport services and protocols
application
transport
provide logical communication network
data link
between app processes running physical
on different hosts
transport protocols run in end
systems
send side: breaks app
9
Internet transport-layer protocols
application
delay guarantees
bandwidth guarantees
10
Multiplexing/demultiplexing
Demultiplexing at rcv host: Multiplexing at send host:
gathering data from multiple
delivering received segments
sockets, enveloping data with
to correct socket
header (later used for
demultiplexing)
= socket = process
P3 P1
P1 P2 P4 application
application application
host 2 host 3
host 1
11
How demultiplexing works
32 bits
transport-layer segment
application
each segment has source,
data
destination port number (message)
host uses IP addresses & port
numbers to direct segment to
appropriate socket TCP/UDP segment format
12
Connectionless demultiplexing
When host receives UDP
Create sockets with port segment:
numbers: checks destination port
DatagramSocket mySocket1 = number in segment
new DatagramSocket(12534); directs UDP segment to
DatagramSocket mySocket2 = socket with that port
new DatagramSocket(12535); number
UDP socket identified by IP datagrams with
two-tuple: different source IP
addresses and/or source
(dest IP address, dest port number) port numbers directed to
same socket
13
Connectionless demux (cont)
DatagramSocket serverSocket = new DatagramSocket(6428);
P2 P1
P1
P3
14
Connection-oriented demux
TCP socket identified Server host may
by 4-tuple: support many
source IP address simultaneous TCP
source port number sockets:
dest IP address each socket identified
dest port number by its own 4-tuple
recv host uses all Web servers have
four values to direct different sockets for
segment to each connecting client
appropriate socket non-persistent HTTP
will have different
socket for each request15
Connection-oriented demux
(cont)
P1 P4 P5 P6 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
P1 P4 P2 P1P3
SP: 5775
DP: 80
S-IP: B
D-IP:C
17
TCP Multiplexing Service
• Multiple processes within a host can
simultaneously access the network via a
single TCP entity.
• Each process within a host which uses TCP
services is identified with a port.
• A port, when concatenated with an IP address,
forms a socket, which is unique throughout the
internet.
• Service by TCP is provided by means of a
logical connection between a pair of sockets.
18
TCP Multiplexing Service
As an example, the diagram on the next slide
shows three hosts A, B and C connected over the
internet. The multiplexing service of TCP would
enable a process X, say in host A to establish a
connection to a process Y in host B. This might
involve use of port 2 in A and port 1 in B. At the
same time a process P in B could establish a
connection to a process Q in A using port 2
of B and port 1 of A. Finally, a process M in A might
establish a link to a process N in host C using ports
3 of A and 1 of C.
19
TCP Multiplexing Service
20
TCP Multiplexing Service
21
http://etc.ch/EP88
Question 1
(a) Modulation
(b) Encoding
(c) Code division
(d) Demultiplexing
22
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable
congestion control
data transfer
3.7 TCP congestion
control
23
UDP: User Datagram Protocol [RFC
768]
“no frills,” “bare bones”
Internet transport protocol Why is there a UDP?
“best effort” service, UDP no connection establishment
segments may be: (which can add delay)
lost
simple: no connection state
at sender, receiver
delivered out of order to
24
UDP: more
32 bits
often used for streaming
multimedia apps Length, in source port # dest port #
loss tolerant bytes of UDP length checksum
segment,
rate sensitive
including
other UDP uses header
DNS
SNMP
Application
data
reliable transfer over UDP:
(message)
add reliability at application
layer
application-specific error
UDP segment format
recovery!
25
UDP checksum
Goal: detect “errors” (e.g., flipped bits) in
transmitted segment
Sender: Receiver:
treat segment contents as compute checksum of received
sequence of 16-bit integers segment
checksum: addition (1’s check if computed checksum
complement sum) of equals checksum field value:
segment contents NO - error detected
26
Internet Checksum Example
Note
When adding numbers, a carryout from the
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
sum 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
27
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
segment structure
3.2 Multiplexing and
reliable data transfer
demultiplexing
flow control
3.3 Connectionless connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable congestion control
data transfer
3.7 TCP congestion
control
28
Principles of Reliable data transfer
important in app., transport, link layers
top-10 list of important networking topics!
send receive
side side
32
Reliable data transfer: getting started
We’ll:
incrementally develop sender, receiver sides of
sender receiver
34
Rdt2.0: channel with bit errors
35
rdt2.0: FSM specification
rdt_send(data)
snkpkt = make_pkt(data, checksum) receiver
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK) 36
rdt2.0: operation with no errors
rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
37
rdt2.0: error scenario
rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt)
rdt_rcv(rcvpkt) &&
isNAK(rcvpkt)
Wait for Wait for rdt_rcv(rcvpkt) &&
call from ACK or udt_send(sndpkt) corrupt(rcvpkt)
above NAK
udt_send(NAK)
rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt)
extract(rcvpkt,data)
deliver_data(data)
udt_send(ACK)
38
rdt2.0 has a fatal flaw!
What happens if ACK/NAK Handling duplicates:
corrupted? sender retransmits current
sender doesn’t know what pkt if ACK/NAK garbled
happened at receiver! sender adds sequence
can’t just retransmit: number to each pkt
possible duplicate receiver discards (doesn’t
deliver up) duplicate pkt
39
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
segment structure
3.2 Multiplexing and
reliable data transfer
demultiplexing
flow control
3.3 Connectionless connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable congestion control
data transfer
3.7 TCP congestion
control
40
TCP: Overview RFCs: 793, 1122, 1323, 2018,
2581
41
TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not
PSH: push data now len used
UA P R S F Receive window
(generally not used) # bytes
checksum Urg data pnter
rcvr willing
RST, SYN, FIN: to accept
Options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)
42
TCP seq. #’s and ACKs
Seq. #’s: Host A Host B
byte stream User
“number” of first types
‘C’
byte in segment’s host ACKs
data receipt of
‘C’, echoes
ACKs: back ‘C’
seq # of next byte
44
TCP reliable data transfer
TCP creates rdt Retransmissions are
service on top of IP’s triggered by:
unreliable service timeout events
Pipelined segments duplicate acks
46
TCP: retransmission scenarios
Host A Host B Host A Host B
Seq=92 timeout
timeout
X
loss
Sendbase
= 100
Seq=92 timeout
SendBase
= 120
SendBase
= 100 SendBase
= 120 premature timeout
time time
lost ACK scenario 47
TCP retransmission scenarios
(more)
Host A Host B
timeout
X
loss
SendBase
= 120
time
Cumulative ACK scenario
48
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
segment structure
3.2 Multiplexing and
reliable data transfer
demultiplexing
flow control
3.3 Connectionless connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable congestion control
data transfer
3.7 TCP congestion
control
49
TCP Flow Control
flow control
sender won’t overflow
receive side of TCP receiver’s buffer by
connection has a transmitting too much,
receive buffer: too fast
speed-matching
service: matching
the send rate to the
receiving app’s drain
app process may be rate
slow at reading from
buffer
50
TCP Flow control: how it works
Rcvr advertises spare
room by including
value of RcvWindow
in segments
(Suppose TCP receiver Sender limits
discards out-of-order unACKed data to
segments) RcvWindow
spare room in buffer guarantees receive
= RcvWindow buffer doesn’t
overflow
= RcvBuffer-
[LastByteRcvd -
LastByteRead] 51
http://etc.ch/EP88
Question 2
Which one of the protocols listed below
can prevent buffer overflow (overrun)?
(a) UDP
(b) HTTP
(c) DNS
(d) TCP
52
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable
congestion control
data transfer
3.7 TCP congestion
control
53
TCP Connection Management
client server
Closing a connection: close
55
TCP Connection Management (cont.)
client server
timed wait
Connection closed.
closed
Note: with small modification,
can handle simultaneous
FINs. closed
56
Chapter 3 outline
3.1 Transport-layer 3.5 Connection-oriented
services transport: TCP
3.2 Multiplexing and segment structure
demultiplexing reliable data transfer
flow control
3.3 Connectionless
connection management
transport: UDP
3.6 Principles of
3.4 Principles of reliable
congestion control
data transfer
3.7 TCP congestion
control
57
Principles of Congestion Control
Congestion:
informally: “too many sources sending too
much data too fast for network to handle”
different from flow control!
manifestations:
lost packets (buffer overflow at routers)
a top-10 problem!
58
TCP congestion control: additive
increase, multiplicative decrease
loss congestion
window
congestion window size
24 Kbytes
Saw tooth
behavior: probing
16 Kbytes
for bandwidth
8 Kbytes
time
time
59
http://etc.ch/EP88
Question 3
At which devices TCP congestion control
detection is implemented?
60
External links
Protocols at Transport Layer
https://www.youtube.com/watch?v=Vdc8T
CESIg8
UDP
http://www.youtube.com/watch?v=77VVjODrJiQ&fea
ture=related
TCP
https://www.youtube.com/watch?v=FdwNzb1CQPg
http://www.tcpipguide.com/free/t_TCPWindowSizeA
djustmentandFlowControl.htm
http://www.youtube.com/watch?v=7Z-h9SZZ22g
61