Transport Layer Our goals: r understand principles behind transport layer services: m...
143
Transport Layer Our goals: understand principles behind transport layer services: multiplexing/ demultiplexing reliable data transfer flow control congestion control learn about transport layer protocols in the Internet: UDP: connectionless transport TCP: connection- oriented transport TCP congestion control
Transport Layer Our goals: r understand principles behind transport layer services: m multiplexing/demultipl exing m reliable data transfer m flow control
Transport Layer Our goals: r understand principles behind
transport layer services: m multiplexing/demultipl exing m reliable
data transfer m flow control m congestion control r learn about
transport layer protocols in the Internet: m UDP: connectionless
transport m TCP: connection-oriented transport m TCP congestion
control
Slide 3
Transport Layer Topics r Review: multiplexing, connection and
connectionless transport, services provided by a transport layer r
UDP r Reliable transport m Tools for reliable transport layer Error
detection, ACK/NACK, ARQ m Approaches to reliable transport
Go-Back-N Selective repeat m TCP Services TCP: Connection setup,
acks and seq num, timeout and triple-dup ack, slow-start,
congestion avoidance.
Slide 4
Transport Layer application transport network link physical
application transport network link physical application transport
network link physical application transport network link physical
application transport network link physical application transport
network link physical Web Browser App Google Server App Transport
Key transport layer service: Send messages between Apps Just
specify the destination and the message and thats it messages
Network Key service the transport layer requires: Network should
attempt to deliver segements.
Slide 5
Transport layer r Transfers messages between application in
hosts m For ftp you exchange files and directory information. m For
http you exchange requests and replies/files m For smtp messages
are exchanged r Services possibly provided m Reliability m Error
detection/correction m Flow/congestion control m Multiplexing
(support several messages being transported simultaneously)
Slide 6
Connection oriented / connectionless r TCP supports the idea of
a connection m Once listen and connect complete, there is a logical
connection between the hosts. m One can determine if the message
was sent r UDP is connectionless m Packets are just sent. There is
no concept (supported by the transport layer) of a connection m But
the application can make a connection over UDP. So the application
is each host will support the hand-shaking and monitoring the state
of the connection. r There are other transport layer protocols such
as SCTP besides TCP and UDP, but TCP and UDP are the most
popular
Slide 7
TCP vs. UDP r Connection oriented m Connections must be set up
m The state of the connection can be determined r Flow/congestion
control m Limits congestion in the network and end hosts m Control
how fast data can be sent r Larger Packet header r Automatically
retransmits lost packets and reports if the message was not
successfully transmitted r Check sum for error detection r
Connectionless m Connections do not need to be set-up m No feedback
provided as to whether packets were successfully delivered r No
flow/congestion control m Could cause excessive congestion and
unfair usage m Data can be sent exactly when it needs to be r Low
overhead r Check sum for error detection
Slide 8
Applications and Transport Protocols ApplicationTCP or UDP?
SMTP Telnet HTTP FTP Multimedia streaming via youtude VoIP via
Skype DNSUDP TCP NFSTCP or UDP
Slide 9
Multiplexing with ports Client IP:B P1 client IP: A P1P2P4
server IP: C SP: 9157 DP: 80 SP: 9157 DP: 80 P5P6P3 D-IP:C S-IP: A
D-IP:C S-IP: B SP: 5775 DP: 80 D-IP:C S-IP: B Transport layer
packet headers always contain source and destination port IP
headers have source and destination IPs When a message is sent, the
destination port must be known. However, the source port could be
selected by the OS. App Transport Network TCP
Slide 10
About multiplexing HTTP usually has port 80 as the destination,
but you can make a web server listen on any port that is not
already used by another application ICANN registered ports (0-1024)
HTTP: 80 HTTP over SSL: 443 FTP: 21 Telnet: 23 DNS: 53 Microsoft
server: 3389 Typically, only one application can listen on a port
at a time (tools such as PCAP can be used to listen on ports that
are already in use. Wireshark uses PCAP) For TCP, you cannot
control the source port; the OS sets it. For UDP, you can set the
source port. A connection is defined as a 5 tuple: source IP,
source port, destination IP, and destination port, and transport
protocol. NATs make use to these five pieces of information. NATs
are discussed in detail in Chapter 4, but they are dependent on
transport layer Since connections are defined by ports and
addresses, there cross layer dependencies (the transport layer
cannot demultiplex without knowledge of the IP addresses, with is a
concept of a different layer.)
Slide 11
Chapter 3 outline r 3.1 Transport-layer services r 3.2
Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP
r 3.4 Principles of reliable data transfer r 3.5
Connection-oriented transport: TCP m segment structure m reliable
data transfer m flow control m connection management r 3.6
Principles of congestion control r 3.7 TCP congestion control
Slide 12
UDP: User Datagram Protocol [RFC 768] r no frills, bare bones
Internet transport protocol r best effort service, UDP segments may
be: m lost m delivered out of order to app r connectionless: m no
handshaking between UDP sender, receiver m each UDP segment handled
independently of others Why is there a UDP? r no connection
establishment (which can add delay) r simple: no connection state
at sender, receiver r small segment header r no congestion control:
UDP can blast away as fast as desired
Slide 13
UDP: more r often used for streaming multimedia apps m loss
tolerant m rate sensitive r other UDP uses m DNS m SNMP r reliable
transfer over UDP: add reliability at application layer m
application-specific error recovery! source port #dest port # 32
bits Application data (message) UDP segment format length checksum
Length, in bytes of UDP segment, including header
Slide 14
UDP checksum Sender: r treat segment contents as sequence of
16-bit integers r checksum: addition (1s complement sum) of segment
contents r sender puts checksum value into UDP checksum field
Receiver: r compute checksum of received segment r check if
computed checksum equals checksum field value: m NO - error
detected m YES - no error detected. But maybe errors nonetheless?
More later . Goal: detect errors (e.g., flipped bits) in
transmitted segment
Slide 15
Internet Checksum Example r Note m When adding numbers, a
carryout from the most significant bit needs to be added to the
result r Example: add two 16-bit integers 1 1 1 1 0 0 1 1 0 0 1 1 0
0 1 1 0 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1
1 0 1 1 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 1 0 1 0 0 0 1 0 0 0 1 0 0
0 0 1 1 wraparound sum checksum
Slide 16
Chapter 3 outline r 3.1 Transport-layer services r 3.2
Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP
r 3.4 Principles of reliable data transfer r 3.5
Connection-oriented transport: TCP m segment structure m reliable
data transfer m flow control m connection management r 3.6
Principles of congestion control r 3.7 TCP congestion control
Slide 17
Principles of reliable data transfer
Slide 18
Principles of Reliable data transfer
Slide 19
Principles of reliable data transfer
Slide 20
Reliable data transfer: getting started send side receive side
rdt_send(): called from above, (e.g., by app.). Passed data to
deliver to receiver upper layer udt_send(): called by rdt, to
transfer packet over unreliable channel to receiver rdt_rcv():
called when packet arrives on rcv-side of channel deliver_data():
called by rdt to deliver data to upper
Slide 21
Application implemented reliable data transfer Main App UDP
communication Application Main App communication Application UDP
reliable channel unreliable channel Application Layer Transport
Layer Pros and cons of implementing a reliable transport protocol
in the application Cons -It is already done by the OS, why reinvent
the wheel. -The OS might have higher priority than the application.
Pros -The OSs TCP is designed to work in every scenario, but your
app might only exist in specific scenarios -Network storage device
-Mobile phone -Cloud app
Slide 22
Reliable data transfer: getting started Well: r incrementally
develop sender, receiver sides of reliable data transfer protocol
(rdt) r consider only unidirectional data transfer m but control
info will flow on both directions! r use finite state machines
(FSM) to specify sender, receiver state 1 state 2 event causing
state transition actions taken on state transition state: when in
this state next state uniquely determined by next event event
actions
Slide 23
Rdt1.0: reliable transfer over a reliable channel r Assume that
the underlying channel is perfectly reliable m no bit errors m no
loss of packets r Make separate FSMs for sender, receiver: m sender
sends data into underlying channel m receiver read data from
underlying channel segment = make_pkt(data) udt_send(segment) Wait
for call from above rdt_send(data) sender data = extract (segment)
deliver_data(data) Wait for call from below rdt_rcv(segment)
receiver
Slide 24
Rdt2.0: channel with bit errors r underlying channel may flip
bits in packets m checksum to detect bit errors r the question: how
to recover from errors: m negative acknowledgements (NAKs):
receiver explicitly tells sender that pkt had errors sender
retransmits pkt on receipt of NAK m acknowledgements (ACKs):
receiver explicitly tells sender that pkt received OK new
mechanisms in rdt2.0 (beyond rdt1.0 ): m error detection m receiver
feedback: control msgs (ACK,NAK) rcvr->sender
Slide 25
rdt2.0: FSM specification Wait for call from above snkpkt =
make_pkt(data, checksum) udt_send(sndpkt) extract(rcvpkt,data)
deliver_data(data) udt_send(ACK) rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) Wait for ACK or NAK Wait for call from below
sender receiver rdt_send(data)
Slide 26
rdt2.0: FSM specification Wait for call from above snkpkt =
make_pkt(data, checksum) udt_send(sndpkt) data = extract(rcvpkt)
deliver_data(data) udt_send(ACK) rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt) Wait
for ACK or NAK Wait for call from below sender receiver
rdt_send(data)
Slide 27
rdt2.0: FSM specification Wait for call from above snkpkt =
make_pkt(data, checksum) udt_send(sndpkt) data = extract(rcvpkt)
deliver_data(data) udt_send(ACK) rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) rdt_rcv(rcvpkt) && isACK(rcvpkt)
udt_send(sndpkt) rdt_rcv(rcvpkt) && isNAK(rcvpkt)
udt_send(NAK) rdt_rcv(rcvpkt) && corrupt(rcvpkt) Wait for
ACK or NAK Wait for call from below sender receiver
rdt_send(data)
Slide 28
rdt2.0 has a fatal flaw! What happens if ACK/NAK corrupted? r
sender doesnt know what happened at receiver! r cant just
retransmit: possible duplicate Handling duplicates: r sender
retransmits current pkt if ACK/NAK garbled r sender adds sequence
number to each pkt r receiver discards (doesnt deliver up)
duplicate pkt Sender sends one packet, then waits for receiver
response stop and wait
Slide 29
rdt2.1: sender, handles garbled ACK/NAKs Wait for call 0 from
above sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt)
rdt_send(data) Wait for ACK or NAK 0 udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || isNAK(rcvpkt) )
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) &&
isACK(rcvpkt) Wait for call 1 from above sndpkt = make_pkt(1, data,
checksum) udt_send(sndpkt) rdt_send(data) udt_send(sndpkt)
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isNAK(rcvpkt) )
rdt_rcv(rcvpkt) && notcorrupt(rcvpkt) &&
isACK(rcvpkt) Wait for ACK or NAK 1
Slide 30
extract(rcvpkt,data) deliver_data(data) sndpkt = make_pkt(ACK,
chksum) udt_send(sndpkt) rdt2.1: receiver, handles garbled ACK/NAKs
Wait for 0 from below Wait for 1 from below rdt_rcv(rcvpkt)
&& !corrupt(rcvpkt) && has_seq0(rcvpkt)
rdt2.1: discussion Sender: r seq # added to pkt r two seq. #s
(0,1) will suffice. Why? r must check if received ACK/NAK corrupted
r twice as many states m state must remember whether current pkt
has 0 or 1 seq. # Receiver: r must check if received packet is
duplicate m state indicates whether 0 or 1 is expected pkt seq # r
note: receiver can not know if its last ACK/NAK received OK at
sender
Slide 36
rdt2.2: a NAK-free protocol r same functionality as rdt2.1,
using ACKs only r instead of NAK, receiver sends ACK for last pkt
received OK m receiver must explicitly include seq # of pkt being
ACKed r duplicate ACK at sender results in same action as NAK:
retransmit current pkt
Slide 37
rdt2.2: sender, receiver fragments Wait for call 0 from above
sndpkt = make_pkt(0, data, checksum) udt_send(sndpkt)
rdt_send(data) udt_send(sndpkt) rdt_rcv(rcvpkt) && (
corrupt(rcvpkt) || isACK(rcvpkt,1) ) rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) && isACK(rcvpkt,0) Wait for ACK 0 sender
FSM fragment Wait for 0 from below rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) && has_seq1(rcvpkt) extract(rcvpkt,data)
deliver_data(data) sndpkt = make_pkt(ACK1, chksum) udt_send(sndpkt)
rdt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq1(rcvpkt))
udt_send(sndpkt) receiver FSM fragment What happens if a pkt is
duplicated?
Slide 38
rdt3.0: channels with errors and loss New assumption:
underlying channel can also lose packets (data or ACKs) m checksum,
seq. #, ACKs, retransmissions will be of help, but not enough
Approach: sender waits reasonable amount of time for ACK r
retransmits if no ACK received in this time r if pkt (or ACK) just
delayed (not lost): m retransmission will be duplicate, but use of
seq. #s already handles this m receiver must specify seq # of pkt
being ACKed r requires countdown timer
Slide 39
stop_timer rdt3.0 sender sndpkt = make_pkt(0, data, checksum)
udt_send(sndpkt) start_timer rdt_send(data) Wait for ACK0
rdt_rcv(rcvpkt) && ( corrupt(rcvpkt) || isACK(rcvpkt,1) )
Wait for call 1 from above rdt_rcv(rcvpkt) &&
notcorrupt(rcvpkt) && isACK(rcvpkt,0) udt_send(sndpkt)
start_timer timeout Wait for call 0from above
Performance of rdt3.0 r rdt3.0 works, but performance stinks r
ex: 1 Gbps link, 15 ms prop. delay, 8000 bit packet and 100bit ACK:
m What is the total delay Data transmission delay 8000/10 9 = 8 10
-6 ACK Transmission delay 100/10 9 = 10 -7 sec Total Delay 2 15ms
+.008 +.0001=30.0081ms r Utilization m Time transmitting / total
time m.008 / 30.0081 = 0.00027 r This is one pkt every 30msec or 33
kB/sec over a 1 Gbps link!
Slide 45
rdt3.0: stop-and-wait operation first packet bit transmitted, t
= 0 senderreceiver RTT last packet bit transmitted, t = L / R first
packet bit arrives last packet bit arrives, send ACK ACK arrives,
send next packet, t = RTT + L / R
Slide 46
Pipelined protocols Pipelining: sender allows multiple,
in-flight, yet-to- be-acknowledged pkts m range of sequence numbers
must be increased m buffering at sender and/or receiver r Two
generic forms of pipelined protocols: go-Back-N, selective
repeat
Slide 47
Pipelining: increased utilization first packet bit transmitted,
t = 0 senderreceiver RTT last bit transmitted, t = L / R first
packet bit arrives last packet bit arrives, send ACK ACK arrives,
send next packet, t = RTT + L / R last bit of 2 nd packet arrives,
send ACK last bit of 3 rd packet arrives, send ACK Increase
utilization by a factor of 3!
Slide 48
Pipelining Protocols Go-back-N: big pic r Sender can have up to
N unacked packets in pipeline r Rcvr only sends cumulative acks m
Doesnt ack packet if theres a gap r Sender has timer for oldest
unacked packet m If timer expires, retransmit all unacked packets
Selective Repeat: big pic r Sender can have up to N unacked packets
in pipeline r Rcvr acks individual packets r Sender maintains timer
for each unacked packet m When timer expires, retransmit only unack
packet
Slide 49
Go-Back-N Sender: r k-bit seq # in pkt header r window of up to
N, unacked pkts allowed r ACK(n): ACKs all pkts up to, including
seq # n - cumulative ACK m may receive duplicate ACKs (see
receiver) r timer for each in-flight pkt r timeout(n): retransmit
pkt n and all higher seq # pkts in window
Slide 50
Go-Back-N Pkt that could be sent unACKed pkt Unused pkt ACKed
pkt send pkt window 1 unACKed pkts start window N=12 0 unACKed pkts
pkts send pkts window N unACKed pkts Next pkt to be sent ACK
arrives window N=12 Send pkt N unACKed pkts window N-1 unACKed pkts
Sliding window State of pkts
Slide 51
Go-Back-N Pkt that could be sent unACKed pkt Unused pkt ACKed
pkt window N unACKed pkts window N-1 unACKed pkts ACK arrives Send
pkt N unACKed pkts window N unACKed pkts window No ACK arrives .
timeout 0 unACKed pkts window
Slide 52
Go-Back-N base
Slide 53
GBN: sender extended FSM Wait rdt_send(data) if (nextseqnum
< base+N) { sndpkt[nextseqnum] =
make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum])
startTimer(nextseqnum) nextseqnum++ } else refuse_data(data) for i
= base to getacknum(rcvpkt) { stop_timer(i) } base =
getacknum(rcvpkt)+1 rdt_rcv(rcvpkt) && !corrupt(rcvpkt)
base=1 nextseqnum=1 start
Slide 54
base GBN: sender extended FSM Wait udt_send(sndpkt[base])
startTimer(base) udt_send(sndpkt[base+1]) startTimer(base+1)
udt_send(sndpkt[nextseqnum-1]) startTimer(nextseqnum-1) timeout
rdt_send(data) if (nextseqnum < base+N) { sndpkt[nextseqnum] =
make_pkt(nextseqnum,data,chksum) udt_send(sndpkt[nextseqnum])
startTimer(nextseqnum) nextseqnum++ } else refuse_data(data) for i
= base to getacknum(rcvpkt)+1 { stop_timer(i) } base =
getacknum(rcvpkt)+1 rdt_rcv(rcvpkt) && !corrupt(rcvpkt)
base=1 nextseqnum=1 rdt_rcv(rcvpkt) && corrupt(rcvpkt)
start
Slide 55
GBN: receiver extended FSM CumACK-only: always send ACK for
correctly-received pkt with highest in-order seq # m may generate
duplicate ACKs need only remember expectedSeqNum r out-of-order
pkt: m discard (dont buffer) -> no receiver buffering! m Re-ACK
pkt with highest in-order seq # Wait sndpkt =
make_pkt(expectedSeqNum,-1ACK,chksum) udt_send(sndpkt)
rdt_rcv(rcvpkt) && (currupt(rcvpkt) ||
seqNum(rcvpkt)!=expectedSeqNum) rdt_rcv(rcvpkt) &&
!currupt(rcvpkt) && seqNum(rcvpkt)==expectedSeqNum
extract(rcvpkt,data) deliver_data(data) sndpkt =
make_pkt(expectedSeqNum,ACK,chksum) udt_send(sndpkt)
expectedSeqNum++ expectedSeqNum=1 start up expectedSeqNum Received
!Received
Slide 56
GBN: sender extended Activity Diagram
Slide 57
GBN: Receiver Activity Diagram
Slide 58
GBN: sender extended Activity Diagram Waiting for file Set N
Set NextPktToSend=0 Set LastACKed=-1 NextPktToSend LastACKed
GBN: receiver extended FSM ACK-only: always send ACK for
correctly-received pkt with highest in-order seq # m may generate
duplicate ACKs need only remember expectedseqnum r out-of-order
pkt: m discard (dont buffer) -> no receiver buffering! m Re-ACK
pkt with highest in-order seq # Wait udt_send(sndpkt) default
rdt_rcv(rcvpkt) && notcurrupt(rcvpkt) &&
hasseqnum(rcvpkt,expectedseqnum) extract(rcvpkt,data)
deliver_data(data) sndpkt = make_pkt(expectedseqnum,ACK,chksum)
udt_send(sndpkt) expectedseqnum++ expectedseqnum=1 sndpkt =
make_pkt(expectedseqnum,ACK,chksum)
Slide 62
GBN in Action sender receiver Send pkt0 Send pkt2 Send pkt3
Send pkt4 Send pkt5 Send pkt6 Send pkt7 Send pkt8 Send pkt9 TO Send
pkt6 Send pkt7 Send pkt8 Send pkt9 Rec 0, give to app, and Send
ACK=0 Rec 1, give to app, and Send ACK=1 Rec 2, give to app, and
Send ACK=2 Rec 3, give to app, and Send ACK=3 Rec 4, give to app,
and Send ACK=4 Rec 5, give to app, and Send ACK=5 Rec 7, discard,
and Send ACK=5 Rec 8, discard, and Send ACK=5 Rec 9, discard, and
Send ACK=5 Rec 6, give to app,. and Send ACK=6 Rec 7, give to app,.
and Send ACK=7 Rec 8, give to app,. and Send ACK=8 Rec 9, give to
app,. and Send ACK=9 Send pkt1
Slide 63
Optimal size of N in GBN (or selective repeat) sender receiver
Send pkt0 Send pkt2 Send pkt3 Send pkt4 Send pkt5 Send pkt6 Send
pkt7 RTT Send pkt1
Slide 64
Optimal size of N in GBN (or selective repeat) sender receiver
Send pkt0 Send pkt2 Send pkt3 RTT Send pkt1 Q: How large should N
be? A: Large enough so that the transmitter is constantly
transmitting. How many pkts can be transmitted before the first ACK
arrives? == How many pkts can be transmitter in one RTT? N = RTT /
(L*R) This is only a first crack at the size of N: What if there
are other data transfers sharing the link? What if the receiver has
a slower link than the transmitter? What if some intermediate link
is the slowest? senderreceiver 1Gbps1Mbps sender 1Gbps1Mbps
receiver 1Gbps
Slide 65
Selective Repeat r receiver individually acknowledges all
correctly received pkts m buffers pkts, as needed, for eventual
in-order delivery to upper layer r sender only resends pkts for
which ACK is not received m sender timer for each unACKed pkt r
sender window m N consecutive seq #s m again limits seq #s of sent,
unACKed pkts
Slide 66
Selective repeat in action Pkt that could be sent unACKed pkt
Unused pkt ACKed pkt State of pkts Window N=6 Window N=6 Delivered
to app Window N=6 Window N=6 Window N=6 Window N=6 Window N=6
Window N=6 ACKed + Buffered
Slide 67
Selective repeat in action Pkt that could be sent unACKed pkt
Unused pkt ACKed pkt State of pkts Window N=6 Delivered to app
Window N=6 Window N=6 Window N=6 Window N=6 Window N=6 Window N=6
Window N=6 ACKed + Buffered
Slide 68
Selective repeat in action Pkt that could be sent unACKed pkt
Unused pkt ACKed pkt State of pkts Window N=6 Delivered to app
Window N=6 ACKed + Buffered Window N=6 Window N=6
Slide 69
Selective repeat in action Pkt that could be sent unACKed pkt
Unused pkt ACKed pkt State of pkts Delivered to app ACKed +
Buffered Window N=6 Window N=6 TO Window N=6 Window N=6
Slide 70
Selective repeat data from above : r if next available seq # in
window, send pkt timeout(n): r resend pkt n, restart timer ACK(n)
in [sendbase,sendbase+N]: r mark pkt n as received r if n smallest
unACKed pkt, advance window base to next unACKed seq # sender pkt n
in [rcvbase, rcvbase+N-1] r send ACK(n) r out-of-order: buffer r
in-order: deliver (also deliver buffered, in-order pkts), advance
window to next not-yet-received pkt pkt n in [rcvbase-N,rcvbase-1]
r ACK(n) otherwise: r ignore receiver Window N=6 Window N=6
sendbase rcvbase
Slide 71
Summary of transport layer tools used so far r ACK and NACK r
Sequence numbers (and no NACK) r Time out r Sliding window m
Optimal size = ? r Cumulative ACK m Buffer at the receiver is
optional r Selective ACK m Requires buffering at the receiver
Slide 72
Chapter 3 outline r 3.1 Transport-layer services r 3.2
Multiplexing and demultiplexing r 3.3 Connectionless transport: UDP
r 3.4 Principles of reliable data transfer r 3.5
Connection-oriented transport: TCP m segment structure m reliable
data transfer m flow control m connection management r 3.6
Principles of congestion control r 3.7 TCP congestion control
Slide 73
TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581 r full duplex
data: m bi-directional data flow in same connection m MSS: maximum
segment size r connection-oriented: m handshaking (exchange of
control msgs) inits sender, receiver state before data exchange r
flow controlled: m sender will not overwhelm receiver r
point-to-point: m one sender, one receiver r reliable, in-order
byte steam: r Pipelined and time- varying window size: m TCP
congestion and flow control set window size r send & receive
buffers
Slide 74
TCP segment structure source port # dest port # 32 bits
application data (variable length) sequence number acknowledgement
number Receive window Urg data pnter checksum F SR PAU 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) Internet
checksum (as in UDP) # bytes rcvr willing to accept counting by
bytes of data (not segments!)
Slide 75
TCP seq. #s and ACKs Seq. #s: m byte stream number of first
byte in segments data m It can be used as a pointer for placing the
received data in the receiver buffer ACKs: m seq # of next byte
expected from other side m cumulative ACK Host A Host B Seq=42,
ACK=79, data = C Seq=79, ACK=43, data = C Seq=43, ACK=80 User types
C host ACKs receipt of echoed C host ACKs receipt of C, echoes back
C time simple telnet scenario
Slide 76
Seq no and ACKs 110108 HELLO WORLD 101102103104105106107109111
Byte numbers Seq no: 101 ACK no: 12 Data: HEL Length: 3 Seq no: 12
ACK no: Data: Length: 0 Seq no: 104 ACK no: 12 Data: LO W Length: 4
Seq no: 12 ACK no: Data: Length: 0 104 108
Slide 77
Seq no and ACKs - bidirectional 110108 HELLO WORLD
101102103104105106107109111 Byte numbers GOODB UY 12131415161718
Seq no: 101 ACK no: 12 Data: HEL Length: 3 Seq no: ACK no: Data:
GOOD Length: 4 Seq no: ACK no: Data: LO W Length: 4 Seq no: ACK no:
Data: BU Length: 2 12 104 16 108 16
Slide 78
TCP Round Trip Time and Timeout Q: how to set TCP timeout value
(RTO)? r If RTO is too short: premature timeout m unnecessary
retransmissions r If RTO is too long: m slow reaction to segment
loss r Can RTT be used? m No, RTT varies, there is no single RTT m
Why does RTT varying? Because statistical multiplexing results in
queuing r How about using the average RTT? m The average is too
small, since half of the RTTs are larger the average Q: how to
estimate RTT? SampleRTT : measured time from segment transmission
until ACK receipt m ignore retransmissions SampleRTT will vary,
want estimated RTT smoother average several recent measurements,
not just current SampleRTT
Slide 79
TCP Round Trip Time and Timeout EstimatedRTT = (1-
)*EstimatedRTT + *SampleRTT r Exponential weighted moving average r
influence of past sample decreases exponentially fast typical
value: = 0.125
Slide 80
Example RTT estimation:
Slide 81
TCP Round Trip Time and Timeout Setting the timeout (RTO) RTO =
EstimtedRTT plus safety margin large variation in EstimatedRTT
-> larger safety margin r first estimate of how much SampleRTT
deviates from EstimatedRTT: RTO = EstimatedRTT + 4*DevRTT DevRTT =
(1- )*DevRTT + *|SampleRTT-EstimatedRTT| (typically, = 0.25) Then
set timeout interval:
Slide 82
TCP Round Trip Time and Timeout RTO = EstimatedRTT + 4*DevRTT
Might not always work RTO = max(MinRTO, EstimatedRTT + 4*DevRTT)
MinRTO = 250 ms for Linux 500 ms for windows 1 sec for BSD So in
most cases RTO = minRTO Actually, when RTO>MinRTO, the
performance is quite bad; there are many spurious timeouts. Note
that RTO was computed in an ad hoc way. It is really a signal
processing and queuing theory question
Slide 83
RTO details r When a pkt is sent, the timer is started, unless
it is already running. r When a new ACK is received, the timer is
restarted r Thus, the timer is for the oldest unACKed pkt m Q: if
RTO=RTT+ , are there many spurious timeouts? m A: Not necessarily
RTO ACK arrives, and so RTO timer is restarted RTO This shifting of
the RTO means that even if RTO