Beruflich Dokumente
Kultur Dokumente
NETS3303/3603 Week 8
Outcomes
Learn the mechanisms of TCP
How they operate How they are implemented
Intro
TCP - Transmission Control Protocol reliable, connection-oriented stream (point to point) protocol
if UDP is like Aus Post TCP is like a one-to-one phone call (cannot broadcast/multicast)
Intro
RFC 793 and host requirements 1122 TCP has own jargon:
Socket: a communication endpoint segment: a TCP packet MSS: maximum segment size, max pkt one TCP side can send another, negotiated at connection time port: application identifier
TCP Properties
stream orientation. stream of bytes passed between send/recv connection is full duplex
think of it as two independent streams joined with piggybacking mechanism
piggybacking - one data stream has control info for the other data stream unstructured stream
doesnt show packet boundaries to applications
School of Information Technologies
TCP Properties
virtual circuit connection
client connects and server listens/accepts i/o transfers dont have remote peer address
Buffered Transfer
Send and receive buffers for flow control
Reliability!
Providing Reliability
Traditional technique: Positive Acknowledgement with Retransmission (PAR)
Receiver sends acknowledgement when data arrives Sender starts timer whenever transmitting Sender retransmits if timer expires before acknowledgement arrives
School of Information Technologies
This wastes a substantial network bandwidth because it must delay sending a new packet until it receives an ack for the previous packet
School of Information Technologies
Bytes through 2 are acknowledged Bytes 3 through 6 not yet acknowledged Bytes 7 though 9 waiting to be sent Bytes above 9 lie outside the window and cannot be sent
Sliding Window
TCP can use cumulative ACK e.g., ACK up to #7 tcp uses bytes not packets for sequencing recv-side controls sliding window
Based on its available buffer space Can stop sending by telling it window size is 0 in ACK, thus flow control
Each segment, including data segments, specifies size of window beyond acknowledged byte Window size may be 0 (receiver cannot accept additional data at present) Receiver can send additional ack later when buffer space becomes available
School of Information Technologies
TCP encapsulation
Smalls windows are advertised and small segments are sent E.g.: a 1-byte data segment would have 54 bytes overhead => 98%!!
School of Information Technologies
TCP Header
Hlen
Header Explained
header sent in every TCP packet
Sometimes may just be control message (SYN/FIN/ACK) with no data
view TCP as 2 sender/recv data streams with control information sent back the other way (piggybacking)
Header
source port: 16 bits, the TCP source port destination port: 16 bits, note ports in 1st 8 bytes sequence number: 1st data octet in this segment (from send to recv): 32 bit space (ISN) ack: if ACK flag set, next expected sequence number (piggybacking; i.e., we are talking about the flow the other way)
School of Information Technologies
Header
hlen: # of 4-byte words in header (e.g. 5 means 20 bytes) Reserved bits: not used flags
URG: - urgent pointer field significant ACK:- ack field significant (this pkt is an ACK!) PSH: - push function (mostly ignored) RST: - reset (give up on) the connection (error) SYN: - initial synchronization packet (start connect) FIN: - final hangup packet (end connect)
Header
window: window size, begins with ACK field that recv-side will accept (piggyback) checksum: 16 bits
Includes 12-byte IP pseudo-header, tcp header, and data
urgent pointer: offset from sequence number, points to data following urgent data, URG flag must be set options - e.g., Max Segment Size (MSS), timestamp
School of Information Technologies
Three-way handshake
interesting problem: how do you make sure last ACK got there (cant ACK it...)?
School of Information Technologies
Close
TIME_WAIT state is used to deal with unreliable delivery, must wait 2 MSL (max segment length) time, 1 or 2 minutes typically
Wait for any duplicate segments to arrive before closing
TCP Retransmission
Designed for Internet environment
Delays on one connection vary over time Delays vary widely between connections
Adaptive Retransmission
TCP keeps estimate of round-trip time (RTT) on each connection RTT derived from observed delay between sending segment and receiving ack Timeout for retransmission based on current round-trip estimate
School of Information Technologies
Solution: Smoothing
Adaptive retransmission schemes keep a statistically smoothed round-trip estimate Smoothing keeps running average from fluctuating wildly
keeps TCP from overreacting to change
Jacobsons Algorithm
Initial RTO value typically reflects Ethernet delay Update RTO using returning acks based on average and variance
SRTT(K + 1) = (1 g) SRTT(K) + g RTT(K + 1) SERR(K + 1) = RTT(K + 1) SRTT(K) SDEV(K + 1) = (1 h) SDEV(K) + h |SERR(K + 1)|
SDEV is a RTT variability factor
TCP source cannot distinguish these 2 cases No valid way to calculate RTT:
From first transmission to ack, or From second transmission to ack?
Karns Algorithm
Do not use measured RTT of retransmitted segments to update SRTT and SDEV Calculate backoff RTO when a retransmission occurs Use backoff RTO for segments until an ACK arrives for a segment that has not been retransmitted
Then Jacobsons algorithm is reactivated to calculate RTO
School of Information Technologies
Summary Of TCP
Major transport service in the Internet (85% of traffic) Connection oriented Provides end-to-end reliability Uses adaptive retransmission Includes facilities for flow control and congestion avoidance Uses 3-way handshake for connection startup and shutdown
School of Information Technologies