Table of Contents
- Control Plane Overview
- Per-Router Control Plane
- Dynamic Routing
- Routing Protocols
- Graph Abstraction & Link Costs
- Routing Algorithm Classification
- Dijkstra's Link-State Algorithm
- Distance Vector Algorithm
- Comparison: DV vs LS
- Scalable Routing – Autonomous Systems (AS)
- Intra-AS Routing Protocols
- Inter-AS Routing: BGP
- SDN Control Plane
- Generalized Forwarding & OpenFlow
- SDN Controller Components
Control Plane Overview
Two approaches to structuring the network control plane:
- Per-router control (traditional) – each router runs its own routing algorithm
- Logically centralized control – Software Defined Networking (SDN)
Two Key Network-Layer Functions
| Function | Plane | Description |
|---|---|---|
| Forwarding | Data Plane | Move packets from router's input to appropriate output |
| Routing | Control Plane | Determine the route taken by packets from source to destination |
Think of forwarding as physically moving a car through a road intersection, and routing as planning the trip on a map beforehand.
Per-Router Control Plane
- Individual routing algorithm components run in each and every router
- Routers interact with each other in the control plane
- Each router maintains its own local forwarding table

- แต่ละ router ต้องรัน routing algorithm
- Router แต่ละตัวสื่อสาร แชร์ information
Like every taxi driver knowing their own city map and independently deciding the best route — no central dispatcher.
Dynamic Routing
- Also known as Adaptive Routing
- Router adds a new route in the routing table for each packet in response to changes in condition or topology of the network
- Dynamic protocols are used to discover new routes
- If any route goes down → automatic adjustment is made
Dynamic Routing Protocol Hierarchy

Dynamic Routing
├── IGP (Interior Gateway Protocol)
│ ├── Distance Vector
│ │ ├── RIP
│ │ └── IGRP
│ ├── Link State
│ │ └── OSPF
│ └── Hybrid
│ └── EIGRP
└── EGP (Exterior Gateway Protocol)
└── Path Vector
└── BGP
Routing Protocols

- Goal: Determine "good" paths from sending host to receiving host through the network of routers
- Path: Sequence of routers packets traverse from source to destination
- "Good" means: least cost, fastest, least congested
- Cost อาจจะเป็น number of hop??
- Routing is considered a "top-10" networking challenge
Graph Abstraction & Link Costs

- Network modeled as a graph:
- : set of routers =
- : set of links =
- = cost of direct link connecting node and
- , (not direct neighbors)
- Cost defined by network operator:
- Could always be 1
- Inversely related to bandwidth
- Inversely related to congestion
Like a GPS map where road "costs" can represent distance, traffic, or road quality — the router picks the cheapest path.
Routing Algorithm Classification

By Information Type
| Type | Description | Algorithm |
|---|---|---|
| Global (Link State) | All routers have complete topology & link cost info (รู้ info ของทุก router เลย) | Dijkstra's |
| Decentralized (Distance Vector) | Routers know only link costs to direct neighbors; iterative exchange (ไม่ค่อยรู้อะไร) | Bellman-Ford |
By Rate of Change
| Type | Description |
|---|---|
| Static | Routes change slowly over time (require human to do ไงงง) |
| Dynamic | Routes change quickly; periodic updates or in response to link cost changes |
Dijkstra's Link-State Algorithm
Properties
- Centralized: network topology and link costs known to all nodes (via link state broadcast)
- Computes least-cost paths from one source node to all other nodes → gives forwarding table
- Iterative: after iterations, knows least-cost path to destinations
Notation
| Symbol | Meaning |
|---|---|
| Direct link cost from node to ; if not direct neighbors | |
| Current estimate of cost of least-cost path from source to destination | |
| Predecessor node along path from source to | |
| Set of nodes whose least-cost-path is definitively known |
Algorithm (Pseudocode)
Initialization:
N' = {u}
for all nodes e:
if e adjacent to u:
D(e) = c(u, e)
else:
D(e) = ∞
Loop:
find a not in N' such that D(a) is minimum
add a to N'
update D(b) for all b adjacent to a and not in N':
D(b) = min(D(b), D(a) + c(a, b))
until all nodes in N'
Key Update Formula
Like Google Maps updating your estimated arrival time at each turn — it always keeps the shortest known path and revises when a faster route is found.
Example Table (source = u)

| Step | N' | D(v),p(v) | D(w),p(w) | D(x),p(x) | D(y),p(y) | D(z),p(z) |
|---|---|---|---|---|---|---|
| 0 | u | 2,u | 5,u | 1,u | ∞ | ∞ |
| 1 | ux | 2,u | 4,x | — | 2,x | ∞ |
| 2 | uxy | 2,u | 3,y | — | — | 4,y |
| 3 | uxyv | — | 3,y | — | — | 4,y |
| 4 | uxyvw | — | — | — | — | 4,y |
| 5 | uxyvwz | — | — | — | — | — |
Resulting Forwarding Table (from u)

| Destination | Outgoing Link |
|---|---|
| v | (u,v) |
| x | (u,x) |
| y | (u,x) |
| w | (u,x) |
| z | (u,x) |
| 
- Iterative, asynchronous: each local iteration caused by:
- Local link cost change
- DV update message from neighbor
- Distributed, self-stopping: node notifies neighbors only when its DV changes
- No notification received → no actions taken
State Information Diffusion
📄 10ComputerNetwork-NetworkLayer_Part4 pages 19 - 32.pdf
| Time | Propagation Reach |
|---|---|
| t=0 | Only at node |
| t=1 | Reaches 1-hop neighbors (e.g., ) |
| t=2 | Reaches 2-hop neighbors (e.g., , ) |
| t=3 | Reaches 3-hop neighbors |
| t=4 | Reaches 4-hop neighbors |
Like a rumor spreading through a social network — each round of gossip spreads the information one more step away.
Link Cost Changes
- "Good news travels fast":
- : node detects link-cost decrease → updates DV → informs neighbors
- : neighbor receives update → recomputes → sends new DV
- : original node receives update → no change → stops
Comparison: DV vs LS
| Feature | Distance Vector (DV) | Link State (LS) |
|---|---|---|
| Convergence | Slow (neighbor only) | Fast (เอาข้อมูลจากทุกอันไง) |
| Updates | Frequently | Event Triggered |
| Loops | Prone to routing loops | Less subjected to loops |
| Configuration | Easy | Difficult |
| Network Types | Broadcast for updates | Multicast for updates |
| Topology | Doesn't know network topology | Knows entire network topology |
| Auto Route Summarization | No | Yes |
| Path Calculation | Hop Count | Shortest Path (metric) |
| Scalability | Limited | Can be highly scalable |
| Protocols | RIP, IGRP | OSPF, IS-IS |
| Algorithm | Bellman-Ford | Dijkstra |
| Manual Route Summarization | Yes | Yes |
| Metric | Hop Count | Link Cost |
DV = asking friends for directions (each only knows their local area). LS = having a full city map yourself.
Scalable Routing – Autonomous Systems (AS)
Why Scalability Matters
- Billions of destinations → can't store all in routing tables; exchange would swamp links
- Administrative autonomy → each network admin wants control over their own network
Solution: Aggregate into Autonomous Systems (AS)
- Intra-AS (intra-domain): routing within the same AS
- All routers in AS run the same intra-domain protocol
- Gateway router: at edge of AS, has links to routers in other ASes

- Inter-AS (inter-domain): routing between ASes
- Gateway routers perform inter-domain routing


- Gateway routers perform inter-domain routing
Forwarding Table Construction



- Intra-AS routing determines entries for destinations within AS
- Inter-AS + Intra-AS together determine entries for external destinations
Inter-AS Routing Role
When AS1 router receives datagram destined outside AS1:
- Learn which destinations are reachable through AS2
- Propagate reachability info to all routers in AS1

Intra-AS Routing Protocols
Most common protocols:
RIP (Routing Information Protocol) — RFC 1723
Protocol นี้ถ้ามี Hop เยอะ (20 hops) อะไรงี้ คือมันจะไม่เวิร์คเลยนะ
Based on Distance Vector (Check!!)
- Type: Distance Vector (DV)
- Sends full routing table to neighbor every 30 seconds
- Maximum hops: 15 routers (16 = infinity/unreachable)
- Summarizes networks to class-full boundary by default
- Administrative distance: 120
- Multicast address: 224.0.0.9
- No longer widely used
RIPv1 vs RIPv2
| Feature | RIPv1 | RIPv2 |
|---|---|---|
| Protocol type | Classful (only) | Classless |
| Updates | Broadcast | Multicast |
| Update trigger | Every 30s | Triggered (on change) |
| VLSM support | No | Yes |
| Authentication | No | Yes |
EIGRP (Enhanced Interior Gateway Routing Protocol)
Based on Distance Vector (Check!!)
- Advanced Distance Vector protocol developed by Cisco (open since 2013 — RFC 7868)
- Enhancement of IGRP
- Extremely quick convergence with minimal network traffic
Default composite metric uses:
- Bandwidth — slowest bandwidth along the path (source → destination)
- Delay — cumulative sum of all interface delays (in tens of microseconds)
Optional (not recommended — causes frequent recalculation):
- Reliability — worst reliability between source and destination
- Load — worst load on a link between source and destination
OSPF (Open Shortest Path First) — RFC 2328
- "open": publicly available standard
- Type: Link-State
- Each router floods OSPF link-state advertisements directly over IP (not TCP/UDP) to all routers in entire AS
- Multiple link cost metrics possible: bandwidth, delay
- Each router has full topology → uses Dijkstra's algorithm to compute forwarding table
- Security: all OSPF messages authenticated (prevent malicious intrusion)
Hierarchical OSPF
- Two-level hierarchy: local area + backbone
- Link-state advertisements flooded only within area or backbone
- Each node has detailed area topology; only knows direction to reach other destinations

Router types:
| Router Type | Role |
|---|---|
| Internal routers | Flood LS in area only; compute routing within area; forward to outside via area border router |
| Area border routers | Summarize distances to destinations in own area; advertise in backbone |
| Backbone routers | Run OSPF limited to backbone |
| Boundary routers | Connect to other ASes |
Dynamic Routing Protocol Comparison
| Feature | RIP | OSPF | EIGRP |
|---|---|---|---|
| Convergence time | Slow | Fast | Fast |
| VLSM | No (v2: Yes) | Yes | Yes |
| Bandwidth usage | High | Low | Low |
| Resources usage | Low | High | Low |
| Multiple path support | No | Yes | Yes |
| Scalability | No | Yes | Yes |
| Patented | No | No | Yes |
| Non-IP Protocol | No | No | Yes |
- RIP เวลามันส่ง ส่งทั้งตาราง, OSPF, EIGRP ส่งเฉพาะตัวที่เปลี่ยน มันก็เลยเร็วกว่าป้ะ???? CHECK!
Inter-AS Routing: BGP
For connecting multiple AS together!!
BGP (Border Gateway Protocol) — the de facto inter-domain routing protocol
Called the "glue that holds the Internet (network of network (AS)) together"
- Allows subnet to advertise its existence and the destinations it can reach to the rest of the Internet
- Provides each AS a means to:
- eBGP: obtain subnet reachability info from neighboring ASes
- iBGP: propagate reachability info to all AS-internal routers
- Determine "good" routes based on reachability information and policy

BGP Session

สมมติ X (SIIT) มา join ใหม่ AS 3 ขอซื้อ 5 public IP, AS3 ต้อง broadcast ผ่าน gateway router ไปให้ autonomous system อื่น ๆ
AS 2 ก็มีสิทธิที่จะส่ง (forward) information ให้ AS 1 หรือไม่ส่งก็ได้
ถ้าส่ง → ทีนี้ทุกคนก็จะรู้แล้ว ถ้าอยาก reach X ต้องไปไหน
- Two BGP routers ("peers") exchange BGP messages over TCP
- Advertising paths to different destination network prefixes
- BGP is a "path vector" protocol
eBGP vs iBGP
| Protocol | Scope | Purpose |
|---|---|---|
| eBGP | Between ASes | Learn reachability from neighboring ASes |
| iBGP | Within AS | Propagate reachability inside AS |
- Gateway routers run both eBGP and iBGP
Path Attributes
- BGP advertised route = prefix + attributes
AS-PATH: list of ASes through which the prefix advertisement has passedNEXT-HOP: specific internal-AS router to next-hop AS
Policy-Based Routing
- Gateway uses import policy to accept/decline path (e.g., never route through AS Y)
- AS policy determines whether to advertise path to other neighboring ASes
BGP Route Selection Order
Path selection เลือกยังไงงง???
- Local preference value attribute: policy decision
- Shortest AS-PATH
- Closest NEXT-HOP router: hot potato routing → choose local gateway with least intra-domain cost
- เวลามี hot potato อยู่ในมือ ก็อยากจะรีบส่ง ๆ ไป55555
- Additional criteria
BGP Path Advertisement Example

- AS3 router
3asends pathAS3, Xto AS2 router2c(via eBGP) - AS2 router
2cacceptsAS3, X→ propagates (via iBGP) to all AS2 routers - AS2 router
2aadvertises pathAS2, AS3, Xto AS1 router1c(via eBGP)
Why Different Intra- vs Inter-AS Routing?
| Dimension | Intra-AS | Inter-AS |
|---|---|---|
| Policy | Single admin; policy less of an issue | Admin wants control over traffic routing |
| Scale | Hierarchical routing reduces table size | Saves routing update traffic |
| Performance | Can focus on performance | Policy dominates over performance |
Title
จบคาบ March 26
SDN Control Plane
แต่ละ router ต้องลง Control Agent → เช็ค status of everything, network แล้วก็ report ให้ server
ถ้ามีข้อมูลมาใหม่ remote controller ก็จะทำ re-calculation!
- ตัวใหญ่ เปลี่ยนเป็น Switch L3 ???? ถามจารย์
Motivation (~2005 renewed interest)
Traditional Internet layer: distributed, per-router control
- Monolithic routers run proprietary OS (e.g., Cisco IOS) with proprietary protocol implementations
- Different "middleboxes" for different functions (firewalls, NAT, load balancers)
Problem: Traffic engineering is very difficult with traditional routing

- จากรูปด้านบนนะ
- Want to force path
u→v→w→zinstead ofu→x→y→z? → Must re-define link weights - Want load balancing across both paths? → Can't do with traditional routing
- Want to route same destination differently based on source? → Can't do with destination-based forwarding
SDN Solution

Data plane act like a BODY (มีการส่งข้อมูลจริง ๆ ก็ตรงนี้)
Control plane act like a BRAIN (อันนี้ทำการ Calculate ให้แทน) → Routing, Security, Access Control
Table ที่อยู่ในแต่ละ Router ที่ได้มาจาก Server มันไม่ใช่แค่ normal forwarding table anymore เราจะเรียกว่า Flow Table, contain much more information
4 Key SDN Characteristics

- Generalized "flow-based" forwarding (e.g., OpenFlow)
- Control, data plane separation
- Control plane functions external to data-plane switches
- Programmable control applications
SDN is like separating the GPS navigation app (control plane) from the car's engine (data plane) — the app can be updated independently.
Why Logically Centralized Control?
- Easier network management: avoid router misconfigurations; greater traffic flow flexibility
- Table-based forwarding (OpenFlow API) allows "programming" of routers
- Centralized programming: compute tables centrally and distribute → easier
- Distributed programming: run algorithm in every router → harder
- Open (non-proprietary) implementation of control plane
SDN Architecture

┌──────────────────────────────────────────┐
│ Network-Control Applications │ ← routing, access control, load balance
│ (Routing) (Access Ctrl) (Load Balance) │
└──────────────┬───────────────────────────┘
│ northbound API
┌──────────────▼───────────────────────────┐
│ SDN Controller (Network OS) │ ← control plane
└──────────────┬───────────────────────────┘
│ southbound API
┌──────────────▼───────────────────────────┐
│ SDN-Controlled Switches │ ← data plane
└──────────────────────────────────────────┘
Three SDN Component
1. Data-Plane Switches

- Fast, simple, commodity switches implementing generalized data-plane forwarding in hardware
- Flow (forwarding) table computed and installed under controller supervision
- API for table-based switch control (e.g., OpenFlow)
- Protocol for communicating with controller (e.g., OpenFlow)
2. SDN Controller (Network OS)

- Maintains network state information
- Interacts with network control apps "above" via northbound API
- Interacts with network switches "below" via southbound API
- Implemented as distributed system for performance, scalability, fault-tolerance, robustness
Example: RYU OpenFlow Controller (น่าจะเป็น Open Source รึเปล่า)
3. Network-Control Applications

- "Brains" of control: implement control functions using lower-level services from SDN controller
- Unbundled: can be provided by 3rd party (distinct from routing vendor or SDN controller)
Generalized Forwarding & OpenFlow
Generalized Forwarding: Match Plus Action
- Each router contains a forwarding table (aka: flow table)
- "Match plus action" abstraction: match bits in arriving packet → take action
| Forwarding Type | Match Field | Actions |
|---|---|---|
| Destination-based | Dest. IP address | Forward out link |
| Generalized | Many header fields | drop / copy / modify / log |
| ![[Screenshot 2026-04-02 at 1.34.38 PM.png | center | 550]] |
Flow Table Abstraction
- Flow: defined by header field values (link-, network-, transport-layer fields)
- Generalized forwarding = simple packet-handling rules:
- Match: pattern values in packet header fields
- Actions: drop, forward, modify packet; or send to controller
- Forward ก็สามารถ ระบุได้ว่าให้ไป port อะไร
- Modify dst IP, src IP, port อะไร ทำได้หมด
- Priority: disambiguate overlapping patterns
- Counters:
#bytesand#packets

Example Flow Table
| Match | Action |
|---|---|
src=*.*.*.*, dest=3.4.*.* | forward(2) |
src=1.2.*.*, dest=*.*.*.* | drop |
src=10.1.2.3, dest=*.*.*.* | send to controller |
(* = wildcard) |
แล้วแบบนี้มันทำหน้าที่เหมือน Firewall?
Contents
OpenFlow: Flow Table Entries

Structure: Match | Action | Stats
Actions:
- Forward packet to port(s)
- Drop packet
- Modify fields in header(s)
- Encapsulate and forward to controller
Header fields matchable (across layers):
| Layer | Fields |
|---|---|
| Link | Ingress Port, Src MAC, Dst MAC, Eth Type, VLAN ID, VLAN Pri |
| Network | IP Src, IP Dst, IP Proto, IP ToS |
| Transport | TCP/UDP Src Port, TCP/UDP Dst Port |
OpenFlow Examples
Flow Table และ concept SDN เราสามารถทำให้ Switch กลายเป็น router, firewall ก็ได้ + …. อื่น ๆ อีกมากมาย
Destination-based forwarding:

- IP datagrams to
51.6.0.8→ forward to port 6
Firewall:

- Block all datagrams to TCP port 22 (SSH): match
TCP d-port = 22→ drop

- Block all from host
128.119.1.1: matchIP Src = 128.119.1.1→ drop
OpenFlow Abstraction: Unifies Different Devices
| Device | Match | Action |
|---|---|---|
| Router | Longest destination IP prefix | Forward out a link |
| Switch | Destination MAC address | Forward or flood |
| Firewall | IP addresses and TCP/UDP port numbers | Permit or deny |
| NAT | IP address and port | Rewrite address and port |
SDN Controller Components
Three Layers of SDN Controller

┌──────────────────────────────────────────────────┐
│ Interface, abstractions for network control apps │
│ [ network graph ] [ RESTful API ] [ intent ] │
├──────────────────────────────────────────────────┤
│ Network-wide distributed, robust state management │
│ [ statistics ] [ flow tables ] [ Link-state info ]│
│ [ host info ] [ switch info ] │
├──────────────────────────────────────────────────┤
│ Communication to/from controlled devices │
│ [ OpenFlow ] [ SNMP ] │
└──────────────────────────────────────────────────┘
| Layer | Role |
|---|---|
| Interface Layer | Abstractions API for network control apps |
| State Management | Distributed database of network links, switches, services |
| Communication | Communicate between SDN controller and controlled switches |
SDN: Control/Data Plane Interaction Example (Link Failure)

- Switch
S1experiences link failure → uses OpenFlow port status message to notify controller - SDN controller receives OpenFlow message → updates link status info
- Dijkstra's routing algorithm (registered for link status changes) → is called
- Dijkstra's algorithm accesses network graph info in controller → computes new routes
- Link state routing app interacts with flow-table-computation component → computes new flow tables
- Controller uses OpenFlow to install new tables in switches that need updating
Summary
Routing Algorithms
- Link State (Dijkstra): global view, fast convergence → used in OSPF
- Distance Vector (Bellman-Ford): local view, iterative → used in RIP
Routing Protocols
- RIP/RIPv2 — DV, hop count metric, max 15 hops
- EIGRP — advanced DV, Cisco, composite metric
- OSPF — LS, hierarchical, uses Dijkstra
- BGP — path vector, inter-AS, policy-based
SDN
- Separates control plane (centralized) from data plane (distributed switches)
- Uses OpenFlow for match+action forwarding
- Controller has northbound (to apps) and southbound (to switches) APIs
