Networks Revision Notes
Transport Layer
Enables multiple processes on one host to communicate with multiple
processes on another remote host over the network(end-system
communication)
It hides the complex communication paths between 2 end systems
Implemented on the end systems
Transport layer protocol break message received from app layer into
segments and send them over the network via the network layer
On destination end system, transport layer receives segments from
network layer, reconstructs message and hands it over to the app layer
TCP/IP Networks
UDP (user Datagram Protocol) and TCP (Transmission Control Protocol)
IP(Internet Protocol) most common and important network protocol
IP Protocol provide logical communication between hosts(unreliable
services)
Main functions of a TCP:
Extending host to host delivery to process to process delivery
(Multiplexing/Demultiplexing)
Provide data integrity validation and error detection
UDP
o Unreliable, connectionless transport services
o Suitable for real time applications/ can tolerate packet loss
o Min packet header= 8 bytes divided into 4
o Source port number
o Destination port number
o Length (no. of bytes in segment)
o Checksum (error detection)
o No connection state/ no need to establish connection
o Segment divided into header + msg payload
TCP
o Reliable, connection-oriented transport services
o Full-duplex protocol
o Doesn’t support 1 to many communication or connections
o Establishing connection = 3 way handshake
TCP send and receive Buffers
Outgoing app. Data is stored in the send buffer
TCP will grab chunks of data from the send buffer and pass it to the
network layer for transmission
TCP segment is limited in size (MSS) Maximum segment size defined based
on maximum transmission unit (MTU)
MTU measures max data frame we could send over link-layer
TCP segment and header + IP header should be <= MTU
Sequence Number and Acknowledgment
TCP views data as unstructured but ordered stream of bytes
Sequence number is the byte stream number of the first byte in the
segment
Ack. Number sent by receiver is the seq. number of the next byte the
receiver expects from sender
TCP Timer Estimation
Premature timeout will result in retransmission
RTT influences selection of timeout
TCP estimates RTT using sampling approach
EstimatedRTT = (1 − α) × EstimatedRTT + α × SampleRTT
TimeoutInterval = EstimatedRTT + 4 × DevRTT
Flow Control
TCP provides flow control service, prevents sender from sending data that
could result in buffer-overflow
The receiver keeps track of the last byte received and the last byte read by
the application layer.
RcvBuffer ≥ [LastByteRcvd − LastByteRead]
Sender keeps track of receiver window size(how much data it could send
without overflowing)
Congestion Control
Packet loss: outcome of network congestion
Congestion occurs when too many end systems attempt to send data
simultaneously, which eventually overwhelms one or more routers
TCP sender responsible for:
Detecting congestion on the path to the receivers host
o Occurrence of timeout
o Receiving duplicate ack.
Reducing/limiting the rate at which it sends data over the congested
path
Managing congestion
How to control sending rate of the sender
Congestion window imposes a constraint on the rate at which the sender
can send data
LastByteSent − LasteByteAcked ≤ min{cwnd,rwnd}
Transmission rate R bps and K TCP connections are going through a link
Fair if average transmission rate of each connection gets an equal share of the link
bandwidth (R/K)
TCP congestion control except 2 scenarios
1. UDP is likely to crowd out TCP traffic in the presence of UDP connections.
2. Parallel TCP connections by the same process or application.
Explicit Congestion Notification
TCP sender receives no explicit congestion indications from network layer
TCP sender relies on timeout events and duplicate ack. To detect
congestion
Router that experiences congestion can set a flag in the network layer
header
Arrival of packet with ECN flag informs the receiver that it should inform
the sender to decrease sending rate
Principles of congestion control in TCP
A lost segment indicates congestion, TCP senders rate needs to be updated
Ack. Segment means we can increase senders rate
TCP’s approach for managing congestion keeps inc. the sending rate until
congestion detected, when detected we decrease
TCP congestion control algorithm is split in 3 stages
It is a distributed asynchronous optimization algorithm
A. Slow Start
1. Cwnd=1 to MSS
2. Initial sending rate = MSS/RTT
3. On successful ack, cwnd increased by 1
4. MSS cwnd = cwnd +MSS
5. When timeout occurs, it resets the cwnd=1 MSS and set a cwnd
threshold to be cwnd/2
B. Congestion Avoidance
1. When the value of cwnd reaches the threshold, TCP enters
congestion avoidance stage
2. Rather than doubling the cwnd, the tcp increases it by 1 MSS x
MSS/cwnd
3. As long as TCP receives ack. Or double ack. It remains in congestion
avoidance state
4. When timeout detected tcp again resets the cwnd to 1 and sets
threshold to cwnd/2 and enters slow start again
C. Fast Recovery (TCP Tahoe = no fast recovery / TCP Reno = fast recovery)
1. If sender receives triple ack., it enters fast recovery
2. Can move from either stage to fast recovery
3. Cwnd increased by 1 for every double ack
4. If time out then go to slow start
5. If ack and cwnd=threshold then go to congestion avoidance
Multiplexing and Demultiplexing
Network process can have 1 or more network sockets
TLP delivers message to socket
Each network socket must have a unique identifier
Multiplexing: Getting message from socket dividing it into segments and
passing the segments to the network layer
Demultiplexing: getting segments from network layer, identifying socket that
should receive the message and passing it to that socket
Transport layer segment must carry the socket identifier
Unique Identifier of Socket: port numbers + IP addresses
UDP socket is identified by destination IP address and destination port number
TCP socket is identified by destination IP address + destination port number +
source IP address + source port number
Reliable data transfer
Data guaranteed to arrive at destination (no loss)
Data integrity guaranteed
Messages delivered in order
However underlying infrastructure is unreliable
Different designs of reliable data transfer
RDT v1.0
RDT over a perfectly reliable channel assumptions:
1. Reliable channel
2. Data is sent in 1 direction
3. No need for feedback
4. Send as many messages as fast as we can
RDT v2.0
RDT over a Channel with bit errors assumptions:
1. Message corruption possible
2. No packet or message loss
3. No out of order packet or messages
Protocol in this case requires feedback from receiver.
Positive feedback = message integrity preserved
On negative acknowledgement sender will resend message until positive
feedback sent.
Sender needs buffer to store original message until positive acknowledgement
It is a stop-and-wait protocol
Problem that feedback itself may be corrupted
RDT v2.1
RDT with sequence number over a channel with bit errors
When sender resends packet after receiving corrupted feedback, new
problem that there will be duplicate packets at receiver side
Need to allow receiver to distinguish between old and new packets
Solution is to add sequence number field to the transport protocol header
section
RDT v3.0
RDT over a lossy Channel with bit errors assumptions:
1. Same as RDT 2.0
2. Msg/packet/acknowledgement might get lost
3. Sender is responsible for detecting lost packets and resolving them using
retransmission
Detecting packet loss: time-based retransmission mechanism using count-down
timer
1. Choose value for countdown timer
2. Start timer each time packet is sent
3. Respond to timer interrupt
4. Stop timer
RDF v3.0
1. Is a RDT protocol
2. It is inefficient (uses stop-and-wait pattern)
3. Alternating-bit protocol (packet seq. numbers alternate between 0/1)
Pipelining
Sender is allowed to send multiple packets without waiting for ack.
Range of sequence number must be increased
Sender and receiver sides may have to buffer more than 1 packet
2 ways to determine buffer size and seq. no. range
Go-Back N (GBN)
Selective Repeat (SR)
Go-Back-N
Sender can send up to N packets without waiting for ack.
At anytime there are U unacknowledged packets in the pipeline where U<=N
U=U-M where 1<=M<=N
1. Let base be the sequence number of the oldest unacknowledged packet.
2. Let nextseqnum be the smallest unused sequence number out of the range
of available sequence numbers.
3. Let [0, base-1] a set of sequence numbers corresponding to acknowledged
packets
4. Let [base, nextseqnum-1] a set of sequence numbers corresponding to
unacknowledged packets that have been sent
5. Let [nextseqnum, base+N-1] a set of sequence numbers that could be used
to send new packets before reaching the stop point (threshold)
When packets arrive out of order they will be ignored and retransmitted
Selective-Repeat (SR)
Sender uses timer to detect potential packet loss (each packet has a timer)
When timer of given packet expires the sender retransmits this packet and
resets the timer
When an ack. Is received its is only used as an indication of receiving a
specific packet
On the receiver side when a packet arrives within the allowed window size,
the packet is stored in a local buffer, and an acknowledgement is sent to
the sender
Receiver will have buffer of size N
Stop-and-wait protocol
With timer, acknowledgment, error detection, sequence number, and
buffering enable building a RDT protocol.
It is inefficient
Can not fully utilize available transmission rate
Mechanisms for designing RDT protocol
1. Checksum
2. Timer
3. Sequence Number
4. Acknowledgment
5. Pipelining
Network Layer
Responsible for enabling host-to-host communication services
2 main categories, data plane and control plane
2 main functions packet forwarding and packet routing
Forwarding: When packet arrives at router input link, router processes packet and
decides output link of that packet
Routing: finds route packet will take from the source to destination
Data plane
All services and functions that enable router to provide forwarding services
Includes:
Reading/writing packet data from input and output ports
Performing error checking
Matching packet to an output port
Typically implemented in the hardware
Forwarding decision is a per-router function that should take a few nanoseconds
Each router uses local routing table to support its packets forwarding decision
Control Plane
Enable routers to discover possible routes for packets from sender to
receiver
Software-defined Networking (SDN) is a modern approach to implement a
control plane in remote servers instead of routers.
Network service model
The set of services offered by the network layer for the communicating hosts
usually defines the service model offered by the network layer
Guaranteed Delivery
Guaranteed Delivery with bounded delay
In-order Delivery
Guaranteed minimal bandwidth
Network Router Architecture
1. Input/Output ports
2. Switching Fabric: connects input ports to output ports
3. Routing Processor: execute control plane functions
Input ports
1. Terminates the incoming physical link at the router
2. Execute packet forwarding and matching and hand over the packet to the
switch fabric
3. Perform queuing if the packets arrival rate is higher than the forwarding
speed/ switch fabric
4. Forward control routing msg to the routing processor
5. Each input port has shadow copy of forwarding/routing table
Forwarding Packets
Destination based forwarding or generalized forwarding
Destination-based: based on destination IP address in packet header
Forward table used as lookup table where IP address associated with one
link interface (output port)
Lookup operations should be fast and constant
In addition the memory access time must be addressed using Ternary
Content Addressable Memory (TCAM)
Generalized forwarding: based on any set of header field values and not limited to
destination IP
Switching Fabric
Responsible for executing forwarding decisions made by router
Moves from 1 input buffer to output buffer
Switching rate indicates speed at which packets can be transferred to the
output port, measured as multiple of input/output line rate
3 types of switching fabrics
o Memory: simplest/ switching under direct control of CPU/ speed
limited by memory bandwidth/ packets can not be forwarded
simultaneously
o Bus: input transfers to output directly/ no intervention by router CPU
over shared bus
o Crossbar: design overcomes bus bandwidth limitations/ consists of
2N buses/ enable fragmenting packets into fixed-length chunks/can
transfer packets simultaneously
Input port Queuing
Switching rate of fabric < combined speed of input links
Only 1 switch fabric that serves all input ports
If incoming traffic exceeds switching rate there will be queuing
delay/packet loss due to a buffer overflow
Head of the line blocking (HOL): queued packet at front of queue prevents
others from moving forward
Output Port Queueing
Occurs when packets arrive from switching fabric faster than output link
transmission rate
Queuing delay will be unbounded/ packet loss when buffer overflow
May use drop-tail policy to handle buffer overflow
Marking packet headers to indicate potential congestion approach used to
notify sender
Scheduling
1. FIFO (first in first out)
2. Priority Queuing (packets assigned to classes)
3. Round Robin (also in classes but we take 1 from each class)
4. Weighted Fair Queuing (same us before each class gets weighted amounted
of service)
IPv4
Main protocol in IP/TCP
Addressing network interfaces
IP Fragmentation
Network links have MTU, largest possible link-level frame, different link
types, different MTUs
Large IP packets divided within the net one packer
Fragments are reassembled only at the final destination
Ethernet frame 1500 bytes while links and WANs is less that 576 bytes
IP addressing
Each host connected to physical network link through network interface
Network interface must have its own IP address
Ip address is written using dotted-decimal notation
Each IP address has a subnet part and a host part
Subnetting means dividing network into 2
CIDR: Classless Inter-Domain Routing
Subnet portion of address of arbitrary length
a.b.c.d/x where x is number of bits in subnet portion of the address
IP address V6.0
Has fixed length header of 40 bytes
Addressing capabilities extended from 32 to 128 bits
V6 vs V4
V6 doesn’t support fragmentation and reassembly
V6 uses new version of ICMP
V6 doesn’t provide error detection
No optional field
Control Plane
Objective is to discover the least cost paths/routes
Could be achieved using per-router control/ logically centralized control
Routing protocols OSPF/BGP/RIP/EIGRP conventional routing approaches
SDN makes clear separation between data and control planes
Per Router Control
Routing algorithm runs on every router
Router is responsible for calculating forward tables
Routers collaborate routing path
Routers exchange connectivity msgs
Control agent on every router responsible for communicating with control
agents
Logically centralized control
Routing algorithm runs on centralized remote controller
Remote controller receives connectivity msgs from routers
Remote controller calculates forwarding tables and sends info ack to router
Control agents don’t connect directly to each other
Centralized algorithms
Least cost path using global knowledge
Graph structure known to every network
All routers see same network layout
Each router runs same routing algorithm to calculate forwarding table
Link-state algorithm
Decentralized algorithms
Goes to several iterations to calculate least cost path
Every router only knows direct connectivity of adjacent routers
Distance vector algorithms
Categorizations
Static vs dynamic routing
Static: do not assume network connectivity change very often
Dynamic: assume connectivity of network change and they run in response to
changes
Load sensitive vs insensitive based on reaction to link-state and traffic load
Link-state routing algorithm
Centralized, network topology is known to all routers in the network
Each router will broadcast connectivity
Router have complete view of topology
Relies on Dijkstra’s shortest path algorithm
Distance Vector Routing Algorithm
Decentralized
Calculates routes until no links info exchanged between router
Asynchronous and self terminating algorithm
Reacts to changes in network topology
Relies on bellman-Ford shortest path algorithm (Can handle graphs with
negative weights)
Link state Distance vector
O(N × E) messages with N nodes and E only exchange messages between
edges. neighbors (but slower)
O(n^2 ) with O(N × E) messages, convergence time varies and suffers
suffers from oscillations from routing loops and count-to-
infinity problem
when the node sends an incorrect link when the node sends an incorrect link
state, it can be tolerated with state, the error propagates through
minimum effect the network.
Intra-AS Routing
Large networks organized into autonomous systems
Routers within same AS are under a single administration
OSPF (Open shortest path first)
Example of intra-AS routing protocol
We can use centralized link-state routing algorithm
Uses msg flooding for advertising link-state info
Open source protocol
Doesn’t specify how link weight calculated (up to AS)
Router broadcasts once every 30 mins or when link-state info change
IP carry OSPF msg between routers
OSPF doesn’t use UDP or TCP
Features:
1. Security
2. Multiple same-cost paths
3. Integrated support for unicast and multicast routing
4. Support partitioning and hierarchy within a single AS.
Inter AS Routing and BGP
Distance vector routing algorithm achieves routing between ISPs and AS
After IP there is BGP (Border Gateway Protocol)
Decentralized and asynchronous protocol
Discover paths between subnets or collection of subnets rather than
individual hosts
Enables routers to gather prefix (subnet) reachability information from
neighboring AS
Enables routers to discover best routes to given subnets at other ASs
Routers within same AS are either gateway (connects to gateway routers at
other AS) or internal(only connects to hosts and routers in its own AS)
routers
Operates over semi-permanent TCP connection
Advertisement message contains NEXT-HOP, AS-Path, destination prefix
ICMP (internet control message protocol)
Ip protocol is unreliable and not designed to give feedback
Enables hosts and routers to communicate info about network layer
operations
Used to send errors and feedback
Carried over IP protocol as an IP protocol payload
Has type and code fields and fingerprint of IP packet that caused ICMP
message
IP fingerprint contains IP packet header and first 8 bytes of IP datagram
PA 8 Questions
CLASSES A B C
A = 0 , 24 hosts/ 8 networks
B = 10, 16 hosts 16 networks
C = 110, 8 host 24 networks
A route oscillation might occur if a destination is reachable from different paths, and when the link-state
algorithm operates in load-sensitive mode, the routes will continue to change.
A routing loop occurs when we use distance-vector to route packets and the network connectivity
changes such that a link cost changes or the link -state changes