程序代写代做代考 CS 372 Lecture #17 The Transport Layer:

CS 372 Lecture #17 The Transport Layer:
• Reliable data transfer with TCP • Error detection/handling
• Sequencing
• Acknowledgements
• retransmission
Note: Many of the lecture slides are based on presentations that accompany Computer Networking: A Top Down Approach, 6th edition,
by Jim Kurose & Keith Ross, Addison-Wesley, 2013.
v
Or•egon State University

Error handling
oHow can sender know that an error has occurred? oBit flipped
oMissing packet oOut-of sequence
oWhat should the receiver do? oWhat should the sender do?
oTCP uses acknowledgement and retransmission

TCP: Overview [RFCs: 793, 1122, 1323, 2018, 2581]
• connection-oriented:
• handshake (exchange of control messages) initializes sender/receiver state before data exchange
opipelined:
o TCP congestion and flow
control
o send & receive buffers
oflow controlled:
o sender will not overwhelm
receiver
o MSS: maximum segment size
socket door
• point-to-point:
• one sender, one receiver
• full duplex (bi-directional data flow in same connection)
• in-order byte steam:
• cumulative byte count
• acknowledgement of bytes received
socket door
application writes data
application reads data
TCP send buffer
segment I ➔
TCP receive buffer

TCP segment structure
32 bits
source port #
header length
sequence number
acknowledgement number
not used
destination port #
checksum
U
A
P
R
S
F
Receive window
Urgent data pointer
Options (variable length, padded to 32 bits)
application data
(variable length)
4-bit header size.
Number of 32-bit “lines” (minimum=5, maximum=15)
Flags for urgent data, ACK validity, push, reset, synchronize, final data
Internet checksum (as in UDP)
counting
by bytes
of data
(not segments!)
# bytes receiver is willing to accept

TCP sequence numbers
oSegments are sent as a stream of bytes o Not separated into records, data types, etc. o Protocol keeps count of data bytes sent
o for each segment, protocol puts byte stream number of first byte in segment’s data into “sequence number” field
oSender keeps a copy of each segment until acknowledged by receiver
oSender’s segment also has “acknowledgement number” o TCP is full-duplex. Data can flow in both directions
simultaneously
o Typical (nothing to ACK) segment has a bogus number in the “acknowledgement number” field

TCP acknowledgement numbers
oReceiver acknowledges all correct segments received. o Error segments are not acknowledged at all
oHeader for acknowledgement segment (ACK) is the same as for other segments
o receiver calculates data bytes received by subtracting 4 x o “header length” from TCP segment total byte-count
oACK may also contain data
o TCP is full-duplex. Data can flow in both directions
o Typical (no data) ACK has a bogus number in the “sequence number” field
“acknowledgement number” field contains the number of the next
byte expected
simultaneously

Simple TCP scenario (no errors)
1. Host A sends “Hello!” to Host
• Host A
Host B •
B. Suppose the ‘H’ is byte #42 in this sequence. ACK (#79) is bogus in this scenario
1.Host A sends ‘Hello!’
Seq:::::42
, ACl(:::::79
2. Host B receives segment,
, data::::: ‘Hel/of’
2.Host B ACKs receipt of segment
determines data length is 6,
so next expected byte
number is 42+6 = #48. Host time B sends ACK, but sends no
data.
3. Host A receives ACK, and sends “Goodbye!” to Host B. ‘G’ is byte #48 in this sequence.
4. Host B receives segment, determines data length is 8, so next expected byte number is 48+6 = #56. Host B sends ACK, but sends no data.
5. Host A receives ACK.
3.Host A receives ACK, sends ‘Goodbye!’
4.Host B ACKs receipt of segment
5.Host A receives ACK

TCP retransmission
oSender sets a count-down timer for each segment sent
o if timer expires before ACK received … re-send o if segment error, ACK will never arrive
• Receiver can detect and discard duplicates
o if ACK is delayed (arrives after re-send) o if ACK is lost

TCP retransmission scenarios
• Seg:::92 8 b • Seq:::92 8 b
l , Ytes data l , Ytes data
ll
Seq:::92 8 b
, Ytes data
timeout
timeout
next seq# = 100
time
next seq# = 100
Host A
Host B
Host A
Host B
segment error
time
segment lost
Error: no ACK sent
X
loss

TCP retransmission scenarios (continued)
next seq# = 100
next seq# = 100

l
Host A
Host B
Host A
Host B
l
loss
time
ACK lost
time ACK delayed
Seq::92
X
, 8 byt
es data
Duplicate
discarded
Seq=92 timeout
Seq=92 timeout
timeout

Summary Lecture #17
oTCP error handling oerror detection
obyte sequencing oacknowledgement (ACK) o retransmission