Transport layer
This presentation is the property of its rightful owner.
Sponsored Links
1 / 55

Transport Layer PowerPoint PPT Presentation


  • 33 Views
  • Uploaded on
  • Presentation posted in: General

Transport-layer services Multiplexing and demultiplexing Connectionless transport: UDP Principles of reliable data transfer Connection-oriented transport: TCP segment structure reliable data transfer flow control connection management Principles of congestion control

Download Presentation

Transport Layer

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Transport layer

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Transport vs network layer

network layer: logical communication between hosts

transport layer: logical communication between processes

relies on, enhances, network layer services

Household analogy:

12 kids sending letters to 12 kids

processes = kids

app messages = letters in envelopes

hosts = houses

transport protocol = Ann and Bill

network-layer protocol = postal service

Transport vs. network layer

Transport Layer


Internet transport layer protocols

reliable, in-order delivery (TCP)

congestion control

flow control

connection setup

unreliable, unordered delivery: UDP

no-frills extension of “best-effort” IP

services not available:

delay guarantees

bandwidth guarantees

application

transport

network

data link

physical

application

transport

network

data link

physical

network

data link

physical

network

data link

physical

network

data link

physical

network

data link

physical

network

data link

physical

logical end-end transport

Internet transport-layer protocols

Transport Layer


Transport layer1

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Multiplexing demultiplexing

delivering received segments

to correct socket

gathering data from multiple

sockets, enveloping data with

header (later used for

demultiplexing)

application

application

application

transport

transport

transport

P1

P3

P2

P1

P4

network

network

network

link

link

link

physical

physical

physical

Multiplexing at send host:

Demultiplexing at rcv host:

host 3

host 2

host 1

Multiplexing/demultiplexing

= socket

= process

Transport Layer


How demultiplexing works

host receives IP datagrams

each datagram has sourceIP address, destination IP address

each datagram carries 1 transport-layer segment

each segment has source, destination port number

host uses IP addresses & port numbers to direct segment to appropriate socket

32 bits

source port #

dest port #

other header fields

application

data

(message)

TCP/UDP segment format

How demultiplexing works

Transport Layer


Connectionless demultiplexing

Create sockets with port numbers:

DatagramSocket mySocket1 = new DatagramSocket(99111);

DatagramSocket mySocket2 = new DatagramSocket(99222);

UDP socket identified by two-tuple:

(dest IP address, dest port number)

When host receives UDP segment:

checks destination port number in segment

directs UDP segment to socket with that port number

IP datagrams with different source IP addresses and/or source port numbers directed to same socket

Connectionless demultiplexing

Transport Layer


Connectionless demux cont

SP: 9157

P3

P2

P1

P1

DP: 6428

SP: 6428

SP: 6428

SP: 5775

DP: 5775

DP: 6428

DP: 9157

Connectionless demux (cont)

DatagramSocket serverSocket = new DatagramSocket(6428);

client

IP: A

Client

IP:B

server

IP: C

SP provides “return address”

Transport Layer


Connection oriented demux

TCP socket identified by 4-tuple:

source IP address

source port number

dest IP address

dest port number

recv host uses all four values to direct segment to appropriate socket

Server host may support many simultaneous TCP sockets:

each socket identified by its own 4-tuple

Web servers have different sockets for each connecting client

non-persistent HTTP will have different socket for each request

Connection-oriented demux

Transport Layer


Connection oriented demux cont

S-IP: B

D-IP:C

SP: 9157

SP: 5775

SP: 9157

P1

P1

P2

P4

P5

P6

P3

DP: 80

DP: 80

DP: 80

S-IP: A

S-IP: B

D-IP:C

D-IP:C

Connection-oriented demux (cont)

client

IP: A

Client

IP:B

server

IP: C

Transport Layer


Connection oriented demux threaded web server

S-IP: B

D-IP:C

SP: 9157

SP: 5775

SP: 9157

P1

P1

P2

P3

DP: 80

DP: 80

DP: 80

S-IP: A

S-IP: B

D-IP:C

D-IP:C

Connection-oriented demux: Threaded Web Server

P4

client

IP: A

Client

IP:B

server

IP: C

Transport Layer


Transport layer2

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Udp user datagram protocol rfc 768

“no frills,” “bare bones” Internet transport protocol

“best effort” service, UDP segments may be:

lost

delivered out of order to app

connectionless:

no handshaking between UDP sender, receiver

each UDP segment handled independently of others

Why is there a UDP?

no connection establishment (which can add delay)

simple: no connection state at sender, receiver

small segment header

no congestion control: UDP can blast away as fast as desired

UDP: User Datagram Protocol [RFC 768]

Transport Layer


Udp more

often used for streaming multimedia apps

loss tolerant

rate sensitive

other UDP uses

DNS (port 53)

SNMP (port 161/162)

reliable transfer over UDP: add reliability at application layer

application-specific error recovery!

32 bits

source port #

dest port #

Length, in

bytes of UDP

segment,

including

header

checksum

length

Application

data

(message)

UDP segment format

UDP: more

Transport Layer


Udp checksum

Sender:

treat segment contents as sequence of 16-bit integers

checksum: addition (1’s complement sum) of segment contents

sender puts checksum value into UDP checksum field

Receiver:

compute checksum of received segment

check if computed checksum equals checksum field value:

NO - error detected

YES - no error detected. But maybe errors nonetheless? More later ….

UDP checksum

Goal: detect “errors” (e.g., flipped bits) in transmitted segment

Transport Layer


Internet checksum example

Internet Checksum Example

  • Note

    • When adding numbers, a carryout from the most significant bit needs to be added to the result

  • Example: add two 16-bit integers

1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0

1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0

1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

wraparound

sum

checksum

Transport Layer


Transport layer3

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Reliable data transfer in action

Reliable Data Transfer in action

Transport Layer


Reliable data transfer in action1

Reliable Data Transfer in action

Transport Layer


Rdt stop and wait operation

rdt: stop-and-wait operation

sender

receiver

first packet bit transmitted, t = 0

last packet bit transmitted, t = L / R

first packet bit arrives

RTT

last packet bit arrives, send ACK

ACK arrives, send next

packet, t = RTT + L / R

Transport Layer


Pipelined protocols

Pipelining: sender allows multiple, “in-flight”, yet-to-be-acknowledged pkts

range of sequence numbers must be increased

buffering at sender and/or receiver

Two generic forms of pipelined protocols: go-Back-N, selective repeat

Pipelined protocols

Transport Layer


Pipelining increased utilization

Pipelining: increased utilization

sender

receiver

first packet bit transmitted, t = 0

last bit transmitted, t = L / R

first packet bit arrives

RTT

last packet bit arrives, send ACK

last bit of 2nd packet arrives, send ACK

last bit of 3rd packet arrives, send ACK

ACK arrives, send next

packet, t = RTT + L / R

Increase utilization

by a factor of 3!

Transport Layer


Go back n

Sender:

k-bit seq # in pkt header

“window” of up to N, consecutive unack’ed pkts allowed (N2k-1)

Go-Back-N

  • ACK(n): ACKs all pkts up to, including seq # n - “cumulative ACK”

    • may receive duplicate ACKs (see receiver)

  • timer for each in-flight pkt

  • timeout(n):retransmit pkt n and all higher seq # pkts in window

Transport Layer


Gbn in action

GBN inaction

Transport Layer


Selective repeat

receiver individually acknowledges all correctly received pkts

buffers pkts, as needed, for eventual in-order delivery to upper layer

sender only resends pkts for which ACK not received

sender timer for each unACKed pkt

sender window (N2k-1)

N consecutive seq #’s

again limits seq #s of sent, unACKed pkts

Selective Repeat

Transport Layer


Selective repeat sender receiver windows

Selective repeat: sender, receiver windows

Transport Layer


Selective repeat1

data from above :

if next available seq # in window, send pkt

timeout(n):

resend pkt n, restart timer

ACK(n) in [sendbase,sendbase+N]:

mark pkt n as received

if n smallest unACKed pkt, advance window base to next unACKed seq #

receiver

sender

Selective repeat

pkt n in [rcvbase, rcvbase+N-1]

  • send ACK(n)

  • out-of-order: buffer

  • in-order: deliver (also deliver buffered, in-order pkts), advance window to next not-yet-received pkt

    pkt n in [rcvbase-N,rcvbase-1]

  • ACK(n)

    otherwise:

  • ignore

Transport Layer


Selective repeat in action

Selective repeat in action

Transport Layer


Selective repeat dilemma

Example:

seq #’s: 0, 1, 2, 3

window size=3

receiver sees no difference in two scenarios!

incorrectly passes duplicate data as new in (a)

Q: what relationship between seq # size and window size?

Selective repeat: dilemma

Ans: N2k-1

Transport Layer


Transport layer4

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Tcp overview rfcs 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

TCP: OverviewRFCs: 793, 1122, 1323, 2018, 2581

Transport Layer


Tcp segment structure

32 bits

URG: urgent data

(generally not used)

counting

by bytes

of data

(not segments!)

source port #

dest port #

sequence number

ACK: ACK #

valid

acknowledgement number

head

len

not

used

Receive window

U

A

P

R

S

F

PSH: push data now

(generally not used)

# bytes

rcvr willing

to accept

checksum

Urg data pnter

Options (variable length)

RST, SYN, FIN:

connection estab

(setup, teardown

commands)

application

data

(variable length)

Internet

checksum

(as in UDP)

TCP segment structure

Transport Layer


Tcp seq s and acks

Seq. #’s:

byte stream “number” of first byte in segment’s data

ACKs:

seq # of next byte expected from other side

cumulative ACK

Q: how receiver handles out-of-order segments

A: TCP spec doesn’t say, - up to implementor

Seq=42, ACK=79, data = ‘C’

Seq=79, ACK=43, data = ‘C’

Seq=43, ACK=80

time

TCP seq. #’s and ACKs

Host B

Host A

User

types

‘C’

host ACKs

receipt of

‘C’, echoes

back ‘C’

host ACKs

receipt

of echoed

‘C’

simple telnet scenario

Transport Layer


Transport layer5

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Tcp reliable data transfer

TCP creates rdt service on top of IP’s unreliable service

Pipelined segments

Cumulative acks

TCP uses single retransmission timer

Retransmissions are triggered by:

timeout events

duplicate acks

Initially consider simplified TCP sender:

ignore duplicate acks

ignore flow control, congestion control

TCP reliable data transfer

Transport Layer


Tcp sender events

data rcvd from app:

Create segment with seq #

seq # is byte-stream number of first data byte in segment

start timer if not already running (think of timer as for oldest unacked segment)

expiration interval: TimeOutInterval

timeout:

retransmit segment that caused timeout

restart timer

Ack rcvd:

If acknowledges previously unacked segments

update what is known to be acked

start timer if there are outstanding segments

TCP sender events:

Transport Layer


Tcp retransmission scenarios

Host A

Host B

Host A

Host B

Seq=92, 8 bytes data

Seq=92, 8 bytes data

Seq=100, 20 bytes data

ACK=100

Seq=92 timeout

timeout

X

ACK=100

ACK=120

loss

Seq=92, 8 bytes data

Sendbase

= 100

Seq=92, 8 bytes data

SendBase

= 120

ACK=120

Seq=92 timeout

ACK=100

SendBase

= 120

time

premature timeout

time

lost ACK scenario

TCP: retransmission scenarios

SendBase

= 100

Transport Layer


Tcp retransmission scenarios more

Host A

Host B

Seq=92, 8 bytes data

ACK=100

Seq=100, 20 bytes data

timeout

X

loss

ACK=120

time

Cumulative ACK scenario

TCP retransmission scenarios (more)

SendBase

= 120

Transport Layer


Fast retransmit

Time-out period often relatively long:

long delay before resending lost packet

Detect lost segments via duplicate ACKs.

Sender often sends many segments back-to-back

If segment is lost, there will likely be many duplicate ACKs.

If sender receives 3 ACKs for the same data, it supposes that segment after ACKed data was lost:

fast retransmit:resend segment before timer expires

Fast Retransmit

Transport Layer


Transport layer6

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Tcp flow control how it works

(Suppose TCP receiver discards out-of-order segments)

spare room in buffer

= RcvWindow

= RcvBuffer-[LastByteRcvd - LastByteRead]

Rcvr advertises spare room by including value of RcvWindow in segments

Sender limits unACKed data to RcvWindow

guarantees receive buffer doesn’t overflow

TCP Flow control: how it works

Transport Layer


Transport layer7

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Tcp connection management

Recall:TCP sender, receiver establish “connection” before exchanging data segments

initialize TCP variables:

seq. #s

buffers, flow control info (e.g. RcvWindow)

client: connection initiator

Socket clientSocket = new Socket("hostname","port number");

server: contacted by client

Socket connectionSocket = welcomeSocket.accept();

Three way handshake:

Step 1:client host sends TCP SYN segment to server

specifies initial seq #

no data

Step 2:server host receives SYN, replies with SYNACK segment

server allocates buffers

specifies server initial seq. #

Step 3: client receives SYNACK, replies with ACK segment, which may contain data

TCP Connection Management

Transport Layer


Tcp connection management cont

Closing a connection:

client closes socket:clientSocket.close();

Step 1:client end system sends TCP FIN control segment to server

Step 2:server receives FIN, replies with ACK. Closes connection, sends FIN.

client

server

close

FIN

ACK

close

FIN

ACK

timed wait

closed

TCP Connection Management (cont.)

Transport Layer


Tcp connection management cont1

Step 3:client receives FIN, replies with ACK.

Enters “timed wait” - will respond with ACK to received FINs

Step 4:server, receives ACK. Connection closed.

Note:with small modification, can handle simultaneous FINs.

TCP Connection Management (cont.)

client

server

closing

FIN

ACK

closing

FIN

ACK

timed wait

closed

closed

Transport Layer


Transport layer8

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Principles of congestion control

Congestion:

informally: “too many sources sending too much data too fast for network to handle”

different from flow control!

manifestations:

lost packets (buffer overflow at routers)

long delays (queueing in router buffers)

a top-10 problem!

Principles of Congestion Control

Transport Layer


Approaches towards congestion control

End-end congestion control:

no explicit feedback from network

congestion inferred from end-system observed loss, delay

approach taken by TCP

Network-assisted congestion control:

routers provide feedback to end systems

single bit indicating congestion (SNA, DECbit, TCP/IP ECN, ATM)

explicit rate sender should send at

Approaches towards congestion control

Two broad approaches towards congestion control:

Transport Layer


Transport layer9

Transport-layer services

Multiplexing and demultiplexing

Connectionless transport: UDP

Principles of reliable data transfer

Connection-oriented transport: TCP

segment structure

reliable data transfer

flow control

connection management

Principles of congestion control

TCP congestion control

Transport Layer

Transport Layer


Tcp congestion control

end-end control (no network assistance)

sender limits transmission:

LastByteSent-LastByteAcked

 CongWin

Roughly,

CongWin is dynamic, function of perceived network congestion

How does sender perceive congestion?

loss event = timeout or 3 duplicate acks

TCP sender reduces rate (CongWin) after loss event

three mechanisms:

AIMD

slow start

conservative after timeout events

CongWin

rate =

Bytes/sec

RTT

TCP Congestion Control

Transport Layer


Tcp aimd

multiplicative decrease: cut CongWin in half after loss event

TCP AIMD

additive increase: increase CongWin by 1 MSS every RTT in the absence of loss events: probing

Long-lived TCP connection

Transport Layer


Tcp slow start

When connection begins, CongWin = 1 MSS

Example: MSS = 500 bytes & RTT = 200 msec

initial rate = 20 kbps

available bandwidth may be >> MSS/RTT

desirable to quickly ramp up to respectable rate

TCP Slow Start

  • When connection begins, increase rate exponentially fast until first loss event

Transport Layer


Refinement

After 3 dup ACKs:

CongWin is cut in half

window then grows linearly

But after timeout event:

CongWin instead set to 1 MSS;

window then grows exponentially

to a threshold, then grows linearly

Refinement

Philosophy:

  • 3 dup ACKs indicates network capable of delivering some segments

  • timeout before 3 dup ACKs is “more alarming”

Transport Layer


Refinement more

Q: When should the exponential increase switch to linear?

A: When CongWin gets to 1/2 of its value before timeout.

Implementation:

Variable Threshold

At loss event, Threshold is set to 1/2 of CongWin just before loss event

Refinement (more)

Transport Layer


Summary tcp congestion control

Summary: TCP Congestion Control

  • When CongWin is below Threshold, sender in slow-start phase, window grows exponentially.

  • When CongWin is above Threshold, sender is in congestion-avoidance phase, window grows linearly.

  • When a triple duplicate ACK occurs, Threshold set to CongWin/2 and CongWin set to Threshold.

  • When timeout occurs, Threshold set to CongWin/2 and CongWin is set to 1 MSS.

Transport Layer


  • Login