0% found this document useful (0 votes)
14 views

Transport_layer_basics

Its a TransportLaher slides that can help you out v much. It is related to computer networks

Uploaded by

Haris Nadeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Transport_layer_basics

Its a TransportLaher slides that can help you out v much. It is related to computer networks

Uploaded by

Haris Nadeem
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

2

Chapter 3
Transport Layer
Computer Networking: A
Top-Down
th
Approach
8 edition
Jim Kurose, Keith Ross
Pearson, 2020
Transport Layer: 3-3
Transport layer: overview
Our goal:
▪ understand principles ▪ learn about Internet transport
behind transport layer layer protocols:
services: • UDP: connectionless transport
• multiplexing, • TCP: connection-oriented reliable
demultiplexing transport
• reliable data transfer • TCP congestion control
• flow control
• congestion control

Transport Layer: 3-4


Transport vs. network layer services and protocols
household analogy:
12 kids in Ann’s house sending
letters to 12 kids in Bill’s
house:
▪ hosts = houses
▪ processes = kids
▪ app messages = letters in
envelopes
▪ transport protocol = Ann and Bill
who demux to in-house siblings
▪ network-layer protocol = postal
service

Transport Layer: 3-5


Transport vs. network layer services and protocols
household analogy:
▪transport layer: 12 kids in Ann’s house sending
communication between letters to 12 kids in Bill’s
processes house:
• relies on, enhances, network ▪ hosts = houses
layer services ▪ processes = kids
▪ app messages = letters in
envelopes
▪network layer: ▪ transport protocol = Ann and Bill
communication between who demux to in-house siblings
hosts ▪ network-layer protocol = postal
service

Transport Layer: 3-6


Transport Layer Actions

Sender:
application ▪ is passed an application
app. msg
application-layer message
transport ▪ determines segment TThhtransport
app. msg
header fields values
network (IP) ▪ creates segment network (IP)

link ▪ passes segment to IP link

physical physical

Transport Layer: 3-7


Transport Layer Actions

Receiver:
application ▪ receives segment from IP application
▪ checks header values
transport
transport
app. msg ▪ extracts application-layer
message
network (IP)
network (IP) ▪ demultiplexes message up
link to application via socket link

physical physical
Th app. msg

Transport Layer: 3-8


Two principal Internet transport
protocols application

▪TCP: Transmission Control Protocol


transport
network
mobile network
data link
physical
national or global ISP
• reliable, in-order delivery

log
• congestion control

ica
l en
• flow control

d-e
• connection setup

nd
▪UDP: User Datagram Protocol
local or

tra
regional ISP

nsp
• unreliable, unordered delivery

ort
home network content
provider
• no-frills extension of “best-effort” IP network datacenter
application

▪services not available:


network
transport
network
data link

• delay guarantees physical

• bandwidth guarantees enterprise


network

Transport Layer: 3-9


Chapter 3: roadmap
▪ Transport-layer services
▪ Multiplexing and demultiplexing
▪ Connectionless transport: UDP
▪ Principles of reliable data transfer
▪ Connection-oriented transport: TCP
▪ Principles of congestion control
▪ TCP congestion control
▪ Evolution of transport-layer
functionality
Transport Layer: 3-10
Multiplexing/demultiplexing
multiplexing as sender: demultiplexing as receiver:
handle data from multiple use header info to deliver
sockets, add transport header received segments to correct
(later used for demultiplexing) socket

application

application P1 P2 application socket


P3 transport P4
process
transport network transport
network link network
link physical link
physical physical

Transport Layer: 3-11


How demultiplexing works
▪ host receives IP datagrams 32 bits
• each datagram has source IP source port # dest port #
address, destination IP address
• each datagram carries one other header fields
transport-layer segment
• each segment has source, application
destination port number data
▪ host uses IP addresses & port (payload)
numbers to direct segment to
appropriate socket TCP/UDP segment format

Transport Layer: 3-12


Connectionless demultiplexing
Recall: when receiving host receives
UDP segment:
▪ when creating socket, must • checks destination port # in
specify host-local port #: segment
DatagramSocket mySocket1 • directs UDP segment to
= new socket with that port #
DatagramSocket(12534);
▪ when creating datagram to
send into UDP socket, must
specify IP/UDP datagrams with same dest.
port #, but different source IP
• destination IP address addresses and/or source port
• destination port # numbers will be directed to same
socket at receiving host
Transport Layer: 3-13
Connectionless demultiplexing: an example
mySocket =
socket(AF_INET,SOCK_DGRAM)
mySocket.bind(myaddr,6428);
mySocket = mySocket =
socket(AF_INET,SOCK_STREAM) socket(AF_INET,SOCK_STREAM)
mySocket.bind(myaddr,9157); mySocket.bind(myaddr,5775);
application
application application
P1
P3 P4
transport
transport transport
network
network link network
link physical link
physical physical

B D
source port: 6428 source port: ?
dest port: 9157 dest port: ?

A C
source port: 9157 source port: ?
dest port: 6428 dest port: ?
Connection-oriented demultiplexing
▪ TCP socket identified by ▪ server may support many
4-tuple: simultaneous TCP sockets:
• source IP address • each socket identified by its
• source port number own 4-tuple
• dest IP address • each socket associated with
• dest port number a different connecting client
▪ demux: receiver uses all
four values (4-tuple) to
direct segment to
appropriate socket
Transport Layer: 3-15
Connection-oriented demultiplexing: example
application
application P4 P5 P6 application
P1 P2 P3
transport
transport transport
network
network link network
link physical link
physical physical
server: IP
address B

host: IP source IP,port: B,80 host: IP


address A dest IP,port: A,9157 source IP,port: C,5775 address C
dest IP,port: B,80
source IP,port: A,9157
dest IP, port: B,80
source IP,port: C,9157
dest IP,port: B,80
Three segments, all destined to IP address: B,
dest port: 80 are demultiplexed to different sockets
Transport Layer: 3-16
Summary
▪ Multiplexing, demultiplexing: based on segment, datagram
header field values
▪ UDP: demultiplexing using destination port number (only)
▪ TCP: demultiplexing using 4-tuple: source and destination IP
addresses, and port numbers
▪ Multiplexing/demultiplexing happen at all layers

Transport Layer: 3-17


Chapter 3: roadmap
▪ Transport-layer services
▪ Multiplexing and demultiplexing
▪ Connectionless transport: UDP
▪ Principles of reliable data transfer
▪ Connection-oriented transport: TCP
▪ Principles of congestion control
▪ TCP congestion control
▪ Evolution of transport-layer
functionality
Transport Layer: 3-18
UDP: User Datagram Protocol
Why is there a UDP?
▪ “no frills,” “bare bones”
Internet transport protocol ▪ no connection
establishment (which can
▪ “best effort” service, UDP add RTT delay)
segments may be: ▪ simple: no connection state
• lost at sender, receiver
• delivered out-of-order to app ▪ small header size
▪ connectionless: ▪ no congestion control
▪ UDP can blast away as fast as
• no handshaking between UDP desired!
sender, receiver ▪ can function in the face of
• each UDP segment handled congestion
independently of others
Transport Layer: 3-19
UDP: User Datagram Protocol
▪ UDP use:
▪ streaming multimedia apps (loss tolerant, rate sensitive)
▪ DNS
▪ SNMP
▪ HTTP/3
▪ if reliable transfer needed over UDP (e.g., HTTP/3):
▪ add needed reliability at application layer
▪ add congestion control at application layer

Transport Layer: 3-20


UDP: User Datagram Protocol [RFC 768]

Transport Layer: 3-21


UDP: Transport Layer Actions

SNMP client SNMP server

application application

transport transport
(UDP) (UDP)

network (IP) network (IP)

link link

physical physical

Transport Layer: 3-22


UDP: Transport Layer Actions

SNMP client SNMP server


UDP sender actions:
application ▪ is passed an application
SNMP msg
application-layer message
transport
transport ▪ determines UDP segment UDP
UDPhh SNMP msg
(UDP) (UDP)
header fields values
network (IP) ▪ creates UDP segment network (IP)

link ▪ passes segment to IP link

physical physical

Transport Layer: 3-23


UDP: Transport Layer Actions

SNMP client SNMP server


UDP receiver actions:
application ▪ receives segment from IP application
▪ checks UDP checksum transport
transport header value
SNMP msg (UDP)
(UDP) ▪ extracts application-layer
network message network (IP)
h SNMP(IP)
msg
UDP
▪ demultiplexes message up link
link to application via socket
physical physical

Transport Layer: 3-24


UDP segment header
32 bits
source port # dest port #
length checksum

application length, in bytes of


data UDP segment,
(payload) including header

data to/from
UDP segment format application layer

Transport Layer: 3-25


UDP checksum
Goal: detect errors (i.e., flipped bits) in transmitted segment
1st number 2nd number sum

Transmitted: 5 6 11

Received: 4 6 11

receiver-computed sender-computed
checksum
= checksum (as received)

Transport Layer: 3-26


Internet checksum
Goal: detect errors (i.e., flipped bits) in transmitted segment
sender: receiver:
▪ treat contents of UDP ▪ compute checksum of received
segment (including UDP header segment
fields and IP addresses) as
sequence of 16-bit integers ▪ check if computed checksum equals
▪ checksum: addition (one’s checksum field value:
complement sum) of segment • not equal - error detected
content • equal - no error detected. But maybe
▪ checksum value put into errors nonetheless? More later ….
UDP checksum field
Transport Layer: 3-27
Internet checksum: an example
example: add two 16-bit integers
1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1

Note: when adding numbers, a carryout from the most significant bit needs to be
added to the result

* Check out the online interactive exercises for more examples: http://gaia.cs.umass.edu/kurose_ross/interactive/
Transport Layer: 3-28
Internet checksum: weak protection!
example: add two 16-bit integers
0 1
1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 0
1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1
wraparound 1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1 Even though
numbers have
sum 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0 changed (bit
flips), no change
checksum 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1 in checksum!

Transport Layer: 3-29


Summary: UDP
▪ “no frills” protocol:
• segments may be lost, delivered out of order
• best effort service: “send and hope for the best”
▪ UDP has its plusses:
• no setup/handshaking needed (no RTT incurred)
• can function when network service is compromised
• helps with reliability (checksum)
▪ build additional functionality on top of UDP in application layer
(e.g., HTTP/3)
Transport layer enhanced services
Reliability: of in-order packet delivery
Flow control: for receiver buffer
Congestion control: for network devices

Transport Layer: 3-31


Chapter 3: roadmap
▪ Transport-layer services
▪ Multiplexing and demultiplexing
▪ Connectionless transport: UDP
▪ Principles of reliable data transfer
▪ Connection-oriented transport: TCP
▪ Principles of congestion control
▪ TCP congestion control
▪ Evolution of transport-layer
functionality
Transport Layer: 3-32
Principles of Reliable communication
Error Recovery: by Error detection and Negative Acknowledgment NACK
in order packet delivery: by adding Sequence numbers to packets
Packet Loss recovery: By acknowledgements ACK for each packet
ACK loss recovery: by a timer to wait for ACK before retransmission
Avoiding delay by waiting for ACK: By pipelining (windowing) of N data messages
Go Back N protocols: pipeline N packets and wait for Cumulative ACK
Selective Repeat protocols: retransmit individual packet against missed ACK
Chapter 3: roadmap
▪ 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: 3-34
TCP: overview RFCs: 793,1122, 2018, 5681, 7323
▪ point-to-point: ▪ cumulative ACKs
• one sender, one receiver ▪ pipelining:
▪ reliable, in-order byte • TCP congestion and flow control
steam: set window size
• no “message boundaries" ▪ connection-oriented:
▪ full duplex data: • handshaking (exchange of control
• bi-directional data flow in messages) initializes sender,
same connection receiver state before data
• MSS: maximum segment size exchange
▪ flow controlled:
• sender will not overwhelm receiver
Transport Layer: 3-35
TCP Connection
Connection: Signaling between end hosts (network is unaware)

Handshake: 3-way connection setup SYN, SYN-ACK(by server), ACK

SYN

SYNACK

ACK

Transport Layer: 3-36


TCP segment structure
32 bits

source port # dest port # segment seq #: counting


ACK: seq # of next expected sequence number bytes of data into bytestream
byte; A bit: this is an ACK (not segments!)
acknowledgement number
head not
length (of TCP header) len used C EUAP R SF receive window flow control: # bytes
Internet checksum checksum Urg data pointer receiver willing to accept
options (variable length)
C, E: congestion notification
TCP options
application data sent by
RST, SYN, FIN: connection data application into
management (variable length) TCP socket

Transport Layer: 3-37


TCP sequence numbers, ACKs
outgoing segment from sender
Sequence numbers: source port # dest port #
sequence number
• byte stream “number” of first acknowledgement number
rwnd
byte in segment’s data checksum urg pointer

window size
Acknowledgements: N

• seq # of next byte expected


from other side sender sequence number space

• cumulative ACK sent sent, usable not


ACKed not-yet but not usable
ACKed yet sent
Q: how receiver handles (“in-flight”)

out-of-order segments outgoing segment from receiver


source port # dest port #
• A: TCP spec doesn’t say, - up sequence number

to implementor acknowledgement number


A rwnd
checksum urg pointer
Transport Layer: 3-38
TCP 3-way handshake
Server state
serverSocket = socket(AF_INET,SOCK_STREAM)
Client state serverSocket.bind((‘’,serverPort))
serverSocket.listen(1)
clientSocket = socket(AF_INET, SOCK_STREAM) connectionSocket, addr = serverSocket.accept()
LISTEN
clientSocket.connect((serverName,serverPort)) LISTEN
choose init seq num,
x
SYNSEN send TCP SYN msg SYNbit=1, Seq=x
T choose init seq num,
y
send TCP SYNACK SYN
SYNbit=1, Seq=y msg, acking SYN RCVD
ACKbit=1;
received SYNACK(x) ACKnum=x+1
ESTAB indicates server is live;
send ACK for SYNACK;
this segment may contain ACKbit=1,
client-to-server data
ACKnum=y+1 received ACK(y)
indicates client is live
ESTAB

Transport Layer: 3-39


TCP sequence numbers, ACKs
Host A Host B

User types‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs receipt of‘C’,
echoes back ‘C’
Seq=79, ACK=43, data = ‘C’
host ACKs receipt
of echoed ‘C’
Seq=43, ACK=80

simple telnet scenario


Transport Layer: 3-40
Example
Host A and Host B are communicating via TCP with a maximum
segment size (MSS) of 1000 bytes. Randomly selected initial sequence
numbers by A and B are 2000 and 500 respectively. Host A initiates
the connection and has 5000 bytes of data to send. Host B accepts
the connection and after receiving two data segments host B too
starts sending 2000 bytes of data over the same connection.
Write down the sequence of messages with following values
▪ Seq no.
▪ Ack no.
▪ SYN flag,
▪ ACK flag
Transport Layer: 3-41

You might also like