SlideShare a Scribd company logo
1 of 42
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
CHAPTER 3
TRANSPORT LAYER
2
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
OUTLINE
1. Transport Services & Protocols
2. Multiplexing & Demultiplexing
3. Principle of Reliable Data Transfer
4. UDP – Connectionless Transport
5. TCP – Connection-Oriented Transport
6. TCP Flow Control
7. TCP Congestion Control
Faculty of Information Technology
MSc. Nguyen Cong Danh
1. TRANSPORT SERVICES
& PROTOCOLS
4
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
• Provide logical communication between app
processes running on different hosts
• Transport protocols run in end systems
oSend side: breaks app messages into
segments, passes to network layer
oRcv side: reassembles segments into
messages, passes to app layer
• More than one transport protocol available to
apps
o Internet: TCP and UDP
TRANSPORT SERVICES & PROTOCOLS
5
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
• Reliable, in-order delivery (TCP)
ocongestion control
oflow control
oconnection setup
• Unreliable, unordered delivery: UDP
ono-frills extension of “best-effort” IP
oprocess-to-process data delivery and error
checking—are the only two services that
UDP provides
• Services not available for IP protocol:
odelay guarantees
obandwidth guarantees
INTERNET TRANSPORT-LAYER PROTOCOLS
6
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP vs UDP more details…
TCP service:
• Reliable transport between sending and
receiving process
• Flow control: sender won’t overwhelm receiver
• Congestion control: throttle sender when
network overloaded
• Does not provide: timing, minimum throughput
guarantee, security
• Connection-oriented: setup required between
client and server processes
UDP service:
• Unreliable data transfer between sending
and receiving process
• Does not provide: reliability, flow control,
congestion control, timing, throughput
guarantee, security, or connection setup,
Faculty of Information Technology
MSc. Nguyen Cong Danh
2. MULTIPLEXING &
DEMULTIPLEXING
8
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
MULTIPLEXING/DEMULTIPLEXING
Transport protocols
(TCP, UDP)
Network protocol (IP)
9
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
HOW DEMULTIPLEXING WORKS
• Host receives IP packets
oEach packet has source IP address,
destination IP address
oEach packet carries one transport-
layer segment
oEach segment has source,
destination port number
• Host uses IP addresses & port numbers
to direct segment to appropriate socket
TCP/UDP segment format
Multiplexing = gathering data chunks at the source, encapsulating with header information, passing the
segment to the network layer
Demultiplexing = delivering the data in a transport-layer segment to the correct socket
10
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
COMMON PORTS
11
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
CONNECTIONLESS MULTIPLEXING & DEMULTIPLEXING
DatagramSocket serverSocket =
new DatagramSocket (6428);
transport
application
physical
link
network
P2
transport
application
physical
link
network
P1
DatagramSocket mySocket2 =
new DatagramSocket(9157);
source port: 9157
dest port: 6428
source port: 6428
dest port: 9157
• UDP socket must be specified by:
o destination IP address
o destination port X
• When host receives UDP segment:
o checks destination port X in
segment
o directs UDP segment to socket with
that port X
IP datagrams with same dest. port X, but
different source IP addresses and/or source
port numbers will be directed to same
socket at destination
12
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
CONNECTION-ORIENTED DEMUX
• TCP socket identified by 4-tuple:
osource IP address
osource port number
odest IP address
odest port number
• Demux: receiver uses all four values to
direct segment to appropriate socket
• Server host may support many
simultaneous TCP sockets:
oeach socket identified by its own 4-tuple
• Web servers have different sockets for each
connecting client
onon-persistent HTTP will have different
socket for each request
13
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
CONNECTION-ORIENTED DEMUX: EXAMPLE
Faculty of Information Technology
MSc. Nguyen Cong Danh
4. UDP –
CONNECTIONLESS
TRANSPORT
15
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
UDP: USER DATAGRAM PROTOCOL
• “Best Effort” service, UDP
segments may be:
olost
odelivered out-of-order to app
• Connectionless:
ono handshaking between
UDP sender, receiver
oeach UDP segment handled
independently of others
• UDP use:
o streaming multimedia apps (loss
tolerant, rate sensitive)
o DNS
o SNMP
• Reliable transfer over UDP:
o add reliability at application layer
o application-specific error
recovery!
16
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
WHY CHOSE UDP INSTEAD TCP?
• Real-time applications require
minimum delay
• No connection establishment
o No delay for connection
establishment
• No connection state
o Support more active client
• Small packet header overhead
o TCP: 20 bytes/segment
o UDP: 8 bytes/segment
17
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
UDP SEGMENT STRUCTURE
source port # dest port #
32 bits
application
data
(payload)
UDP segment format
length checksum
length, in bytes of
UDP segment,
including header
For error detection
 Receiving host checks whether
bits within the UDP segment have
been altered
18
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
UDP CHECKSUM
Goal: detect “errors” (e.g., flipped bits) in transmitted segment
Sender:
• Treat segment contents,
including header fields, as
sequence of 16-bit integers
• Checksum: addition (one ’ s
complement sum) of segment
contents
• Sender puts checksum value
into UDP checksum field
Receiver:
• Compute checksum of received
segment
• Check if computed checksum
equals checksum field value:
oNO - error detected
oYES - no error detected. But
maybe errors nonetheless?
More later ….
UDP provides error checking  but does not do anything to recover from an error
19
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
INTERNET CHECKSUM: EXAMPLE
Example: add two 16-bit integers
1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 0 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
1 1 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
wraparound
sum
checksum
Note: when adding numbers, a carryout from the most significant bit needs to be added to the result
Faculty of Information Technology
MSc. Nguyen Cong Danh
5. TCP – CONNECTION-
ORIENTED TRANSPORT
21
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP: TRANSMISSION CONTROL PROTOCOL
• Point-to-point:
oOne sender, one receiver
• Reliable, in-order byte steam:
oNo “message boundaries”
• Pipelined:
oTCP congestion and flow
control set window size
• Full duplex data:
oBi-directional data flow in same connection
oMSS: maximum segment size
• Connection-oriented:
oHandshaking (exchange of control msgs) inits sender,
receiver state before data exchange
• Flow controlled:
oSender will not overwhelm receiver
22
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SEGMENT STRUCTURE
source port # dest port #
32 bits
application
data
(variable length)
sequence number
acknowledgement number
receive window
Urg data pointer
checksum
F
S
R
P
A
U
head
len
not
used
options (variable length)
URG: urgent data
(generally not used)
ACK: ACK #
valid
PSH: push data now
(generally not used)
RST, SYN, FIN:
connection estab
(setup, teardown
commands)
# bytes
rcvr willing
to accept
counting
by bytes of data
(not segments!)
Internet
checksum
(as in UDP)
23
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SEQUENCE NUMBERS, ACKs
• Sequence numbers:
o Byte stream “number” of first byte
in segment’s data
• Acknowledgements:
o Seq # of next byte expected from
other side
o Cumulative ACK
Q: How receiver handles out-of-order
segments?
source port # dest port #
sequence number
acknowledgement number
checksum
rwnd
urg pointer
incoming segment to sender
A
sent
ACKed
sent, not-
yet ACKed
(“in-
flight”)
usable
but not
yet sent
not
usable
window size
N
sender sequence number space
source port # dest port #
sequence number
acknowledgement number
checksum
rwnd
urg pointer
Outgoing segment from sender
24
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
ESTABLISH TCP CONNECTION: TCP 3-WAY HANDSHAKE
SYNbit=1, Seq=x
choose init seq num, x
send TCP SYN msg
ESTAB
SYNbit=1, Seq=y
ACKbit=1; ACKnum=x+1
choose init seq num, y
send TCP SYNACK
msg, acking SYN
ACKbit=1, ACKnum=y+1
received SYNACK(x)
indicates server is live;
send ACK for SYNACK;
this segment may contain
client-to-server data
received ACK(y)
indicates client is live
SYNSENT
ESTAB
SYN RCVD
client state
LISTEN
server state
LISTEN
25
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP: CLOSING A CONNECTION
FIN_WAIT_2
CLOSE_WAIT
FINbit=1, seq=y
ACKbit=1; ACKnum=y+1
ACKbit=1; ACKnum=x+1
wait for server
close
can still
send data
can no longer
send data
LAST_ACK
CLOSED
TIMED_WAIT
timed wait
for 2*max
segment lifetime
CLOSED
FIN_WAIT_1 FINbit=1, seq=x
can no longer
send but can
receive data
clientSocket.close()
client state server state
ESTAB
ESTAB
26
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
SUPPLEMENT 6: TCP vs UDP CONNECTIONS
27
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP RETRANSMISSION SCENARIOS
lost ACK scenario
Host B
Host A
Seq=92, 8 bytes of data
ACK=100
Seq=92, 8 bytes of data
X
timeout
ACK=100
premature timeout
Host B
Host A
Seq=92, 8 bytes of data
ACK=100
Seq=92, 8
bytes of data
timeout
ACK=120
Seq=100, 20 bytes of data
ACK=120
SendBase=100
SendBase=120
SendBase=120
SendBase=92
SendBase=92
SendBase=100
28
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP RETRANSMISSION SCENARIOS
X
cumulative ACK
Host B
Host A
Seq=92, 8 bytes of data
ACK=100
Seq=120, 15 bytes of data
timeout
Seq=100, 20 bytes of data
ACK=120
SendBase=92
SendBase=120
29
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
3 DUPLICATE ACKs
X
fast retransmit after sender
receipt of triple duplicate ACK
Host B
Host A
Seq=92, 8 bytes of data
ACK=100
timeout
ACK=100
ACK=100
ACK=100
Seq=100, 20 bytes of data
Seq=100, 20 bytes of data
• When a duplicate ACK is received the sender does not
know if it is because a TCP segment was lost or simply
that a segment was delayed and received out of order
at the receiver.
• If more than two duplicate ACKs are received by the
sender, it is a strong indication that at least one
segment has been lost.
• When three or more duplicate ACKs are received, the
sender does not even wait for a re-transmission time to
expire before re-transmitting the segment ( the sender
enters the congestion avoidance mode).
Faculty of Information Technology
MSc. Nguyen Cong Danh
6. TCP FLOW CONTROL
31
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
Old data sent that has already been ACKed
(Could as well be marked as free space)
New data sent to transport layer
by application, but not yet sent
Free buffer space where application can
write new data to be sent
32
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
Data that has been sent, but not ACKed
Also called the Sending window
This is the sliding window (yes, it slides!)
This data can not be sent yet, as
the sliding window in this example
has a maximum size of 10
33
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
ACTION: An ACK of the oldest sent packet arrives
• The window slides so that the left border is in line
with the oldest outstanding ACK
• The unsent segments that fit within the window
are sent
34
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
• The data is placed in free buffer slots
ACTION: The application has more data to send
35
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
• Older sent but un-ACKed segments are now
considered to be ACKed
ACTION: An ACK arrives in the middle of the window
• The window slides and unsent segments within
the window are sent
• The window shrinks by one segment as there is
no more than 9 segments outstanding
36
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
• The data is placed in free buffer slots
ACTION: The application has more data to send
• As the window is currently 9 segments wide,
it can grow by one segment
• The new data that fits within the window is sent
37
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP SLIDING WINDOW – SENDER SIDE
Not sent Sent, no ACK ACKed Free
Sending buffer at the sender:
• The ACK is silently ignored
ACTION: An ACK of already ACKed segments arrives
38
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP FLOW CONTROL
application
process
TCP socket
receiver buffers
TCP
code
IP
code
application
OS
receiver protocol stack
application may
remove data from
TCP socket buffers ….
… slower than
TCP
receiver is
delivering
(sender is
sending)
from sender
receiver controls sender, so
sender won’t overflow
receiver’s buffer by transmitting
too much, too fast
flow control
The idea is that a node receiving data will send
some kind of feedback to the node sending the
data to let it know about its current condition.
39
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP FLOW CONTROL
• Receiver “advertises” free buffer space by
including rwnd value in TCP header of
receiver-to-sender segments (aka. in ACK)
oRcvBuffer is the receive buffer. It’s size
set via socket options (typical default is
4096 bytes)
oMany operating systems auto adjust
RcvBuffer
• Sender limits amount of unacked (“in-flight”)
data sent to receiver based on the rwnd
value
• Guarantees receive buffer will not overflow
buffered data
free buffer space
rwnd
RcvBuffer
TCP segment payloads
to application process
receiver-side buffering
TCP provides flow control by having the sender maintain a variable called the receive window (rwnd).
Faculty of Information Technology
MSc. Nguyen Cong Danh
7. TCP CONGESTION
CONTROL
41
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
INTRODUCTION TO CONGESTION CONTROL
Congestion:
• Informally: “too many sources sending too
much data too fast for network to handle”
• Different from flow control!
• Manifestations:
oLost packets (buffer overflow at routers)
oLong delays (queueing in router buffers)
TCP Congestion Control:
• Basic idea: each source determines how
much capacity is available to a given flow in
the network.  Each sender limits the rate!
oRaises 3 questions:
- How does TCP limit the rate?
- How does TCP sender perceive that
there is congestion on the path?
- What algorithm should the sender
use to change ites send rate?
• ACKs are used to “pace” the transmission of
packets such that TCP is “self-clocking”
42
FACULTY OF INFORMATION TECHNOLOGY
MSc. Nguyen Cong Danh
TCP CONGESTION CONTROL ALGORITHMS
• Some TCP congestion Control algorithms:
o Tahoe
 Slow Start
 Congestion Avoidance
 Fast Retransmit
o Reno
 Fast Recovery
o Vegas
 New Congestion Avoidance
o RED
o REM
o SACK
o FACK…
Slow Start
Congestion
Avoidance
Fast
Retransmit/
Fast
Recovery

More Related Content

Similar to Chapter 3 - Transport Layer for VN Students

Master Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to ExpertMaster Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to ExpertAbhishek Sagar
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP PresentationHarish Chand
 
Beyond TCP: The evolution of Internet transport protocols
Beyond TCP: The evolution of Internet transport protocolsBeyond TCP: The evolution of Internet transport protocols
Beyond TCP: The evolution of Internet transport protocolsOlivier Bonaventure
 
Chapter_3_v8.1.pdf
Chapter_3_v8.1.pdfChapter_3_v8.1.pdf
Chapter_3_v8.1.pdfLNhi89
 
Jaimin chp-6 - transport layer- 2011 batch
Jaimin   chp-6 - transport layer- 2011 batchJaimin   chp-6 - transport layer- 2011 batch
Jaimin chp-6 - transport layer- 2011 batchJaimin Jani
 
LECTURE-Transport-Layer_lec.ppt
LECTURE-Transport-Layer_lec.pptLECTURE-Transport-Layer_lec.ppt
LECTURE-Transport-Layer_lec.pptMonirHossain707319
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingKeyur Vadodariya
 
transport layer protocols
transport layer protocolstransport layer protocols
transport layer protocolsBE Smârt
 
TCP_NISCHAYBAHL.pptx
TCP_NISCHAYBAHL.pptxTCP_NISCHAYBAHL.pptx
TCP_NISCHAYBAHL.pptxNischayBahl1
 
TRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxTRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxutkarshlodhi4
 
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdf
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdfDCN 5th ed. slides ch24 Transport-Layer Protocols.pdf
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdfBilal Munir Mughal
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer servicesMelvin Cabatuan
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxDESTROYER39
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxsarosh32
 

Similar to Chapter 3 - Transport Layer for VN Students (20)

lecturer3.pptx
lecturer3.pptxlecturer3.pptx
lecturer3.pptx
 
Week4 lec1-bscs1
Week4 lec1-bscs1Week4 lec1-bscs1
Week4 lec1-bscs1
 
Master Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to ExpertMaster Class : TCP/IP Mechanics from Scratch to Expert
Master Class : TCP/IP Mechanics from Scratch to Expert
 
TCP - IP Presentation
TCP - IP PresentationTCP - IP Presentation
TCP - IP Presentation
 
Tcp ip presentation
Tcp ip presentationTcp ip presentation
Tcp ip presentation
 
Beyond TCP: The evolution of Internet transport protocols
Beyond TCP: The evolution of Internet transport protocolsBeyond TCP: The evolution of Internet transport protocols
Beyond TCP: The evolution of Internet transport protocols
 
Chapter_3_v8.1.pdf
Chapter_3_v8.1.pdfChapter_3_v8.1.pdf
Chapter_3_v8.1.pdf
 
Jaimin chp-6 - transport layer- 2011 batch
Jaimin   chp-6 - transport layer- 2011 batchJaimin   chp-6 - transport layer- 2011 batch
Jaimin chp-6 - transport layer- 2011 batch
 
LECTURE-Transport-Layer_lec.ppt
LECTURE-Transport-Layer_lec.pptLECTURE-Transport-Layer_lec.ppt
LECTURE-Transport-Layer_lec.ppt
 
Transport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And DemultiplexingTransport Layer Services : Multiplexing And Demultiplexing
Transport Layer Services : Multiplexing And Demultiplexing
 
transport layer protocols
transport layer protocolstransport layer protocols
transport layer protocols
 
TCP_NISCHAYBAHL.pptx
TCP_NISCHAYBAHL.pptxTCP_NISCHAYBAHL.pptx
TCP_NISCHAYBAHL.pptx
 
Transport layer protocols : TCP and UDP
Transport layer protocols  : TCP and UDPTransport layer protocols  : TCP and UDP
Transport layer protocols : TCP and UDP
 
TRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptxTRANSPORT LAYER ppt.pptx
TRANSPORT LAYER ppt.pptx
 
Chapter3 transport
Chapter3 transportChapter3 transport
Chapter3 transport
 
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdf
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdfDCN 5th ed. slides ch24 Transport-Layer Protocols.pdf
DCN 5th ed. slides ch24 Transport-Layer Protocols.pdf
 
Transport layer services
Transport layer servicesTransport layer services
Transport layer services
 
Unit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptxUnit 4-Transport Layer Protocols-3.pptx
Unit 4-Transport Layer Protocols-3.pptx
 
Unit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptxUnit 4-Transport Layer Protocols.pptx
Unit 4-Transport Layer Protocols.pptx
 
3. transport layer
3. transport layer3. transport layer
3. transport layer
 

Recently uploaded

UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERUNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERDineshKumar4165
 
907MTAMount Coventry University Bachelor's Diploma in Engineering
907MTAMount Coventry University Bachelor's Diploma in Engineering907MTAMount Coventry University Bachelor's Diploma in Engineering
907MTAMount Coventry University Bachelor's Diploma in EngineeringFi sss
 
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样whjjkkk
 
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一F La
 
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一fjjwgk
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsMihajloManjak
 
What Causes DPF Failure In VW Golf Cars & How Can They Be Prevented
What Causes DPF Failure In VW Golf Cars & How Can They Be PreventedWhat Causes DPF Failure In VW Golf Cars & How Can They Be Prevented
What Causes DPF Failure In VW Golf Cars & How Can They Be PreventedAutobahn Automotive Service
 
Dubai Call Girls Services Call 09900000000
Dubai Call Girls Services Call 09900000000Dubai Call Girls Services Call 09900000000
Dubai Call Girls Services Call 09900000000Komal Khan
 
GREEN VEHICLES the kids picture show 2024
GREEN VEHICLES the kids picture show 2024GREEN VEHICLES the kids picture show 2024
GREEN VEHICLES the kids picture show 2024AHOhOops1
 
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...kexey39068
 
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样gfghbihg
 
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一ga6c6bdl
 
Call Girls in Karachi | +923081633338 | Karachi Call Girls
Call Girls in Karachi  | +923081633338 | Karachi Call GirlsCall Girls in Karachi  | +923081633338 | Karachi Call Girls
Call Girls in Karachi | +923081633338 | Karachi Call GirlsAyesha Khan
 
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualJohn Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualExcavator
 
What Could Cause A VW Tiguan's Radiator Fan To Stop Working
What Could Cause A VW Tiguan's Radiator Fan To Stop WorkingWhat Could Cause A VW Tiguan's Radiator Fan To Stop Working
What Could Cause A VW Tiguan's Radiator Fan To Stop WorkingEscondido German Auto
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...shivangimorya083
 
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂Hot Call Girls In Sector 58 (Noida)
 
call girls in G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in  G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in  G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGERUNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
UNIT-II-ENGINE AUXILIARY SYSTEMS &TURBOCHARGER
 
907MTAMount Coventry University Bachelor's Diploma in Engineering
907MTAMount Coventry University Bachelor's Diploma in Engineering907MTAMount Coventry University Bachelor's Diploma in Engineering
907MTAMount Coventry University Bachelor's Diploma in Engineering
 
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样
(办理学位证)墨尔本大学毕业证(Unimelb毕业证书)成绩单留信学历认证原版一模一样
 
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一
办理(PITT毕业证书)美国匹兹堡大学毕业证成绩单原版一比一
 
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一
如何办理(UC毕业证书)堪培拉大学毕业证毕业证成绩单原版一比一
 
Digamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and QualificationsDigamma - CertiCon Team Skills and Qualifications
Digamma - CertiCon Team Skills and Qualifications
 
What Causes DPF Failure In VW Golf Cars & How Can They Be Prevented
What Causes DPF Failure In VW Golf Cars & How Can They Be PreventedWhat Causes DPF Failure In VW Golf Cars & How Can They Be Prevented
What Causes DPF Failure In VW Golf Cars & How Can They Be Prevented
 
Dubai Call Girls Services Call 09900000000
Dubai Call Girls Services Call 09900000000Dubai Call Girls Services Call 09900000000
Dubai Call Girls Services Call 09900000000
 
GREEN VEHICLES the kids picture show 2024
GREEN VEHICLES the kids picture show 2024GREEN VEHICLES the kids picture show 2024
GREEN VEHICLES the kids picture show 2024
 
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...
Call Girl Service Global Village Dubai +971509430017 Independent Call Girls G...
 
sauth delhi call girls in Connaught Place🔝 9953056974 🔝 escort Service
sauth delhi call girls in  Connaught Place🔝 9953056974 🔝 escort Servicesauth delhi call girls in  Connaught Place🔝 9953056974 🔝 escort Service
sauth delhi call girls in Connaught Place🔝 9953056974 🔝 escort Service
 
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样
(办理学位证)(Toledo毕业证)托莱多大学毕业证成绩单修改留信学历认证原版一模一样
 
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Jama Masjid (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一
如何办理迈阿密大学毕业证(UM毕业证)成绩单留信学历认证原版一比一
 
Call Girls in Karachi | +923081633338 | Karachi Call Girls
Call Girls in Karachi  | +923081633338 | Karachi Call GirlsCall Girls in Karachi  | +923081633338 | Karachi Call Girls
Call Girls in Karachi | +923081633338 | Karachi Call Girls
 
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service ManualJohn Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
John Deere 300 3029 4039 4045 6059 6068 Engine Operation and Service Manual
 
What Could Cause A VW Tiguan's Radiator Fan To Stop Working
What Could Cause A VW Tiguan's Radiator Fan To Stop WorkingWhat Could Cause A VW Tiguan's Radiator Fan To Stop Working
What Could Cause A VW Tiguan's Radiator Fan To Stop Working
 
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...Russian  Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
Russian Call Girls Delhi Indirapuram {9711199171} Aarvi Gupta ✌️Independent ...
 
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
꧁༒☬ 7042364481 (Call Girl) In Dwarka Delhi Escort Service In Delhi Ncr☬༒꧂
 
call girls in G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in  G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in  G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in G.T.B. Nagar (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 

Chapter 3 - Transport Layer for VN Students

  • 1. FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh CHAPTER 3 TRANSPORT LAYER
  • 2. 2 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh OUTLINE 1. Transport Services & Protocols 2. Multiplexing & Demultiplexing 3. Principle of Reliable Data Transfer 4. UDP – Connectionless Transport 5. TCP – Connection-Oriented Transport 6. TCP Flow Control 7. TCP Congestion Control
  • 3. Faculty of Information Technology MSc. Nguyen Cong Danh 1. TRANSPORT SERVICES & PROTOCOLS
  • 4. 4 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh • Provide logical communication between app processes running on different hosts • Transport protocols run in end systems oSend side: breaks app messages into segments, passes to network layer oRcv side: reassembles segments into messages, passes to app layer • More than one transport protocol available to apps o Internet: TCP and UDP TRANSPORT SERVICES & PROTOCOLS
  • 5. 5 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh • Reliable, in-order delivery (TCP) ocongestion control oflow control oconnection setup • Unreliable, unordered delivery: UDP ono-frills extension of “best-effort” IP oprocess-to-process data delivery and error checking—are the only two services that UDP provides • Services not available for IP protocol: odelay guarantees obandwidth guarantees INTERNET TRANSPORT-LAYER PROTOCOLS
  • 6. 6 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP vs UDP more details… TCP service: • Reliable transport between sending and receiving process • Flow control: sender won’t overwhelm receiver • Congestion control: throttle sender when network overloaded • Does not provide: timing, minimum throughput guarantee, security • Connection-oriented: setup required between client and server processes UDP service: • Unreliable data transfer between sending and receiving process • Does not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, or connection setup,
  • 7. Faculty of Information Technology MSc. Nguyen Cong Danh 2. MULTIPLEXING & DEMULTIPLEXING
  • 8. 8 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh MULTIPLEXING/DEMULTIPLEXING Transport protocols (TCP, UDP) Network protocol (IP)
  • 9. 9 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh HOW DEMULTIPLEXING WORKS • Host receives IP packets oEach packet has source IP address, destination IP address oEach packet carries one transport- layer segment oEach segment has source, destination port number • Host uses IP addresses & port numbers to direct segment to appropriate socket TCP/UDP segment format Multiplexing = gathering data chunks at the source, encapsulating with header information, passing the segment to the network layer Demultiplexing = delivering the data in a transport-layer segment to the correct socket
  • 10. 10 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh COMMON PORTS
  • 11. 11 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh CONNECTIONLESS MULTIPLEXING & DEMULTIPLEXING DatagramSocket serverSocket = new DatagramSocket (6428); transport application physical link network P2 transport application physical link network P1 DatagramSocket mySocket2 = new DatagramSocket(9157); source port: 9157 dest port: 6428 source port: 6428 dest port: 9157 • UDP socket must be specified by: o destination IP address o destination port X • When host receives UDP segment: o checks destination port X in segment o directs UDP segment to socket with that port X IP datagrams with same dest. port X, but different source IP addresses and/or source port numbers will be directed to same socket at destination
  • 12. 12 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh CONNECTION-ORIENTED DEMUX • TCP socket identified by 4-tuple: osource IP address osource port number odest IP address odest port number • Demux: receiver uses all four values to direct segment to appropriate socket • Server host may support many simultaneous TCP sockets: oeach socket identified by its own 4-tuple • Web servers have different sockets for each connecting client onon-persistent HTTP will have different socket for each request
  • 13. 13 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh CONNECTION-ORIENTED DEMUX: EXAMPLE
  • 14. Faculty of Information Technology MSc. Nguyen Cong Danh 4. UDP – CONNECTIONLESS TRANSPORT
  • 15. 15 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh UDP: USER DATAGRAM PROTOCOL • “Best Effort” service, UDP segments may be: olost odelivered out-of-order to app • Connectionless: ono handshaking between UDP sender, receiver oeach UDP segment handled independently of others • UDP use: o streaming multimedia apps (loss tolerant, rate sensitive) o DNS o SNMP • Reliable transfer over UDP: o add reliability at application layer o application-specific error recovery!
  • 16. 16 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh WHY CHOSE UDP INSTEAD TCP? • Real-time applications require minimum delay • No connection establishment o No delay for connection establishment • No connection state o Support more active client • Small packet header overhead o TCP: 20 bytes/segment o UDP: 8 bytes/segment
  • 17. 17 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh UDP SEGMENT STRUCTURE source port # dest port # 32 bits application data (payload) UDP segment format length checksum length, in bytes of UDP segment, including header For error detection  Receiving host checks whether bits within the UDP segment have been altered
  • 18. 18 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh UDP CHECKSUM Goal: detect “errors” (e.g., flipped bits) in transmitted segment Sender: • Treat segment contents, including header fields, as sequence of 16-bit integers • Checksum: addition (one ’ s complement sum) of segment contents • Sender puts checksum value into UDP checksum field Receiver: • Compute checksum of received segment • Check if computed checksum equals checksum field value: oNO - error detected oYES - no error detected. But maybe errors nonetheless? More later …. UDP provides error checking  but does not do anything to recover from an error
  • 19. 19 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh INTERNET CHECKSUM: EXAMPLE Example: add two 16-bit integers 1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 wraparound sum checksum Note: when adding numbers, a carryout from the most significant bit needs to be added to the result
  • 20. Faculty of Information Technology MSc. Nguyen Cong Danh 5. TCP – CONNECTION- ORIENTED TRANSPORT
  • 21. 21 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP: TRANSMISSION CONTROL PROTOCOL • Point-to-point: oOne sender, one receiver • Reliable, in-order byte steam: oNo “message boundaries” • Pipelined: oTCP congestion and flow control set window size • Full duplex data: oBi-directional data flow in same connection oMSS: maximum segment size • Connection-oriented: oHandshaking (exchange of control msgs) inits sender, receiver state before data exchange • Flow controlled: oSender will not overwhelm receiver
  • 22. 22 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SEGMENT STRUCTURE source port # dest port # 32 bits application data (variable length) sequence number acknowledgement number receive window Urg data pointer checksum F S R P A U head len not used options (variable length) URG: urgent data (generally not used) ACK: ACK # valid PSH: push data now (generally not used) RST, SYN, FIN: connection estab (setup, teardown commands) # bytes rcvr willing to accept counting by bytes of data (not segments!) Internet checksum (as in UDP)
  • 23. 23 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SEQUENCE NUMBERS, ACKs • Sequence numbers: o Byte stream “number” of first byte in segment’s data • Acknowledgements: o Seq # of next byte expected from other side o Cumulative ACK Q: How receiver handles out-of-order segments? source port # dest port # sequence number acknowledgement number checksum rwnd urg pointer incoming segment to sender A sent ACKed sent, not- yet ACKed (“in- flight”) usable but not yet sent not usable window size N sender sequence number space source port # dest port # sequence number acknowledgement number checksum rwnd urg pointer Outgoing segment from sender
  • 24. 24 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh ESTABLISH TCP CONNECTION: TCP 3-WAY HANDSHAKE SYNbit=1, Seq=x choose init seq num, x send TCP SYN msg ESTAB SYNbit=1, Seq=y ACKbit=1; ACKnum=x+1 choose init seq num, y send TCP SYNACK msg, acking SYN ACKbit=1, ACKnum=y+1 received SYNACK(x) indicates server is live; send ACK for SYNACK; this segment may contain client-to-server data received ACK(y) indicates client is live SYNSENT ESTAB SYN RCVD client state LISTEN server state LISTEN
  • 25. 25 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP: CLOSING A CONNECTION FIN_WAIT_2 CLOSE_WAIT FINbit=1, seq=y ACKbit=1; ACKnum=y+1 ACKbit=1; ACKnum=x+1 wait for server close can still send data can no longer send data LAST_ACK CLOSED TIMED_WAIT timed wait for 2*max segment lifetime CLOSED FIN_WAIT_1 FINbit=1, seq=x can no longer send but can receive data clientSocket.close() client state server state ESTAB ESTAB
  • 26. 26 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh SUPPLEMENT 6: TCP vs UDP CONNECTIONS
  • 27. 27 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP RETRANSMISSION SCENARIOS lost ACK scenario Host B Host A Seq=92, 8 bytes of data ACK=100 Seq=92, 8 bytes of data X timeout ACK=100 premature timeout Host B Host A Seq=92, 8 bytes of data ACK=100 Seq=92, 8 bytes of data timeout ACK=120 Seq=100, 20 bytes of data ACK=120 SendBase=100 SendBase=120 SendBase=120 SendBase=92 SendBase=92 SendBase=100
  • 28. 28 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP RETRANSMISSION SCENARIOS X cumulative ACK Host B Host A Seq=92, 8 bytes of data ACK=100 Seq=120, 15 bytes of data timeout Seq=100, 20 bytes of data ACK=120 SendBase=92 SendBase=120
  • 29. 29 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh 3 DUPLICATE ACKs X fast retransmit after sender receipt of triple duplicate ACK Host B Host A Seq=92, 8 bytes of data ACK=100 timeout ACK=100 ACK=100 ACK=100 Seq=100, 20 bytes of data Seq=100, 20 bytes of data • When a duplicate ACK is received the sender does not know if it is because a TCP segment was lost or simply that a segment was delayed and received out of order at the receiver. • If more than two duplicate ACKs are received by the sender, it is a strong indication that at least one segment has been lost. • When three or more duplicate ACKs are received, the sender does not even wait for a re-transmission time to expire before re-transmitting the segment ( the sender enters the congestion avoidance mode).
  • 30. Faculty of Information Technology MSc. Nguyen Cong Danh 6. TCP FLOW CONTROL
  • 31. 31 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: Old data sent that has already been ACKed (Could as well be marked as free space) New data sent to transport layer by application, but not yet sent Free buffer space where application can write new data to be sent
  • 32. 32 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: Data that has been sent, but not ACKed Also called the Sending window This is the sliding window (yes, it slides!) This data can not be sent yet, as the sliding window in this example has a maximum size of 10
  • 33. 33 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: ACTION: An ACK of the oldest sent packet arrives • The window slides so that the left border is in line with the oldest outstanding ACK • The unsent segments that fit within the window are sent
  • 34. 34 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: • The data is placed in free buffer slots ACTION: The application has more data to send
  • 35. 35 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: • Older sent but un-ACKed segments are now considered to be ACKed ACTION: An ACK arrives in the middle of the window • The window slides and unsent segments within the window are sent • The window shrinks by one segment as there is no more than 9 segments outstanding
  • 36. 36 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: • The data is placed in free buffer slots ACTION: The application has more data to send • As the window is currently 9 segments wide, it can grow by one segment • The new data that fits within the window is sent
  • 37. 37 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP SLIDING WINDOW – SENDER SIDE Not sent Sent, no ACK ACKed Free Sending buffer at the sender: • The ACK is silently ignored ACTION: An ACK of already ACKed segments arrives
  • 38. 38 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP FLOW CONTROL application process TCP socket receiver buffers TCP code IP code application OS receiver protocol stack application may remove data from TCP socket buffers …. … slower than TCP receiver is delivering (sender is sending) from sender receiver controls sender, so sender won’t overflow receiver’s buffer by transmitting too much, too fast flow control The idea is that a node receiving data will send some kind of feedback to the node sending the data to let it know about its current condition.
  • 39. 39 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP FLOW CONTROL • Receiver “advertises” free buffer space by including rwnd value in TCP header of receiver-to-sender segments (aka. in ACK) oRcvBuffer is the receive buffer. It’s size set via socket options (typical default is 4096 bytes) oMany operating systems auto adjust RcvBuffer • Sender limits amount of unacked (“in-flight”) data sent to receiver based on the rwnd value • Guarantees receive buffer will not overflow buffered data free buffer space rwnd RcvBuffer TCP segment payloads to application process receiver-side buffering TCP provides flow control by having the sender maintain a variable called the receive window (rwnd).
  • 40. Faculty of Information Technology MSc. Nguyen Cong Danh 7. TCP CONGESTION CONTROL
  • 41. 41 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh INTRODUCTION TO CONGESTION CONTROL Congestion: • Informally: “too many sources sending too much data too fast for network to handle” • Different from flow control! • Manifestations: oLost packets (buffer overflow at routers) oLong delays (queueing in router buffers) TCP Congestion Control: • Basic idea: each source determines how much capacity is available to a given flow in the network.  Each sender limits the rate! oRaises 3 questions: - How does TCP limit the rate? - How does TCP sender perceive that there is congestion on the path? - What algorithm should the sender use to change ites send rate? • ACKs are used to “pace” the transmission of packets such that TCP is “self-clocking”
  • 42. 42 FACULTY OF INFORMATION TECHNOLOGY MSc. Nguyen Cong Danh TCP CONGESTION CONTROL ALGORITHMS • Some TCP congestion Control algorithms: o Tahoe  Slow Start  Congestion Avoidance  Fast Retransmit o Reno  Fast Recovery o Vegas  New Congestion Avoidance o RED o REM o SACK o FACK… Slow Start Congestion Avoidance Fast Retransmit/ Fast Recovery

Editor's Notes

  1. our goals: understand principles behind transport layer services: multiplexing, demultiplexing reliable data transfer flow control congestion control learn about Internet transport layer protocols: UDP: connectionless transport TCP: connection-oriented reliable transport TCP congestion control
  2. Sau này học đến Network Layer sẽ có sự phân biệt như sau: - network layer: logical communication between hosts - transport layer: logical communication between processes Logical communication có nghĩa là các hosts có các processes đang chạy trên đó có vẻ như là kết nối trực tiếp với nhau nhưng thực chất là chúng được kết nối thông qua hang loạt thiết bị mạng như routers và links… Application processes không quan tâm đến cơ sở hạ tầng mạng bên dưới hoặc làm cách nào mà message đến được đích, chúng chỉ cần biết là transport layer cung cấp các dịch vụ để gửi message đi. It’s important to note that network routers act only on the network-layer fields of the datagram; that is, they do not examine the fields of the transport-layer segment encapsulated.
  3. No-frills: không rườm rà Recall IP protocol: + IP provides logical communication between hosts. + An unreliable service (best-effort delivery service) (it does not guarantee segment delivery, it does not guarantee orderly delivery of segments, and it does not guarantee the integrity of the data in the segments)
  4. Each port number is a 16-bit number, ranging from 0 to 65535. The port numbers ranging from 0 to 1023 are called well-known port numbers and are restricted,
  5. When a UDP socket is created  trans. layer automatically assigns a port number to the socket In particular, the transport layer assigns a port number in the range 1024 to 65535 that is currently not being used by any other UDP port in the host. (Chúng ta có thể tự gán port cho socket được tạo ra bằng bind() method: clientSocket.bind((‘ ‘, 19157)) Thông thường client side của application để cho trans. Layer tự động gán port number, trong khi phía server side thì gán một port number cụ thể từ trước. QUAN TRỌNG: một UDP socket được xác định một cách đầy đủ bởi 2 yếu tố: destination IP address & destination port number. Tức là, nếu 2 UDP segments có địa chỉ nguồn khác nhau và port number nguồn khác hoặc giống nhau, nhưng nếu có chung địa chỉ IP đích và port đích thì 2 segments đó sẽ được chuyển đến cùng một tiến trinh đích thông qua destination socket. Khi đó source IP và source port chỉ dùng với mục đích là return address.
  6. https://tools.ietf.org/html/rfc768 we mention that it is possible for an application to have reliable data transfer when using UDP. This can be done if reliability is built into the application itself (for example, by adding acknowledgment and retransmission mechanisms
  7. TCP will also continue to resend a segment until the receipt of the segment has been acknowledged by the destination, regardless of how long reliable delivery takes. TCP maintains connection state in the end systems. This connection state includes receive and send buffers, congestion-control parameters, and sequence and acknowledgment number parameters.  UDP, on the other hand, does not maintain connection state and does not track any of these parameters  server devoted to a particular application can typically support many more active clients
  8. UDP Header: 8 bytes The UDP header has only four fields, each consisting of two bytes. The UDP checksum provides for error detection.
  9. Sender: - Chia contents ra làm các chuỗi 16 bits liên tiếp nhau. Thực hiện 1s complement của tổng tất cả các chuỗi 16bits trong segment Kết quả thu được được đặt trong checksum field of the UDP segment. The 1s complement is obtained by converting all the 0s to 1s and converting all the 1s to 0s. At the receiver, all four 16-bit words are added, including the checksum. If no errors are introduced into the packet, then clearly the sum at the receiver will be 1111111111111111. If one of the bits is a 0, then we know that errors have been introduced into the packet. You may wonder why UDP provides a checksum in the first place, as many link-layer protocols (including the popular Ethernet protocol) also provide error checking. The reason is that there is no guarantee that all the links between source and destination provide error checking. Furthermore, even if segments are correctly transferred across a link, it’s possible that bit errors could be introduced when a segment is stored in a router’s memory.
  10. RFC 1122, RFC 2581
  11. Flow controlled nghĩa là sender sẽ giới hạn sending speed để chắc chắn là receiver không bị quá tải. Congestion control khá giống với flow control, tuy nhiên sender giới hạn sending speed tùy thuộc vào điều kiện của network.
  12. TCP Header: 20 - 60 bytes. (20 bytes is the most common) The 32-bit sequence number field and the 32-bit acknowledgment number field are used by the TCP sender and receiver in implementing a reliable data transfer service, The 16-bit receive window field is used for flow control. The 4-bit header length field specifies the length of the TCP header in 32-bit words. The TCP header can be of variable length due to the TCP options field.
  13. Two of the most important fields in the TCP segment header are the sequence number field and the acknowledgment number field. Recall that TCP is full-duplex, so that Host A may be receiving data from Host B while it sends data to Host B. The acknowledgment number that Host A puts in its segment is the sequence number of the next byte Host A is expecting from Host B. Because TCP only acknowledges bytes up to the first missing byte in the stream, TCP is said to provide cumulative acknowledgments The subtle issue is: What does a host do when it receives out-of-order segments in a TCP connection? There are basically two choices: either (1) the receiver immediately discards out-of-order segments (which, as we discussed earlier, can simplify receiver design) (2) the receiver keeps the out-of-order bytes and waits for the missing bytes to fill in the gaps. Clearly, the latter choice is more efficient in terms of network bandwidth, and is the approach taken in practice.
  14. RFC 1122, RFC 2581
  15. Animation: https://www.youtube.com/watch?v=zY3Sxvj8kZA&ab_channel=KhurramTanvir Một số vấn đề quan trọng đối với Sliding window – sender side: Must keep track of outstanding data  Data sent, but not ACKed Must not exceed maximum window size  Configuration parameter; Affects memory consumption Must adjust window size when:  An ACK inside the window arrives; New data that can fit within window arrives from application
  16. It’s important to understand that this is not the same as Congestion Control. Although there’s some overlap between the mechanisms TCP uses to provide both services, they are distinct features. Congestion control is about preventing a node from overwhelming the network (i.e. the links between two nodes), while Flow Control is about the end-node.
  17. the receive window is used to give the sender an idea of how much free buffer space is available at the receiver. Simply put, it is a TCP receive buffer for incoming data that has not been processed yet by the application. The size of the TCP Receive Window is communicated to the connection partner using the window size value field of the TCP header. This field tells the link partner how much data can be sent on the wire before an acknowledgment is received. If the receiver is not able to process the data as fast as it arrives, gradually the receive buffer will fill and the TCP window will be reduced in the acknowledgment packets. This will alert the sender that it needs to reduce the amount of data sent or allow the receiver time to clear the buffer. https://www.brianstorti.com/tcp-flow-control/
  18. Một số định nghĩa quan trọng: SEGMENT: A segment is ANY TCP/IP data or acknowledgment packet (or both). MAXIMUM SEGMENT SIZE (MSS): The MSS is the size of the largest segment that the sender can transmit.