Lecture 5
description
Transcript of Lecture 5
Data Communication IData Communication ILecture 5Lecture 5
presented by
Werner Wild, CEO EvolutionInnsbruck, San Francisco, Zurich
Contact: [email protected]
Today’s Lecture PlanToday’s Lecture Plan
TCP
TCPTCP
Connection oriented byte stream– All bytes arrive in order– No “boundaries”
Not a virtual circuit– “Two end” management
Full duplex connectionAlways point-to-point
TCP TCP RFCs: 793, 1122, 1323, 2018, 2581RFCs: 793, 1122, 1323, 2018, 2581
full duplex data:– bi-directional data flow in
same connection
– MSS: maximum segment size
connection-oriented: – handshaking (exchange of
control msgs) init’s sender, receiver state before data exchange
flow controlled:– sender will not overwhelm
receiver
point-to-point:– one sender, one receiver
reliable, in-order byte steam:– no “message boundaries”
pipelined:– TCP congestion and flow
control set window size
send & receive buffers
socketdoor
T C Psend buffer
T C Preceive buffer
socketdoor
segm ent
applicationwrites data
applicationreads data
The TCP HeaderThe TCP Header
Byte stream sent as sequence of segments– Segment may be 0 to 64k bytessource port destination port
sequence number
acknowledgment number
window size
urgent pointerchecksum
options
data
headerlength unused flags
Establishing a ConnectionEstablishing a Connection
Normal connection Host 1 initiates and
chooses its initial sequence number.
Host 2 replies with its own initial sequence number and acknowledges host 1.
Host 1 begins data.
host 1 host 2
CR (seq=x)
ACK (seq=y,ack=x)
DATA (seq=x’,ack=y)
Duplicate Request (I)Duplicate Request (I)
A previous connection request appears from nowhere.
Host 2 replies with its own initial sequence number and acknowledges host 1.
Host 1 rejects the connection request.
host 1 host 2
CR (seq=x)
ACK (seq=y,ack=x)
REJECT (ack=y)
Duplicate Connection (II)Duplicate Connection (II)
A previous connection request appears from nowhere .
Host 2 replies. The first data packet of
the previous connection also appears.
Host 1 rejects the connection request.
host 1 host 2
CR (seq=x)
ACK (seq=y,ack=x)
REJECT (ack=y)
DATA (seq=x’,ack=z)
Initial Sequence NumbersInitial Sequence Numbers
Ensure no sequence number is reused before all packets and acks have expired.
Includes restart after a crash.
Large sequence space.
Based on bits from a “clock”.
timese
qu
ence
nu
mb
ers
initialsequencenumbers
sequencenumbersused
forbiddenrange
TCP seq. #’s and ACKsTCP seq. #’s and ACKsSeq. #’s:
– byte stream “number” of first byte in segment’s data
ACKs:– seq # of next byte
expected from other side
– cumulative ACKQ: how receiver handles
out-of-order segments– A: TCP spec doesn’t
say, - up to implementor
Host A Host B
Seq=42, ACK=79, data = ‘C’
Seq=79, ACK=43, data = ‘C’
Seq=43, ACK=80
Usertypes
‘C’
host ACKsreceipt
of echoed‘C’
host ACKsreceipt of
‘C’, echoesback ‘C’
timesimple telnet scenario
TCP ACK generationTCP ACK generationEvent
in-order segment arrival, no gaps,everything else already ACKed
in-order segment arrival, no gaps,one delayed ACK pending
out-of-order segment arrivalhigher-than-expect seq. #gap detected
arrival of segment that partially or completely fills gap
TCP Receiver action
delayed ACK. Wait up to 500msfor next segment. If no next segment,send ACK
immediately send singlecumulative ACK
send duplicate ACK, indicating seq. #of next expected byte
immediate ACK if segment startsat lower end of gap
TCP SequencingTCP Sequencing
seq=92, 8 bytes data
ack=100
seq=92, 8 bytes data
ack=100tim
eou
t
A B
Retransmission due to lost acknowledgment.
Note sequence number is bytes transmitted.
TCP Sequencing cont.TCP Sequencing cont.
seq=92, 8 bytes data
ack=100
A B
Cumulative acknowledgment avoids retransmission.
seq=100, 20 bytes data
ack=120tim
eou
t
TCP Sequencing cont.TCP Sequencing cont.
seq=92, 8 bytes data
seq=92, 8 bytes data
ack=100time
out
A B
Delayed acknowledgment causes retransmission
Subsequent acknowledgment prevents retransmission.
Not go-back-n Not selective repeat
seq=100, 20 bytes data
ack=120ack=120
TCP Flow ControlTCP Flow Control
receiver: explicitly informs sender of (dynamically changing) amount of free buffer space – RcvWindow field in TCP segment
sender: keeps the amount of transmitted, unACKed data less than most recently received RcvWindow
sender won’t overrun
receiver’s buffers bytransmitting too
much, too fast
flow control
receiver buffering
RcvBuffer = size or TCP Receive Buffer
RcvWindow = amount of spare room in Buffer
Receive WindowReceive Window (Example) (Example)
applicationwrites 2k
sender receiver
empty 4k2k, seq=0
2kack=2048, win=2048
applicationwrites 3k
2k, seq=20484k full
ack=4096, win=0
ack=4096, win=2048
2k
applicationreads 2k
1k, seq=40962k1k
TCP RTT and TimeoutTCP RTT and Timeout
Q: how to set TCP timeout value?
longer than RTT– note: RTT will
vary too short: premature
timeout– unnecessary
retransmissions too long: slow
reaction to segment loss
Q: how to estimate RTT? SampleRTT: measured time
from segment transmission until ACK receipt
– ignore retransmissions, cumulatively ACKed segments
SampleRTT will vary, want estimated RTT “smoother”
– use several recent measurements, not just current SampleRTT
TimeoutsTimeouts
What is the appropriate value for a timeout?
est_rtt = (1-p)(est_rtt) + p (sample_rtt)dev = (1-p) dev + p |sample_rtt - est_rtt|
The EndThe End
Thank you for your attention !
SourcesSources
For the preparation of this lectures a lot of sources where used – my special thanks go to :– Univ. Auckland– Univ. California – San Diego (UCSD)– Univ. Hongkong– … many others …