You are on page 1of 30

National University of

Computer & Emerging Sciences


CS 3001 – COMPUTER NETWORKS

Lecture 11
CHAPTER 3
th
26 October, 2021
Nauman Moazzam Hayat
nauman.moazzam@lhr.nu.edu.pk Office Hours:

11:30 am till 6:00 pm (Every Tuesday & Thursday)

Chapter 3: Transport Layer

our goals:
❖ understand services:
principles behind ▪ multiplexing,
transport layer demultiplexing
▪ reliable data transfer ▪ UDP: connectionless
▪ flow control transport
▪ congestion control ▪ TCP: connection-oriented
❖ learn about Internet reliable transport
transport layer protocols: ▪ TCP congestion control

Transport Layer 3-2

Chapter 3 outline
3.5 connection-oriented
3.1 transport-layer transport: TCP
services ▪ segment structure
3.2 multiplexing and ▪ reliable data transfer
demultiplexing ▪ flow control
▪ connection management
3.3 connectionless
3.6 principles of congestion
transport:
control
UDP
3.7 TCP congestion control
3.4 principles of reliable
data transfer
Transport Layer 3-3

Transport services and protocols


application

❖ provide logical messages into segments,


communication between app passes to network layer
processes running on different ▪ rcv side: reassembles
hosts segments into messages,
❖ transport protocols run in passes to app layer
end systems ❖ more than one transport
▪ send side: breaks app
protocol available to apps ▪
Internet: TCP and UDP, application
transport

SCTP etc… network


data link
transport
network
physical
data link
physical

Transport Layer 3-4

Transport Layer vs Network Layer & Data Link


Layer

- The Data Link Layer is responsible for delivery of frames


between two neighboring nodes over a link. This can be called
node-to-node delivery.

- The network layer is responsible for delivery of datagrams


between two hosts. This can be called host-to-host delivery.

Communication on the Internet is not defined as the exchange


of data between two nodes or between two hosts. Real
communication takes place between two processes.

- The Transport Layer is responsible for the process-to-process

delivery.
Transport vs. network layer

between hosts
❖ network layer:
❖ transport layer:
logical
logical
communication
communication ❖ hosts = houses
❖ processes = kids
between processes ❖ app messages = letters in
▪ relies on, enhances, envelopes
network layer ❖ transport protocol = Ann

services and Bill who demux to in

household analogy: house siblings ❖


network-layer protocol =
12 kids in Ann ’s house
postal service
sending letters to 12 kids
in Bill’s house:

Transport Layer 3-6

Internet transport-layer protocols


delivery (TCP)
application
transport network

❖ reliable,
data link

▪ congestion
in-order physical network

control data link


network data link physical

▪ flow control
physical
network data link

▪ connection setup
physical network data
link physical
network
❖ unreliable, unordered data link

delivery: UDP
▪ no-frills extension guarantees
❖ services not physical
of “best-effort” IP network data link

network data link


physical
available: ▪ delay physical

application guarantees physical


transport network data link

▪ bandwidth
Transport Layer 3-8

Chapter 3 outline

transport:
3.1 transport-layer UDP
services 3.4 principles of reliable
3.2 multiplexing and data transfer
demultiplexing 3.5 connection-oriented
3.3 connectionless transport: TCP
▪ segment structure 3.6 principles of congestion
▪ reliable data transfer control
▪ flow control 3.7 TCP congestion control
▪ connection management

Transport Layer 3-9

Port
- Port is a transport layer address / identifier to choose
among the multiple processes running among the same
host

- 16 bit integers ranging between 0 & 65,535


- The client side program chooses a port number randomly
(ephemeral port number)

- The server side ports are not random but well known and
pre assigned

- IANA (Internet Assigned Number Authority) had divided


port numbers into three ranges:

- Well Known: 0 to 1023. Assigned & controlled by IANA. (Example HTTP


uses Port # 80, FTP uses port # 21. List of well known ports given in RFC
1700 & updated via RFC 3232)
- Registered: 1024 to 49,151. Not assigned / controlled by IANA, but
registered with them to avoid duplication.
- Dynamic (or Private): 49,152 to 65,535. Neither controlled, nor registered.
Can be used by any process. (Ephemeral Ports.)
Multiplexing/demultiplexing

multiplexing at sender:
demultiplexing at receiver: handle data from multiple
sockets, add transport header (later use header info to deliver received
used for demultiplexing) segments to correct socket

application
n P4
transport transport
network network transport
link link network
application
physical physical link
P3 P1 P2
applicatio physical
socket
proces
s

Transport Layer 3-11

How datagrams

demultiplexing
works 32 bits

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

Transport Layer 3-12


Connectionless demultiplexing

❖ recall:
created socket has
host-local port #:
❖ whenhost receives UDP
DatagramSocket mySocket1
= new segment:
DatagramSocket(12534);
▪ checks destination port #
❖ recall:
when creating in segment
datagram to send into ▪ directs UDP segment to
UDP socket, must specify ▪ socket with that port #
destination IP address (thus UDP socket identified by 2-tuple: •
dest IP address
▪ destination port # • dest port number)
and/or source port
IP datagrams with same numbers will be directed
dest. port #, but different to same socket at dest
source IP addresses
Transport Layer 3-13

Connectionless demux: example

DatagramSocket
DatagramSocket network application
mySocket2 = new link P1
DatagramSocket physical
(9157); serverSocket transport

application = new network

P3 DatagramSocket link
physical
transport
(6428);
application link
DatagramSocket
mySocket1 = new P4
DatagramSocket
transport physical
(5775);
network
sour source port: ?
ce dest port: ?
port:
source port: 6428
9157 dest dest source port: ?
port: 6428 port: dest port: ?
9157

Transport Layer 3-14

Connection-oriented demux

▪ source IP address
❖ TCP socket identified ▪ source port number
by 4-tuple:
▪ dest IP address ▪ each socket identified by
▪ dest port number its own 4-tuple
❖ demux: receiver uses all ❖ web servers have
four values to direct different sockets for
segment to appropriate each connecting client ▪
socket non-persistent HTTP will
❖ server host may support have different socket for
many simultaneous TCP each request
sockets:

Transport Layer 3-15

Connection-oriented demux: example


application
application P4 P5 P6 application

P3 P3
transport
P2
source IP,port: B,80 physical
transport
network
network
link
link
physical
physical host: IP
server: IP address C
address B
transport
network
dest IP,port: A,9157 host: IP
link

address A
source IP,port: A,9157
dest IP, port: B,80 IP,port: B,80
source IP,port: C,5775 dest
IP,port: B,80 source IP,port: C,9157 dest
three segments, all destined to IP address:
B, dest port: 80 are demultiplexed to
Transport Layer 3-16
different sockets

Connection-oriented demux: example

threaded server
application
application P3 P2
P3
P4
application transport
source IP,port: B,80
transport
network
network
link
dest IP,port: A,9157 host: IP
link
physical
physical
server: IP physical address C
address B
transport
network
host: IP
link
address A source IP,port: C,5775 dest
IP,port: B,80
source IP,port: source IP,port: C,9157 dest
A,9157 dest IP, port: B,80 IP,port: B,80

Transport Layer 3-17

Chapter 3 outline

3.2 multiplexing and


3.1 transport-layer demultiplexing
services
3.3 connectionless
transport: ▪ reliable data transfer
UDP ▪ flow control
▪ connection management
3.4 principles of reliable
3.6 principles of congestion
data transfer
control
3.5 connection-oriented
transport: TCP 3.7 TCP congestion control
▪ segment structure

Transport Layer 3-18

UDP: User Datagram Protocol [RFC 768]


of others
❖“no frills,” “bare bones” ❖ UDP use:
Internet transport
▪ streaming multimedia
protocol
apps (loss tolerant, rate
❖“best effort” service,
sensitive)
UDP segments may
be: ▪ lost ▪ DNS
▪ SNMP
▪ delivered out-of-order
to app ❖ reliable transfer over
❖ connectionless: UDP:
▪ no handshaking ▪ add reliability at
between UDP sender, application layer
receiver ▪ application-specific error
▪ each UDP segment recovery!
handled independently
Transport Layer 3-19

UDP: segment header

32 bits
source port # dest port # length
UDP segment format
checksum length, in bytes of
UDP segment,
including header
application
data why is there a UDP?❖ no
(payload)
connection
establishment (which can add header size
delay) ❖ no congestion control: UDP
❖ simple: no connection state can blast away as fast as
at sender, receiver ❖ small desired

Transport Layer 3-20

UDP checksum

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


segment
including header fields &
sender: data, as sequence of 16-
❖ treat segment contents, bit integers (words)
❖ checksum: addition received segment
(one’s complement ❖ check if computed
sum) of segment checksum equals checksum
contents field value:
❖ sender puts checksum ▪ NO - error detected
value into UDP ▪ YES - no error detected.
checksum field But maybe errors
receiver: nonetheless? More
❖ compute checksum of later ….

Transport Layer 3-21

Internet checksum: example


example: add two 16-bit integers
11110011001100110111010101010
10101
11011101110111011
wraparound
110111011101111001
sum 0100010001000011
checksum

Note: when adding numbers, a carryout from the


most significant bit needs to be added to the result

Transport Layer 3-22


Midterm 1 Solution

Discussion • - Midterm 1 Solution was discussed

You might also like