1. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
1
Content
Week 9: Transport Layer
Principles of Transport Layer
Transport-layer Services
Multiplexing and demultiplexing
Transport Layer Protocols
Connectionless Transport: UDP
Connection-oriented Transport: TCP
Segment Structure
Reliable Data Transfer
Flow Control
Connection management
2. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP Sender (Events)
2
Sender Events
Host B
Host A
Seq=92, 8 bytes of data
Seq=92, 8 bytes of data
ACK=100
timeout
Receive data from Application layer
1
2
3
3. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP Sender (simplified)
event: data received from
application
create segment with seq #
seq # is byte-stream number
of first data byte in segment
start timer if not already
running
• think of timer as for oldest
unACKed segment
• expiration interval:
TimeOutInterval
event: timeout
retransmit segment that
caused timeout
restart timer
event: ACK received
if ACK acknowledges
previously unACKed segments
• update what is known to be
ACKed
• start timer if there are still
unACKed segments
3
1 2
3
4. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP Receiver: ACK generation [RFC 5681]
Event at receiver
Arrival of in-order segment with
expected seq #. All data up to
expected seq # already ACKed
Arrival of in-order segment with
expected seq #. One other
segment has ACK pending
Arrival of out-of-order segment
higher-than-expect seq. # .
Gap detected
Arrival of segment that
partially or completely fills gap
TCP receiver action
Delayed ACK. Wait up to 500ms
for next segment. If no next segment,
send ACK
Immediately send single cumulative
ACK, ACKing both in-order segments
Immediately send duplicate ACK,
indicating seq. # of next expected byte
Immediate send ACK, provided that
segment starts at lower end of gap
4
5. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP: retransmission scenarios
lost ACK scenario
Host B
Host A
Seq=92, 8 bytes of data
Seq=92, 8 bytes of data
ACK=100
X
ACK=100
timeout
premature timeout
Host B
Host A
Seq=92, 8
bytes of
data
ACK=120
timeout
ACK=100
ACK=120
SendBase=100
SendBase=120
SendBase=120
Seq=92, 8 bytes of data
Seq=100, 20 bytes of data
SendBase=92
send cumulative
ACK for 120
5
6. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP: retransmission scenarios
cumulative ACK
covers for earlier lost
ACK
Host B
Host A
Seq=92, 8 bytes of data
Seq=120, 15 bytes of data
Seq=100, 20 bytes of data
X
ACK=100
ACK=120
6
7. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP fast retransmit
Host B
Host A
timeout
ACK=100
ACK=100
ACK=100
ACK=100
X
Seq=92, 8 bytes of data
Seq=100, 20 bytes of
data
Seq=100, 20 bytes of data
Receipt of three duplicate ACKs
indicates 3 segments received
after a missing segment – lost
segment is likely. So retransmit!
if sender receives 3 additional
ACKs for same data (“triple
duplicate ACKs”), resend unACKed
segment with smallest seq #
likely that unACKed segment lost,
so don’t wait for timeout
TCP fast retransmit
7
Seq=120, 10 bytes of
data
Seq=130, 10 bytes of
data
Seq=140, 10 bytes of
data
8. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
8
Content
Week 9: Transport Layer
Principles of Transport Layer
Transport-layer Services
Multiplexing and demultiplexing
Transport Layer Protocols
Connectionless Transport: UDP
Connection-oriented Transport: TCP
Segment Structure
Reliable Data Transfer
Flow Control
9. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP flow control
application
process
TCP socket
receiver buffers
TCP
code
IP
code
receiver protocol stack
Q: What happens if network
layer delivers data faster than
application layer removes
data from socket buffers?
Network layer
delivering IP datagram
payload into TCP
socket buffers
from sender
Application removing
data from TCP socket
buffers
9
10. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP flow control
application
process
TCP socket
receiver buffers
TCP
code
IP
code
receiver protocol stack
Q: What happens if network
layer delivers data faster than
application layer removes
data from socket buffers?
from sender
Application removing
data from TCP socket
buffers
receive window
flow control: # bytes
receiver willing to accept
10
11. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP flow control
application
process
TCP socket
receiver buffers
TCP
code
IP
code
receiver protocol stack
Q: What happens if network
layer delivers data faster than
application layer removes
data from socket buffers?
receiver controls sender, so
sender won’t overflow
receiver’s buffer by
transmitting too much, too fast
flow control
from sender
Application removing
data from TCP socket
buffers
11
12. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP flow control
TCP receiver “advertises” free buffer
space in rwnd field in TCP header
• RcvBuffer size set via socket
options (typical default is 4096 bytes)
• many operating systems autoadjust
RcvBuffer
sender limits amount of unACKed
(“in-flight”) data to received rwnd
guarantees receive buffer will not
overflow
buffered data
free buffer space
rwnd
RcvBuffer
TCP segment payloads
to application process
TCP receiver-side buffering
12
13. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
TCP flow control
TCP receiver “advertises” free buffer
space in rwnd field in TCP header
• RcvBuffer size set via socket
options (typical default is 4096 bytes)
• many operating systems autoadjust
RcvBuffer
sender limits amount of unACKed
(“in-flight”) data to received rwnd
guarantees receive buffer will not
overflow
flow control: # bytes receiver willing to accept
receive window
TCP segment format
13
14. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
14
Chapter 4: network layer
TCP/IP: Transmission Control Protocol / Internet Protocol
15. University of Sharjah: College of Computing and Informatics
Dr. Bouziane Brik
15
4.1 introduction
4.2 virtual circuit and datagram
networks
4.3 what’s inside a router
4.4 IP: Internet Protocol
– datagram format
– IPv4 addressing
– ICMP
– IPv6
4.5 routing algorithms
– link state
– distance vector
Chapter 4: outline