Internet Routing and Forwarding Explained
Internet Routing and Forwarding Explained
Networks
[Link]. Course, 1st Semester 2025-2026
Prof. Dr. Emad Hasan Abbood
Routing on the Internet
Forwarding and Routing
The network layer must determine the route or path taken by packets
as they flow from a sender to a receiver. The algorithms that
calculate these paths are referred to as routing algorithms.
Connection Setup
Some network-layer architectures, for
example, ATM, frame relay, and MPLS
require the routers along the chosen
path from source to destination to
handshake with each other in order to
set up state before network-layer data
packets within a given source-to-
destination connection can begin to
flow.
Advanced Computer Networks Prof. Dr. Emad H. Abbood 5
Four components:
Inside a Router: Forwarding Function 1. Input ports
2. Switch Fabric
3. Output ports
4. Routing processor
Performs the
physical layer
function of
terminating an
incoming physical
link at a router
Performs link-layer
functions needed
to interoperate
with the link layer
at the other side of
the incoming link
▪ In SDN routers:
o responsible for communicating with the remote controller in order to (among other activities)
receive forwarding table entries computed by the remote controller, and install these entries
in the router’s input ports.
o The routing processor also performs the network management functions
The forwarding table is computed and updated by the routing processor, with a shadow copy typically
stored at each input port. The forwarding table is copied from the routing processor to the line cards
over a separate bus (e.g., a PCI bus) indicated by the dashed line from the routing processor to the
input line cards in the previous figure. With a shadow copy, forwarding decisions can be made locally,
at each input port, without invoking the centralized routing processor on a per-packet basis and thus
avoiding a centralized processing bottleneck.
• Lookup is conceptually simple (search through the forwarding table looking for the longest prefix
match)
• In Gigabit transmission rates, this lookup must be performed in nanoseconds
▪ techniques beyond a simple linear search through a large table are needed
▪ surveys of fast lookup algorithms can be found in [Gupta 2001, Ruiz-Sanchez 2001]
▪ On-Chip DRAM and faster SRAM
▪ TCAM (Ternary Content Address Memories) are used for lookups
• A packet may be temporarily blocked from entering the switching fabric if packets from other input
ports are currently using the fabric
• A blocked packet will be queued at the input port and then scheduled to cross the fabric at a later
point in time
▪ Output port processing takes packets that have been stored in the output port’s
memory and transmits them over the output link. This includes selecting and de-
queueing packets for transmission, and performing the needed link layer and
physical-layer transmission functions.
Assume arriving packets have same equal lengths and arrive in synchronous manner (the time to
send a packet on any link is equal to the time to receive a packet on any link), 𝑅𝑠𝑤𝑖𝑡𝑐ℎ is N times
faster than 𝑅𝑙𝑖𝑛𝑒 . Then only: Negligible queuing will occur at input port
This is because even in the worst case, where all N input lines are receiving packets, and all packets are to
be forwarded to the same output port, each batch of N packets (one packet per input port) can be cleared
through the switch fabric before the next batch arrives
Example:
If Link capacity = 10Gbps, RTT = 250 msec -> B = 0.625 Gbytes
• [Appenzeller 2004], suggest that when there are a large number of TCP flows (N) passing through
a link, the amount of buffering needed is:
𝐶
𝐵𝑢𝑓𝑓𝑒𝑟 𝑠𝑖𝑧𝑒 𝐵 = 𝑅𝑇𝑇 ×
𝑁
With a large number of flows typically passing through large backbone router links the value of
N can be large, with the decrease in needed buffer size becoming quite significant.
Flow table entries are also needed at s1 to forward the datagrams received from s2 to either h1 or h2;
and flow table entries are needed at s3 to forward datagrams received on interface 4 from s2 over
interface 3 toward s1.
If there were no other entries in s2’s flow table, then only traffic from 10.3.*.* would be forwarded to the
hosts attached to s2.
data
plane
CA 2. control, data
CA CA CA CA
plane separation
1: generalized “flow-based”
forwarding (e.g., OpenFlow)
routing
…
▪ Fast, simple, commodity switches implementing
access load
generalized data-plane forwarding in hardware control balance
SDN-controlled switches
routing
…
▪ Maintain network state information
access load
control balance
▪ Interacts with network control
control
applications “above” via northbound API northbound API plane
routing
…
▪ “brains” of control: implement access load
control balance
control functions using lower-level control
northbound API plane
services, API provided by SDN
SDN Controller
controller (network operating system)
or SDN controller
SDN-controlled switches
▪ The managing server actively controls a managed device by sending it configurations, which are
specified in a structured XML document, and activating a configuration at the managed device.
▪ NETCONF uses a remote procedure call (RPC) paradigm, where protocol messages are also
encoded in XML and exchanged between the managing server and a managed device over a
secure, connection-oriented session such as the TLS (Transport Layer Security) protocol over TCP.
LAN LAN
Example: the least-cost path between u and w is (u, x, y, w) ⇒ c(u, x, y, w) = 3. If all edges have
the same cost, then least-cost path = shortest path
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
Initialize:
N’ = current node Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
N’ = { u }
0 u 2,u 5,u 1,u ∞ ∞
for all nodes v
if v is a neighbor of u
D(v) = c(u, v)
else
D(v) = ∞
Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
Loop until 𝑵 = 𝑵’: 0 u 2,u 5,u ∞ ∞
1, 𝑢
Find a node n not in N’ such that D(n) is a
minimum 1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
→ Node x has minimum D(n)
add n to N’
N’ = {u, x} Cost to
for each neighbor m of n not in N’: Cost to 𝑤 We now
𝑣 is Ignore 𝑥, it
for each neighbor of node x is better have a
not better is in 𝑵’
D(m) = min( D(m), D(n) + c(n, m)) through 𝑥 path to 𝑦
through 𝑥
new cost = old cost or cost through x
if D(m) changed, set p(m) = n
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
Loop until 𝑵 = 𝑵’: Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
find n not in N’ such that D(n) is
a minimum 0 u 2,u 5,u 1, 𝑢 ∞ ∞
→ Nodes v & y have minimum D(n),
Pick any one: we choose y 1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
add n to N’ 2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
N’ = {u, x, y}
for each neighbor m of n not in N’:
for each neighbor of node y Cost to w We now
D(m) = min(D(m), D(n) + c(n, m)) Skip 𝑥 and 𝑦,
is even better have a
new cost = old cost or cost through x are in 𝑵’
through y path to 𝑧
if D(m) changed, set p(m) = n
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
Loop until 𝑵 = 𝑵’: Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
find n not in N’ such that D(n) is
a minimum 0 u 2,u 5,u 1, 𝑢 ∞ ∞
→ Nodes v has minimum D(n)
1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
add n to N’ 2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
N’ = {u, x, y, v}
for each neighbor m of n not in N’: 3 𝑢𝑥𝑦𝑣 3, 𝑦 4, 𝑦
for each neighbor of node y
D(m) = min(D(m), D(n) + c(n, m)) No change
new cost = old cost or cost through x No improvement Z is not a
if D(m) changed, set p(m) = n (2+3) ≮ 3 neighbor
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
Loop until 𝑵 = 𝑵’: Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
find n not in N’ such that D(n) is
a minimum 0 u 2,u 5,u 1, 𝑢 ∞ ∞
→ Nodes w has minimum D(n)
1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
add n to N’ 2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
N’ = {u, x, y, v, w}
for each neighbor m of n not in N’: 3 𝑢𝑥𝑦𝑣 3, 𝑦 4, 𝑦
for each neighbor of node y 4, 𝑦
4 𝑢𝑥𝑦𝑣𝑤
D(m) = min(D(m), D(n) + c(n, m))
new cost = old cost or cost through x
if D(m) changed, set p(m) = n No improvement
(3+5) ≮ 4
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
Loop until 𝑵 = 𝑵’: Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
find n not in N’ such that D(n) is
a minimum 0 u 2,u 5,u 1, 𝑢 ∞ ∞
→ Node z is the only one left
1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
add n to N’ 2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
N’ = {u, x, y, v, w, z}
for each neighbor m of n not in N’: 3 𝑢𝑥𝑦𝑣 3, 𝑦 4, 𝑦
There are no neighbors not in 𝑵’! 4, 𝑦
4 𝑢𝑥𝑦𝑣𝑤
Complete
5 𝑢𝑥𝑦𝑣𝑤𝑧
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
(3) u is x’s x y
predecessor
𝑵 = 𝑵’: Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
All nodes are in 𝑵’
0 u 2,u 5,u 1, 𝑢 ∞ ∞
For each node, we have the total
cost from the source and the 1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
predecessor along that path.
2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
We can look up the predecessor to
find its predecessor 3 𝑢𝑥𝑦𝑣 3, 𝑦 4, 𝑦
4 𝑢𝑥𝑦𝑣𝑤 4, 𝑦
Example: least-cost path from u → y
is u → x → y 5 𝑢𝑥𝑦𝑣𝑤𝑧
2 5
𝐷(𝑣): cost of least-cost path from source to 𝑣
2 3
𝑝(𝑣): previous node (neighbor of v) along the least-cost path u 1 z
1 2
to 𝑣
1
𝑁 : subset of nodes for which we found the least-cost path
′
x y
We can create a forwarding table that
stores the next hop on the least-cost Step 𝑁′ 𝐷(𝑣), 𝑝(𝑣) 𝐷(𝒘), 𝑝(𝒘) 𝐷(𝒙), 𝑝(𝒙) 𝐷(𝒚), 𝑝(𝒚) 𝐷(𝒛), 𝑝(𝒛)
route
Forwarding table for node u 0 u 2,u 5,u 1, 𝑢 ∞ ∞
Dest. link 1 𝑢𝑥 2, 𝑢 4, 𝑥 2, 𝑥 ∞
v uv 2 𝑢𝑥𝑦 2, 𝑢 3, 𝑦 4, 𝑦
w ux 3 𝑢𝑥𝑦𝑣 3, 𝑦 4, 𝑦
x ux 4 𝑢𝑥𝑦𝑣𝑤 4, 𝑦
y ux 5 𝑢𝑥𝑦𝑣𝑤𝑧
z ux
• What can be done to prevent such oscillations (which can occur in any algorithm, not just an LS algorithm,
that uses a congestion or delay-based link metric)? One solution would be to mandate that link costs not
depend on the amount of traffic carried—an unacceptable solution since one goal of routing is to avoid
highly congested (for example, high-delay) links.
• Another solution is to ensure that not all routers run the LS algorithm at the same time. This seems a more
reasonable solution, since we would hope that even if routers ran the LS algorithm with the same periodicity,
the execution instance of the algorithm would not be the same at each node.
• Interestingly, researchers have found that routers in the Internet can self-synchronize among themselves
[Floyd Synchronization 1994]. That is, even though they initially execute the algorithm with the same period
but at different instants of time, the algorithm execution instance can eventually become, and remain,
synchronized at the routers. One way to avoid such self-synchronization is for each router to randomize the
time it sends out a link advertisement.
▪ If this results in a change to x’s DV, it sends the new DV to its neighbors
Each cost estimate 𝐷𝑥 (𝑦) converges to the actual least-cost 𝐷𝑥 (𝑦)
x 0 2 7 x ∞ ∞ ∞ x ∞ ∞ ∞
from
from
y ∞ ∞ ∞ y 2 0 1 y ∞ ∞ ∞ x 7 z
z ∞ ∞ ∞ z ∞ ∞ ∞ z 7 1 0
from
from
y ∞ ∞ ∞ y 2 0 1 y ∞ ∞ ∞
z ∞ ∞ ∞ z ∞ ∞ ∞ z 7 1 0
c(y, x) = 2 c(z, x) = 7
Advanced Computer Networks Prof. Dr. Emad H. Abbood 79
DV Example y
Node x DV table Node y DV table Node z DV table
Cost to Cost to Cost to
2 1
x y z x y z x y z
from
x 0 2 7 x 0 2 7 x 0 2 7
from
from
y ∞ ∞ ∞ y 2 0 1 y ∞ ∞ ∞ x 7 z
z ∞ ∞ ∞ z ∞ ∞ ∞ z 7 1 0
From y: c(y,z) is 1 Node y sends its DV {2, 0, 1}
c(x, z) = c(x, y) + c(y,z) = 2 + 1 = 3 to nodes x and z
Less than old value, 7
Node z sends its DV {7, 1, 0}
Node x DV table Node y DV table Node z DV table
to nodes x and y
Cost to Cost to Cost to
x y z x y z x y z Every update to a node’s
x 0 2 3 x 0 2 7 x 0 2 7 DV also updates the
from
from
from
forwarding table
y 2 0 1 y 2 0 1 y 2 0 1 From y: c(y,x) is 2
c(z, x) = c(z,y) + c(y,x) = 1 + 2 = 3
z 7 1 0 z 7 1 0 z 3 1 0 Less than old value, 7
c(x, y) = 2 c(y, x) = 2 c(z, y) = 1
Advanced Computer Networks Prof. Dr. Emad H. Abbood 80
DV Example y
Node x DV table Node y DV table Node z DV table
Cost to Cost to Cost to
2 1
x y z x y z x y z
from
x 0 2 7
from
x 0 2 3 x 0 2 7
from
y 2 0 1 y 2 0 1 y 2 0 1 x 7 z
z 7 1 0 z 7 1 0 z 3 1 0
• Node x sends its DV {0, 2,
3} to nodes y and z
Node z DV table
• Node y’s vector did not
Node x DV table Node y DV table
change – it stays quiet
Cost to Cost to Cost to • Node z sends its DV {3, 1,
x y z x y z x y z 0} to nodes x and y
from
from
x 0 2 3
from
x 0 2 3 x 0 2 3
y 2 0 1 y 2 0 1 y 2 0 1
z 3 1 0 z 3 1 0 z 3 1 0
We converged. Everyone has the same view of the network. Nobody has updates to send.
Advanced Computer Networks Prof. Dr. Emad H. Abbood 81
Link cost changes
❖ The DV algorithm remains quiet once it converges until some link cost changes
❖ If a node detects link cost change between itself and a neighbor
o It updates its distance vector
o If there is a change in the cost of any least-cost path
o it informs its neighbors of the new distance vector
o Each neighbor computes a new least cost
▪ If the value changed from its previous value, it sends its DV to its neighbors
▪ Recompute until values converge
AS1 must:
• learn which destinations are
reachable through AS2,
which through AS3
• propagate this reachability
info to all routers in AS1
Multihomed stub AS
❑ Like a stub AS but connected to multiple other ASes
❑ Provides fault tolerant connectivity for systems in the AS but does not offer routing from
other ASes
Transit AS
❑ Provides connections through itself to other networks
Solution
The 21 timers are listed below:
o Periodic timer: 1
o Expiration timer: 20 − 5 = 15
o Garbage collection timer: 5
W X Y
A D B k
W X Y
A D B B
What do we merge?
• Destination z via A is 5 hops vs. 7
• We know of a destination to w (2
hops via A)
OSPF Areas
o Subdivision of an OSPF autonomous system
o Each area
➢ Runs its own OSPF link state routing algorithm
➢ Has one or more area border routers (ABR) to route outside the area
Backbone area:
o Contains all area border routers in the AS (and possibly others)
o Inter-area routing
➢ route to an ABR, through the backbone, and to the ABR in the destination area
Advanced Computer Networks Prof. Dr. Emad H. Abbood 101
Inter-AS Routing: BGP
Border Gateway Protocol: BGP
❑ Border Gateway Protocol: exterior gateway protocol (EGP)
• inter-AS protocol: routes between autonomous systems (AS)
• BGP version 4 is the standard inter-AS protocol in the Internet