0% found this document useful (0 votes)
27 views52 pages

Week12.2 Final

Uploaded by

Enis Mert Kuzu
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)
27 views52 pages

Week12.2 Final

Uploaded by

Enis Mert Kuzu
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/ 52

CS 408

Computer Networks

Week 12- Transport Protocols - TCP

Kürşat Çağıltay, [email protected]

1
Dijkstra’s algorithm

Step N' N2,p(2) N3,p(3) N4,p(4) N5,p(5) N6,p(6)


0 1 2, 1-2 5, 1-3 1, 1-4 ∞ ∞
1 1,4 2,1-2 4,1-4-3 2,1-4-5 ∞
2 1,4,2 2,1-2 4,1-4-3 ∞
3 1,4,2,5 3,1-4-5-3 4,1-4-5-6
4 1,4,2,5,3 4,1-4-5-6
5 1,4,2,5,3,6
Dijkstra’s algorithm: result

resulting least-cost-path tree from N1:


resulting forwarding table in N1:
2 3 destination outgoing link
N2 (N1,N2) route from N1 to N4 directly
1 6 N4 (N1,N4)
4 5 N5 (N1,N4) route from N1 to all other
N3 (N1,N4) destinations via N4
N6 (N1,N4)
Open Shortest Path First (OSPF)
• RIP has limitations in large internets
—RIP metrics are very simple and might cause suboptimal routes to be
formed
• OSPF is preferred interior routing protocol for TCP/IP based
internets
• Link state routing used
Link State Routing
• When initialized, router determines link cost on each interface
• Router advertises these costs to all other routers in topology
• Router monitors its costs
—When changes occur, costs are re-advertised
• Each router constructs topology and calculates shortest path to
each destination network
—Can use any algorithm, but in practice Dijkstra is used
OSPF Overview
• Router maintains the state (i.e. Cost) of local links
• Transmits updated state information to all routers in AS or in area
• Router receiving update must acknowledge

• Each router maintains a database that reflects the topology


—Directed graph
—And then generates a spanning tree and routing table
Sample Autonomous System
• Vertices (nodes)
—Routers
—Networks
• Edges
—Connecting two routers
—Connecting router to
network
Directed Graph of Sample Autonomous System

Each router applies


Dijkstra algorithm on
this graph to find out
minimum path to
each destination
network
Example: The Spanning Tree for Router R6
Application of Exterior and Interior Routing
Protocols
Border Gateway Protocol (BGP)
• For use with TCP/IP internets
• Preferred ERP of the Internet
• Allows routers (gateways) in different Autonomous Systems to
exchange routing information
• Current version is BGP-4
—RFC 4271
TCP/IP
Protocol
Suite

Link Layer

Physical Layer
Transport Protocol - Summary
• Provides end-to-end data transfer
• Shields upper layer application protocols from the details of
networks
• TCP: complicated flow and error control since the underlying
network service (IP) is unreliable
• TCP is connection oriented
• UDP is another transport layer protocol but connectionless
Connection Oriented Transport Protocol
Mechanisms
• Logical connections between end users
—Connection Establishment
—Data Transfer
—Connection Termination
• Reliable service
• e.g. TCP
5 Issues in a Simple Transport Protocol
• Addressing
• Multiplexing
• Flow Control
• Connection establishment and termination
1&2 -Addressing and Multiplexing
• Multiple users employ same transport protocol
— Users are multiplexed
— User (Client process) is locally identified by port number
• User identification for the target
—Usually host address + port
• Called a socket in TCP and UDP
• Port represents a particular transport service (TS) user
—25 SMTP, 80 HTTP, etc. -> these are for server
—Client port numbers are >1024 and selected arbitrarily
• Host address
—An attached network device
—In the Internet, a global internet address (e.g. IP addr.)
Transport services and protocols
application
transport

▪ provide logical communication


network
mobile network
data link
physical
national or global ISP
between application processes
running on different hosts

▪ transport protocols actions in end local or


regional ISP
systems:
• sender: breaks application messages home network content
provider
into segments, passes to network layer network datacenter
application
network
• receiver: reassembles segments into
transport
network
data link
messages, passes to application layer physical

enterprise
network
Transport vs. network layer services and
protocols

▪network layer (IP): logical communication between


hosts
▪transport layer (TCP, UDP): logical communication
between processes
• relies on, enhances, network layer services
Transport Layer Actions: Multiplex

Sender:
application ▪ is passed an application- application
app. msg
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 Actions: Demultiplex

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

physical physical
Th app. msg
HTTP server
client
application application
HTTP msg
transport

transport network transport


network link network
link physical link
physical physical
HTTP server
client
application application
HTTP msg
transport
Ht HTTP msg

transport network transport


network link network
link physical link
physical physical
HTTP server
client
application application
HTTP msg
transport
Ht HTTP msg

Hnnetwork
Ht HTTP msg transport
transport
network link network
link physical link
physical physical
HTTP server
client
application application

transport

transport network transport


network link network
link physical link
physical physical

Hn Ht HTTP msg
HTTP server
client1 client2
application P-client1 P-client2 application

transport

transport network transport


network link network
link physical link
physical physical
Multiplexing/demultiplexing
multiplexing at sender: demultiplexing at 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
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
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
demultiplexing: example
application
application P4 P5 P6 application
P1 P2 P3
transport
transport transport
network
network link network
link physical link
physical server: IP physical
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
3 - Flow Control

Sliding Window Protocol


3 - Flow Control
• Flow control is end to end
• Flow should be controlled because
—The receiving party may not keep up with the flow of data
—Results in buffers filling up
• Transport level flow control is more difficult than link-level one
(next topic)
—transmission delay is variable due to network. That makes difficult to use
timeouts
Transport Level Flow Control
• Do nothing
— Segments that overflow are discarded
— Sending transport entity will fail to get ACK and will retransmit
• Not a good solution for a reliable network
• Backpressure
— Refuse further segments
• So that the sending party eventually senses the problem due to lengthy queues
— Coarse grained – packets are not accepted for all connections
• Network and link layer connection are used by several transport layer connections and flow
control is exercised on several transport connections together
• Sliding window protocols with credit scheme ***
— Sender sends up to certain window size without getting ack
— Window size is set dynamically and unit is octets (bytes)
— Note: Sliding window is also used in Data Link layer
Credit Scheme
• Each octet has an sequence number
• Segments are numbered with the sequence number of the their
first octets
• Each transport segment has a header that contains
—sequence number
—ack number
—window size
Use of Header Fields
• When sending
—seq. number (SN) of first octet in segment is included
• Two flow control related fields: AN=i, W=j
—AN is ack. number; W is window size (for credit)
—All octets with sequence numbers up to and including i-1 are
acknowledged
• Next expected octet is i
—Permission to send window of W=j octets (gives credit)
Flow Control Perspectives of Sending and
Receiving Parties

-
Sliding window metaphore ☺

https://youtube.com/shorts/6nxexmfjIiw?si=iYxl0
Zg243P8sZvT
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
TCP sequence numbers, ACKs
outgoing segment from sender
source port # dest port #
sequence number
acknowledgement number
Sequence numbers: rwnd
checksum urg pointer

• byte stream “number” of window size


N
first byte in segment’s data

sender sequence number space


Acknowledgements:
sent sent, not- usable not
• seq # of next byte expected ACKed yet ACKed but not usable
(“in-flight”) yet sent
from other side
• Single or cumulative ACK outgoing segment from receiver
source port # dest port #
sequence number
acknowledgement number
A rwnd
checksum urg pointer
Flow Control Protocols

1. Stop-and-wait Automatic Repeat Request (ARQ)


2. Go-Back-N ARQ
3. Selective Repeat ARQ
1 - stop-and-wait operation
sender receiver
first packet bit transmitted, t = 0

first packet bit arrives


RTT last packet bit arrives, send ACK

ACK arrives, send next


packet, t = RTT + L / R

▪ protocol performance stinks!


▪ Protocol limits performance of underlying infrastructure (channel)
1 - stop-and-wait operation
sender receiver

L/R L/R
Usender=
RTT + L / R
.008 RTT
=
30.008
= 0.00027

▪ protocol performance stinks!


▪ Protocol limits performance of underlying infrastructure (channel)
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
3-packet pipelining increases
utilization by a factor of 3!

U 3L / R .0024
sender = = = 0.00081
RTT + L / R 30.008
Go-Back-N ARQ (Automatic Repeat Request)
sender window (N=4) sender receiver
012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, discard,
012345678 rcv ack0, send pkt4 (re)send ack1
012345678 rcv ack1, send pkt5 receive pkt4, discard,
(re)send ack1
ignore duplicate ACK receive pkt5, discard,
(re)send ack1
pkt 2 timeout
012345678 send pkt2
012345678 send pkt3
012345678 send pkt4 rcv pkt2, deliver, send ack2
012345678 send pkt5 rcv pkt3, deliver, send ack3
rcv pkt4, deliver, send ack4
rcv pkt5, deliver, send ack5
Go-Back-N: sender
▪ sender: “window” of up to N, consecutive transmitted but unACKed pkts
• k-bit seq # in pkt header

▪ cumulative ACK: ACK(n): ACKs all packets up to, including seq # n


• on receiving ACK(n): move window forward to begin at n+1
▪ timer for oldest in-flight packet
▪ timeout(n): retransmit packet n and all higher seq # packets in window
Go-Back-N: receiver
▪ ACK-only: always send ACK for correctly-received packet so far, with
highest in-order seq #
• need only remember rcv_base
▪ on receipt of out-of-order packet:
• can discard (don’t buffer) or buffer: an implementation decision

Receiver view of sequence number space:


received and ACKed

… … Out-of-order: received but not ACKed

rcv_base
Not received
3-Selective repeat
▪receiver individually acknowledges all correctly received packets
• buffers packets, as needed, for eventual in-order delivery to upper
layer
▪sender times-out/retransmits individually for unACKed packets
• sender maintains timer for each unACKed pkt
▪sender window
• N consecutive seq #s
• limits seq #s of sent, unACKed packets
Selective Repeat ARQ Automatic Repeat Request

sender window (N=4) sender receiver


012345678 send pkt0
012345678 send pkt1
012345678 send pkt2 receive pkt0, send ack0
012345678 send pkt3 Xloss receive pkt1, send ack1
(wait)
receive pkt3, buffer,
012345678 rcv ack0, send pkt4 send ack3
012345678 rcv ack1, send pkt5
receive pkt4, buffer,
record ack3 arrived send ack4
receive pkt5, buffer,
pkt 2 timeout send ack5
012345678 send pkt2
012345678 (but not 3,4,5)
012345678 rcv pkt2; deliver pkt2,
012345678 pkt3, pkt4, pkt5; send ack2

Q: what happens when ack2 arrives?


Selective repeat: sender, receiver
windows
Flow Control Protocols
• Stop-and-wait Automatic Repeat Request (ARQ) – For simplex or
low speed communications, handshaking
• Go-Back-N ARQ - Mainly used for data link layer communication
• Selective Repeat ARQ – Used in TCP
Sliding Window Protocol Simulation

• https://nikhilsahu.me/Sliding-window-simulator/
Example of TCP Credit - Assume 200 octets/segment
- Initial credit (window size) 1400 octets
Allocation Mechanism - Beginning octet number 1001
Flow Control Protocols

• Stop-and-wait Automatic Repeat Request (ARQ)


• Go-Back-N ARQ
• Selective Repeat ARQ

You might also like