fundamentals of computer networks ece 478/578 lecture #20: transmission control protocol instructor:...

15
Fundamentals of Computer Networks ECE 478/578 Lecture #20: Transmission Control Protocol Instructor: Loukas Lazos Dept of Electrical and Computer Engineering University of Arizona

Upload: norma-littleton

Post on 16-Dec-2015

218 views

Category:

Documents


1 download

TRANSCRIPT

Fundamentals of Computer NetworksECE 478/578

Lecture #20: Transmission Control ProtocolInstructor: Loukas Lazos

Dept of Electrical and Computer EngineeringUniversity of Arizona

Transmission Control Protocol (TCP)Connection oriented

Explicit set-up and tear-down of TCP session

Stream-of-bytes serviceSends and receives a stream of bytes, not messages

Reliable, in-order deliveryChecksums to detect corrupted dataAcknowledgments & retransmissions for reliable deliverySequence numbers to detect losses and data reordering

Flow controlPrevents overflow of the receiver’s buffer

Congestion controlAdapts to network congestion for the greater good

2

Does TCP Duplicate Lower Layer Services? Sliding-window based algorithmIncorporates ACK, NACKs, retransmissions, timeouts, ordering

How is TCP different?Runs over a route rather than a single physical link Needs to establish a connection and negotiate parameters (sliding window size)Adapts to heterogeneous conditions

RTT varies with connected hosts, time of the day etc, unpredictableFlow control on computers with different resources

Reorders and retransmits packets end-to-endEven if packets are in order on one physical link this does not guarantee end-to-

end ordering

Provides congestion controlNo immediate feedback from the link, no knowledge of conditions along the wayCongestion control based on feedback 3

TCP Byte Service

4

In general, TCP is a full duplex protocol,. i.e. data flows in both directions

5

TCP Segment

IP packetNo bigger than Maximum Transmission Unit (MTU)E.g., up to 1500 bytes on an Ethernet

TCP packetIP packet with a TCP header and data insideTCP header is typically 20 bytes long

TCP segmentNo more than Maximum Segment Size (MSS) bytesE.g., up to 1460 consecutive bytes

IP HdrIP Data

TCP HdrTCP Data (segment)

TCP Segment

6

Simplified TCP FlowData Sequence Numbers flow toward the receiverAcks and Window Size flow the opposite direction

7

Header Fields in a Segment

<SrcPort, SrcIPAddr, DestPort, DestIPAddr> define a TCP connection

SequenceNum: Sequence number of the first byte in the segment

Flags: 6-bit field: SYN, FIN, RESET, PUSH, URG, ACKSYN, FIN: Establish and terminate a TCP connectionACK: request for an acknowledgementURG: Urgent Data UrgPtr points to where the urgent data endsPUSH: a notification to the application running over TCPRESET: some error occurred and the connection needs to be aborted

8

9

Sequence NumbersHost A

Host B

TCP Data

TCP Data

TCP HDR

TCP HDR

ISN (initial sequence number)

Sequence number = 1st byte ACK sequence

number = next expected byte

10

Initial Sequence Number (ISN)Sequence number for the very first byte

E.g., Why not a de facto ISN of 0?

Practical issueIP addresses and port #s uniquely identify a connectionSame port #s may get used again to establish new connection and there is a chance an old packet is still in flightand might be associated with the new connection

So, TCP requires changing the ISN over timeSet from a 32-bit clock that ticks every 4 μsWraps around once every 4.55 hours!

But, this means the hosts need to exchange ISNs

Connection Establishment

11

Three-Way HandshakeExchange of three messages

Timer

Timer

Client’s SYN Packet

12

Client’s Port Server’s Port

Client’s ISN

20 SYN

Server’s Reply Packet

13

Client’s PortServer’s Port

Server’s ISN

20 SYN, ACK

Client’s ISN + 1

Client’s ACK Packet

14

Client’s Port Server’s Port

Server’s ISN + 1

20 ACK

16

Tearing Down the Connection

Closing the connectionFinish (FIN) to close and receive remaining bytesAnd other host sends a FIN ACK to acknowledgeReset (RST) to close and not receive remaining bytes

SYN

SYN

AC

K

AC

K

Dat

a

FIN

FIN A

CK

AC

K

timeA

BFIN

AC

K