69
TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering [email protected] Lecture 13 Transport Layer

TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering [email protected] Lecture 13 Transport Layer

Embed Size (px)

Citation preview

Page 1: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 1

Spring 2006

EE 5304/EETS 7304 Internet Protocols

Tom OhDept of Electrical Engineering

[email protected]

Lecture 13

Transport Layer

Page 2: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 2

Administrative Issues

I will pass out the Test #2 next week.

For in-class students, we will have Test #3(Final) on May 9, 2006, 6:30PM.

I will post Homework 4 on our course website tomorrow.

Page 3: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 3

Outline (Comer, Ch. 25)

Transport layer functions

General considerations

Types of networks

Transport functions for type A network

Transport functions for type B network

Transport functions for type C network

Page 4: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 4

Transport Layer (TCP/IP View)

TransportTransport

Internet

IPIP

Network/Network/physicalphysical

ApplicationApplication

TransportTransport

IPIP

Network/Network/physicalphysical

ApplicationApplication

Host Host

Host-to-host protocol to hide details of network from application

Page 5: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 5

Transport Layer (cont)

Provides host-to-host communication service to application

Applications do not have to worry about details of network

Can often enhance network services (e.g, TCP/IP)

Ensure error recovery if network layer is unreliable Ensure end-to-end flow control Ensure multiplexing and demultiplexing sessions onto

same connection

Applications can call on transport layer without having to worry about these things

Page 6: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 6

Transport Layer (cont)

TransportTransport

ApplicationApplication

TransportTransport

ApplicationApplication

Host Host

Application may see reliable, flow controlled, multiplexed communication transport-layer service

Underlying network may be unreliable

Page 7: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 7

Transport Layer (cont)

Transport layer can be simpler if network is good

TCP/IP is extreme case

IP layer is intentionally simple as possible - best-effort and unreliable

Transport layer (TCP) is complicated

Page 8: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 8

Connection-Oriented or Connectionless?

Transport layer offers connection-oriented or connectionless service to application?

Commonly connection-oriented, eg, TCP

Requires connection set-up and disconnect phases Most appropriate if hosts want reliable, flow controlled,

sequential transfer of long stream of data Network layer can be connection-oriented or

connectionless If connectionless, transport layer must do more work to

appear connection-oriented (e.g, TCP)

Page 9: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 9

Transport Layer (cont)

TransportTransport

ApplicationApplication

TransportTransport

ApplicationApplication

Host Host

Application sees a virtual connection: packets are delivered in sequential order

Underlying network may be connectionless or connection-

oriented

Page 10: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 10

Connection-Oriented? (cont)

Some transport layer protocols are connectionless, eg, UDP

Sometimes connection set-up is unjustified, eg, when data is short/bursty or application does not need reliable delivery

Network layer can be connection-oriented or connectionless (but makes practical sense only for connectionless network)

Page 11: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 11

Quality of Service Needed by Application?

Application may request a desired or minimum QoS

QoS can be characterized by specific parameters, eg:

Connection establishment delay: time to set up a new connection

Connection blocking probability: chance of failing to set up new connection

Throughput: number of data bytes transferred over time Transit delay: time from packet transmission to delivery

Page 12: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 12

QoS (cont)

QoS parameters (cont):

Availability: how often service is unavailable Reliability: percentage of lost or errored messages that are

uncorrected by network Relative priority: priority of connection compared to other

connections

Transport layer QoS may be limited by network QoS

Although unreliable network can be made to appear more reliable, transport layer cannot overcome some limitations of the network (bandwidth, delays)

Page 13: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 13

OSI Types of Network Service

A: reliable packet delivery, rare signaled network failures (that cause reported but uncorrected connection loss or packet loss)

A-1: sequential delivery, arbitrary packet size A-2: non-sequential delivery, arbitrary packet size (e.g.

datagram) A-3: non-sequential delivery, maximum packet size

B: reliable delivery, rate of signaled failures can be unacceptable, e.g. X.25

C: unreliable delivery (lost/duplicated packets), e.g, IP

Page 14: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 14

Type A-1 Network Service

Assumes reliable network, sequential packet delivery, arbitrary packet size

Important transport layer functions:

Connection setup/termination Multiplexing/demultiplexing Flow control

Page 15: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 15

Type A-1 Network: Connection Setup

Set-up verifies dest. host is ready, negotiates optional parameters (TPDU size, window size, QoS), and allows allocation of resources (buffer space)

TPDU = transport protocol data unit (transport layer packet)

Simple 2-way handshake for connection set-up is sufficient

closedclosed

host Bhost A

passive open (listen)

active openSYN

SYNestablished

established

Page 16: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 16

Type A-1 Network: Connection Setup (cont)

Connection request can be initiated by OPEN command from user → send RFC, wait to receive RFC (connection accepted) or CLOSE (connection refused)

If receive RFC → OPEN state (connection established)

If receive RFC (connection request) in LISTEN state → send RFC to accept, enter OPEN state (connection established)

If receive RFC in IDLE state → notify user of connection request, then send RFC and enter OPEN state if user accepts

Page 17: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 17

Type A-1 Network: Connection Setup (cont)

If both hosts initiate RFC about same time → no confusion

Connection termination works in same way Initiated by either side, return to IDLE state

closedclosed

host Bhost A

SYN SYNactive open active open

established established

Page 18: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 18

Type 1-A Network: Multiplexing

Multiplexing → multiple applications running on same host can use same transport protocol

Applications are identified by port numbers carried in transport layer packet header

Transport layer can multiplex data from multiple applications (identified by ports) to send via network layer

Can receive data from network layer and demultiplex to appropriate application

Well known ports: TCP 80 = HTTP; UDP 53 = DNS; TCP 25 = SMTP

Page 19: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 19

Multiplexing (cont)

TransportTransport

ApplicationApplication

TransportTransport

ApplicationApplication

Host Host

Port 80

ApplicationApplication

Port 35

ApplicationApplication

Port 26 Port 18

Page 20: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 20

Type 1-A Network: Flow Control

Like data link layer, flow control is to prevent sender host A from overwhelming dest. host B

Dest. host B has options:

Do nothing• If receive buffers overflow, data is lost• A will time-out and resend → makes congestion worse

Refuse to accept data from network layer• Relies on backpressure from flow control in network to slow

down A• Slow: backpressure may take long time to reach A• Coarse control: other connections may be also effected

Page 21: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 21

Type 1-A Network: Flow Control (cont)

Use sliding window

Need ACKs and sequence numbers for TPDUs B will withhold ACKs to slow down A (A will not time-out

and resend because packet delivery is assumed reliable) Works well, but may not work well if network is unreliable

(A will time-out and resend if ACKs are too slow or lost)

Use credits

Separates ACKs from flow control: can ACK without granting credit & vice versa

Also works well for unreliable networks

Page 22: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 22

Type A-2 Network Service

Assumes reliable network, non-sequential packet delivery, arbitrary packet size

Non-sequential delivery → TPDU sequence numbers are required for resequencing at dest. host

Already saw sequence numbers are useful for flow control

Transport protocol must keep track of control TPDUs

Possible confusion for flow control

Page 23: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 23

Type A-2 Network Service (cont)

New credit value might overtake old credit value → sender gets wrong message

Need to sequentially number credit messages to avoid confusion

packet N

host Bhost A

credit 0

credit MAck

waiting for datawaiting for credit

Page 24: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 24

Type A-2 Network Service (cont)

Possible confusion in connection set-up

Data packets could arrive before a CONNECTION_ACCEPT

• Should queue these TPDUs in expectation of a CONNECTION_ACCEPT

Data packets could arrive after a CONNECTION_RELEASE

• CONNECTION_RELEASE should contain number of last TPDU

Page 25: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 25

Type A-2 Network Service (cont)

RFC

host Bhost A

RFC

2

Ack

data arrives before connection is accepted

SYN

1

CLS

host Bhost A

N

data arrives after connection is released

N-1

CLS

Page 26: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 26

Type A-3 Network Service

Assumes reliable network, non-sequential packet delivery, limited packet size

Transport service is stream oriented (user data is treated as continuous) or block oriented

If block oriented, blocks are segmented into TPDUs and reassembled

Maybe number the blocks & number TPDUs within each block, but TPDUs have sequence numbers

• Only need End of Block flag

Page 27: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 27

Type B Network Service

Assumes reliable network, maybe non-sequential packet delivery, network failures are possible

TPDUs can be lost but reported to transport entities

Transport entity must handle known lost data and/or lost connection

Page 28: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 28

Type B Network Service (cont)

In connection reset (eg, X.25 RESET), maybe some TPDUs will be lost

Transport entity sends control TPDU to other end to ACK reset condition and gives number of last received TPDU

Wait to send new TPDUs until receive corresponding reset control TPDU from other end

If network connection is lost without reset (eg, X.25 RESTART), new connection must be requested

Transport entity sends control TPDU to other end to identify new network connection

Page 29: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 29

Type C Network Service

Assumes unreliable network, non-sequential packet delivery, eg, IP

Transport layer functions:

Retransmission Duplicate detection Flow control Connection setup/clear Crash recovery

Page 30: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 30

Type C Network - Retransmission Strategy

TPDUs can be lost or errored

Requires ACKs to sender

Sender has timers and timeouts to resend

If timeout too short → unnecessary retransmissions If timeout too long → slow to respond to lost TPDU Should be somewhat longer than (variable) roundtrip delay

Fixed timeouts cannot adapt

Adaptive timeout: no known best solutions (although used in TCP)

Page 31: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 31

Type C Network - Duplicate Detection

No confusion for lost TPDUs that are retransmitted

But if ACK lost, receiver might get duplicate TPDUs

If a duplicate TPDU arrives before connection close,

Receiver assumes ACK was lost & it ACKs duplicate Sender should not be confused by multiple ACKs for same

TPDU Range of sequence numbers should be large enough not

to repeat (wrap around) during connection

Page 32: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 32

Type C Network - Duplicate Detection (cont)

If a duplicate TPDU arrives after connection close,

TPDU from old connection could arrive during new connection and be mistaken for new TPDU

Could use continuous sequence numbers, transport connection ID,...

RFCs contain initial sequence number

Page 33: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 33

Type C Network - Duplicate Detection (cont)

host Bhost A

duplicate TPDU at B, no confusion

N

N

host Bhost A

ACK

duplicate ACKs at A, no confusion

N

N

ACK

ACK

host Bhost A

duplicate TPDU arrives during new connection, confused for new TPDU

N

N

CLS

CLS

CLS

CLS

SYN

SYN

Page 34: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 34

Type C Network - Flow Control

Credits work well

Eg, (ACK N, CREDIT M) acks all TPDUs up to N and grants credit for TPDUs N+1 through N+M

If ACK is lost, future ACKs will resync. protocol

Sender will timeout and resend, and generate new ACK

But (ACK N, CREDIT 0) can close window, if next (ACK N, CREDIT M) is lost → deadlock

Window timer is reset with each ACK If timeout, entity must send ACK even if duplicates earlier

ACK

Page 35: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 35

Type C Network - Flow Control (cont)

N

host Bhost A

Ack N, credit 0

Ack N, credit M

waiting for datawaiting for credit

N

host Bhost A

Ack N, credit 0

Ack N, credit M

window timer

Ack N, credit M

Page 36: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 36

Type C Network - Connection Setup

RFCs (request or confirm) can be lost or delayed in normal 2-way handshake

Use retransmit-RFC timer → receiver may get duplicate RFCs (if CONNECTION_CONFIRM lost)

1. ignore duplicate if connection already set up 2. confusing if arrives after connection clear

• Mistaken for new request, real new request is discarded

Page 37: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 37

Type C Network - Connection Setup (cont)

SYN i

host Bhost A

obsolete SYN arrives

B discards duplicate SYN

B rejects TPDU

A sends new SYNSYN j B respondsSYN k

A opens connection

A sends TPDU k+1

Page 38: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 38

Type C Network - Connection Setup (cont)

If CONNECTION_REQUEST is delayed, sender may get duplicate RFCs

Ignore duplicate if connection already up

3-way handshake: ACK both the RFC and sequence number

Old RFC causes a reset (rejection) at sender Old CONNECTION_CONFIRMED is discarded

Page 39: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 39

Type C Network - Connection Setup (cont)

host Bhost A

normal

SEQ i, ACK j

SYN i

host Bhost A

old SYN, connection is rejected by A

SYN j, ACK i

host Bhost A

delayed SYN/ACK, connection is rejected by A, new connection is accepted

RST , ACK j

old SYN i

SYN j, ACK i

SEQ i, ACK j

SYN i

SYN j, ACK i

old SYN k, ACK m

RST, ACK k

Page 40: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 40

Spring 2006

EE 5304/EETS 7304 Internet Protocols

Tom OhDept of Electrical Engineering

[email protected]

Lecture 13

UDP

Page 41: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 41

Outline

UDP (comer, Ch. 24)

UDP header (Comer, Ch. 24)

Page 42: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 42

UDP (User Datagram Protocol)

Provides unreliable datagram service with less overhead than TCP

Application has full responsibility for handling datagrams that are lost, duplicated, or out of order

UDP adds multiplexing on top of IP

Different applications on same host are identified by port numbers

An application is identified uniquely by <host address, port number>

Page 43: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 43

UDP (cont)

TransportTransport

ApplicationApplication

TransportTransport

ApplicationApplication

Host Host

UDP port 80

ApplicationApplication

UDP port 25

ApplicationApplication

UDP port 26

UDP port 18

Unreliable connectionless service

Page 44: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 44

UDP 8-byte Header

bits:

data

UDP source port

8

UDP destination port

message length checksum

8 8 8

Source port (16 bits): optional; allows replies to sender

Destination port (16 bits): identifies application at destination hostMessage length (16 bits):

bytes of data + 8 for UDP header

Page 45: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 45

UDP Header (cont)

Checksum (2 bytes) = error detection over a pseudoheader + UDP datagram

PseudoheaderPseudoheader UDP datagramUDP datagram

Page 46: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 46

UDP Header (cont)

Pseudoheader = 12 bytes constructed from IP header

Source and dest. IP addresses (4 bytes each) Protocol (1 byte) = 17 for UDP UDP length (2 bytes) = length of UDP datagram

(excluding pseudoheader)

bits:

source IP address

8

zero UDP length

8 8 8

protocol

destination IP address

Page 47: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 47

UDP Header (cont)

IP address is used in checksum to verify correct destination

Does this checksum violate the layering principle?

Yes - because UDP uses info from IP layer below it (IP packet header fields)

Page 48: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 48

Spring 2006

EE 5304/EETS 7304 Internet Protocols

Tom OhDept of Electrical Engineering

[email protected]

Lecture 13

TCP - Part 1

Page 49: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 49

Outline (Comer, Ch. 25)

TCP

TCP header

TCP retransmissions

TCP duplicate detection

TCP connection set-up and close

Page 50: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 50

TCP (Transmission Control Protocol)

TCP is predominant transport layer protocol to add end-to-end reliability above IP

Designed for reliable sequential byte stream delivery with no duplicates, no loss

Views application data as continuous byte stream, breaks into segments of 64-Kbyte max. length

Keeps track of each byte with a sequence number Segments are prefixed with TCP header and encapsulated

into IP packets

Page 51: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 51

TCP (cont)

TCP dataTCP dataTCP headerTCP headerIP headerIP header

Sending application

Data• • • • • •

DataData

DataDataTCP headerTCP header

TCP segment

Receiving application

Data• • • • • •

DataData

DataDataTCP headerTCP header

TCP segment

IP packet

Page 52: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 52

TCP (cont)

Provides connection-oriented service between applications on different hosts

An application is identified to TCP by port address

Application is completely identified by 16-bit port address & 32-bit IP address

TCP connection is between two endpoints, source <host address, port> and destination <host address, port>

Page 53: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 53

TCP (cont)

TransportTransport

ApplicationApplication

TransportTransport

ApplicationApplication

Host Host

TCP port 80

ApplicationApplication

TCP port 25

ApplicationApplication

TCP port 26

TCP port 18

Reliable connection-oriented service with no duplicate, lost, misordered, or errored bytes

Page 54: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 54

TCP (cont)

TCP assumes IP - a type C network - so has all of most complicated functions of transport protocol

Error control detects missing, errored, non-sequential, and duplicate packets

Uses sequence numbers and piggybacked ACKs, adaptive retransmissions

Flow control using credits

Connection control: 3-way handshake

Also, TCP assumes responsibility for congestion avoidance because IP has no congestion control

Page 55: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 55

TCP Header

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Source port (16 bits): optional; allows replies to sender

Destination port (16 bits): identifies application at destination host

Page 56: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 56

TCP Header

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Checksum (16 bits): error detection over pseudoheader + TCP segment

Page 57: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 57

TCP Header (cont)

Pseudoheader is constructed from IP packet header including IP source/destination addresses, protocol field (=6 for TCP), length of TCP segment

Ensures that IP addresses are correct

Like UDP, this violates layering principle of OSI model

bits:

source IP address

8

zero TCP length

8 8 8

protocol

destination IP address

Page 58: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 58

TCP Header

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Sequence number (32 bits): number of first data byte, except if SYN=1; data bytes are numbered sequentially, to reconstruct sender’s byte stream

Page 59: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 59

TCP Header (cont)

Sending application

Byte n+1Byte n • • •

DataData

DataDataTCP headerTCP header

Number of first byte = sequence number

Receiving application

DataData

Byte n+2 Byte n+1Byte n • • •Byte n+2

Sequence number tells where this segment belongs in reconstructed byte stream

Page 60: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 60

TCP Header

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Acknowledgement (32 bits): piggybacked ACK tells sender the next byte that is expected; ACKs are cumulative and refers to end of contiguous received data; additional received data, if not contiguous, triggers a duplicate ACK

Page 61: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 61

TCP Header (cont)

Sending application

DataData

Segment ASEQ = 400

Receiver’s buffer

Byte 399

DataData

DataData

Segment BSEQ = 600

Segment CSEQ = 800

DataData

Segment Breceived first

ACK 400

bytes

Page 62: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 62

TCP Header (cont)

Sending application

DataData

Segment ASEQ = 400

Receiver’s buffer

Byte 399

DataData

DataData

Segment BSEQ = 600

Segment CSEQ = 800

DataData

Segment Creceived second

ACK 400

duplicate

bytes

Page 63: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 63

TCP Header (cont)

Sending application

DataData

Segment ASEQ = 400

Receiver’s buffer

Byte 999

DataData

DataData

Segment BSEQ = 600

Segment CSEQ = 800

DataData

Segment Areceived third

ACK 1000

bytes

Page 64: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 64

TCP Header (cont)

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Header length (4 bits): in units of 4 bytes; header is 20 bytes (value = 5) + options (if any)

Reserved (6 bits): all zeros

Page 65: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 65

TCP Header (cont)

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Flags (6 bits): URG: tells if Urgent pointer is usedACK: tells if Acknowledgement field is used PUSH: forces immediate transmission at senderRST: tells receiver to abort and reset connectionSYN: segments for 3-way handshake to set up connectionFIN: segments for 3-way handshake to terminate connection

Page 66: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 66

TCP Header (cont)

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

URG flag: tells if Urgent pointer is used

Urgent pointer (16 bits): used if URG=1

Page 67: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 67

TCP Header (cont)

Urgent pointer (2 bytes): points to number of first byte after urgent data in segment

If URG flag =1, data up to urgent pointer is urgent data to be processed immediately; rest of data is regular (not urgent)

Allows "out of band" data (to be processed immediately, out of sequence)

DataDataTCP headerTCP header

Urgent pointer

Urgent data

Regular data

Page 68: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 68

TCP Header (cont)

Push function:

Normally, TCP accumulates data from sender before transmitting a segment

If sender issues a “push”, TCP will send the ready data, even if segment will be short (e.g., 1 byte of data)

Page 69: TO 3-7-06 p. 1 Spring 2006 EE 5304/EETS 7304 Internet Protocols Tom Oh Dept of Electrical Engineering taehwan@engr.smu.edu Lecture 13 Transport Layer

TO 3-7-06 p. 69

TCP Header (cont)

bits:

data

TCP source port

8

TCP destination port

checksum urgent pointer

8 8 8

sequence number

acknowledgement number

HLEN windowflagsRES

options

Window (16 bits): piggybacked credit advertised by receiver; for flow control of sender