Routers:
2 types route a packet through the network:
- connectionless: datagram
- connection-oriented: virtual circuit
Two main functions of a router
- Forwarding: packet entering a router is directed to the correct exit interface using a routing table.
- Routing: the mechanism that the router uses to create paths in the network. There are 2 types of routing, direct routing(using the same network) and indirect routing(Two different networks connected by a gateway)
Router architecture:
- it has 3 main components:
- input ports
- output ports
- switching fabrics
Input ports:
- It performs processing at line speed by buffering.
- buffering slows down the incoming datagram if it is faster than what the switch fabric supports
Switch fabric:
Memory based:
- Uses CPU to route traffic
- The incoming packet is copied into memory.
- The packet is then read from memory to the output port.
- Speed limited by the memory.
Bus based:
- No CPU
- All input port are connected to the same bus
- Broadcast the packet to all output ports and only the correct one picks it up
Crossbar based:
- Dedicated paths between inputs and outputs
- Multiple packets can be sent in parallel
Output ports:
- It performs processing at line speed by buffering.
- buffers if the outgoing packets low is faster than the interface speed
Buffering and scheduling:
- We use buffering to slow down the transmission speed, if the receiver can’t keep up.
- Delays and losses are due to buffer congestion.
- Scheduling is the process of deciding which packet gets sent next on an output link when multiple packets are waiting in a queue (buffer)
- Scheduling Algorithms are used to know which packet should be sent before the other
- FIFO algorithm, first-in first-out
- Priority Scheduling
- Round Robin, each queue has its turn and cycle through each queue evenly
- Weighted Round Robin, like RR but queues have weights (High weight -> more bandwidth)
- Fair queuing, Tries to give each flow equal share of bandwidth
- Weighted Fair Queuing, like FQ but queues have weights (High weight -> more bandwidth)
IP address:
It is divided into 5 groups:
| Group | NetID | HostID | Range of W | NB of hosts |
|---|---|---|---|---|
| A | w.0.0.0 | x.y.z | 1 -> 126 | |
| B | w.x.0.0 | y.z | 128 -> 191 | |
| C | w.x.y.0 | z | 192 -> 223 | |
| w can NOT be equal to 0 or 127. | ||||
| group A: | ||||
0xxxxxxx . - . - . - | ||||
| group B: | ||||
10xxxxxx . xxxxxxx . - . - | ||||
| group C: | ||||
110xxxxx . xxxxxxxx . xxxxxxxx . - |
IPs we cannot use:
- x.x.x.0 -> used for network address
- 192.168.1.225 -> used for broadcast
- 255.255.255.255 -> used for broadcast on private networks
- 127.0.0.1 -> used for loopback
- 192.168.x.x -> used in private networks
- 169.254.x.x -> used for Link-Local
- 224.x.x.x -> used for multicast
- 240.x.x.x -> used for reserved / experimental cases
- 0.0.0.0 -> means “unknown address” or “default route”(in routing tables)
NAT:
-
NAT stand for Network Address Translation
-
it translates from public IP to Private and vice versa
-
it can also translate from IPv4 to IPv6 and vice versa
-
It allows responses to connections that were initiated from inside.
-
it has 3 types:
- Open: Any external host can reach you if a mapping exists
- Moderate: Only specific IPs/ports can respond
- Strict: Each connection gets a unique mapping
NAT vs PAT:
| NAT | PAT | |
|---|---|---|
| Mapping | 1:1 | many:1 |
| Public IPs | One per device | One for many device |
| Uses Ports | No | Yes |
| Scalability | Low | High |
| Common usage | Servers | Home/office networks |
Subnetting into multiple locations:
Class C:
Network ID : 200.57.11.0
we want to divide it into 5 different locations.
200 is between 192 -> 223 => Class C
=> take 3 bits from the host mask.
old subnet mask: 255.255.255.0 - 11111111.11111111.11111111.00000000 (/24)
new subnet mask: 255.255.255.224 - 11111111.11111111.11111111.11100000 (/27)
| Subnet ID | First Host ID |
|---|---|
| 200.57.11.0 | 200.57.11.1 |
| 200.57.11.32 | 200.57.11.33 |
| 200.57.11.64 | 200.57.11.65 |
| 200.57.11.96 | 200.57.11.97 |
| 200.57.11.128 | 200.57.11.129 |
| 200.57.11.160 | 200.57.11.161 |
| 200.57.11.192 | 200.57.11.193 |
| 200.57.11.224 | 200.57.11.22 |
Class A:
Network ID: 50.0.0.0
we want to divide into 4 subnets.
=> we take 2 bits from the host mask.
old subnet mask: 255.0.0.0 (/8)
new subnet mask: 255.192.0.0 (/10)
| Subnet ID | First Host IP | Last Host IP |
|---|---|---|
| 50.0.0.0 | 50.0.0.1 | 50.63.255.254 |
| 50.64.0.0 | 50.64.0.1 | 50.127.255.254 |
| 50.128.0.0 | 50.128.0.1 | 50.191.255.254 |
| 50.192.0.0 | 50.192.0.1 | 50.255.255.254 |
Class B:
Network ID: 185.72.0.0
we want to divide into 10 subnets
=> we take 4 bits form the host mask.
old subnet mask: 255.255.0.0
new subnet mask: 255.255.240.0
| Subnet ID | First Host IP | Last Host IP |
|---|---|---|
| 185.72.0.0 | 185.72.0.1 | 185.72.15.254 |
| 185.72.16.0 | 185.72.16.1 | 185.72.31.254 |
| 185.72.32.0 | 185.72.32.1 | 185.72.47.254 |
| 185.72.48.0 | 185.72.48.1 | 185.72.65.254 |
| 185.72.64.0 | 185.72.64.1 | 185.72.79.254 |
| … | … | … |
| 185.72.240.0 | 185.72.240.1 | 185.72.255.254 |
ICMP:
- stands for Internet control message protocol
- Its main functions are:
- Error reporting
- Reachability testing
- Congestion control
- Route change notification
- Performance and subnet addressing
- Ping: is to test connectivity between devices
- Ping is a : ICMP echo request / reply
- It will test the layers 4-3-2
Ping messages:
- Destination unreachable: if the destination is not in the router (not configured in the router)
- ping timeout
- source Quench: Automatic by the router to the destination. it reduce the frequency of input in case the buffer of the router is full and cannot receive more data at the moment.
IGMP:
- stands for Internet Group Multicast Protocol
- Unicast / Multicast / Broadcast
- It is in the Multicast communication
Lets us:
- Define group -> group IP address
- Join group
- leave group
- check members
- routing for multicast communication
ARP:
- It translate the IP to MAC address to know next hop
- It gets the physical address by broadcasting an ARP request containing the IP address.
- saying “Who has 192.168.1.x?”
- to make ARP more efficient, each machine keeps an ARP table in its memory that is being updated
RARP:
- Stands for Reverse ARP.
- It allows machine to use its physical address to determine its logical address on the Internet.
- It allows a computer to identify itself as a target by broadcasting a RARP request over the network.
- Servers also has an RARP table saved in its memory for reliability and efficiency.
Autonomous system:
- It is a set of networks connected to each other. that are organized by the same company.
- The company control how the routing is done, and what protocols to use.
Routing algorithms:
- It is used to pick a “good” route to take for sending packets from one router to another.
- There are three types of routing protocols:
- Link state:
- each router must discover its neighbors
- each router must measure the line delay of each neighbor
- each router summarizes its local topology (LSP)
- each router send its local LSP to all other routers in the network
- routers assemble every LSP and uses Dijkstra algorithm to calculate the shortest path
- distance vector:
- A router regularly broadcasts the routes it knows to its neighbors
- A route is composed of a destination address, a gateway address, and a metric indicating the number of hops required to reach the destination.
- When a router receives a new table, it performs the Bellman-Ford algorithm for each entry in the table received
- Modifying an entry in a router’s table causes the new table to be broadcast to all adjacent routers.
- Disadvantages of Distance Vector techniques:
- Size of routing information (proportional to the number of routers
- Metric (=shortest path) is difficult to use, limited to 16, not suitable for
- modern networks
- Looping, possibly infinite
- No multiple paths
- path-vector:
- The router gives the full path that a route takes to reach a destination
- each route includes “Destination network” and “complete path to reach it”
- This avoids loops, applies routing policies, and choose paths based on path attribute
- The “Border Gateway Protocol” uses this method of routing. especially when working across the internet between many autonomous systems (AS)
- Link state:
Summary:
- Link-State → fast and accurate (High CPU load)
- Distance Vector → simple, but slow and limited (Risk of loops)
- Path Vector → scalable, policy-based (Internet)

Routing protocols:
RIP:
- Routers periodically sends full routing table
- Chose the path with fewest hops
pros: - Simple
- Minimal configuration
cons: - Not scalable
- Slow convergence
OSPF:
- Builds a full topology map
- Calculate the shortest path using SPF
- Uses area to scale
pros: - fast convergence
- scalable
- Efficient updates
cons: - High CPU/memory usage
EGP:
- Not a protocol, It’s only a concept.
- Refers to routing between different Autonomous Systems (AS)
- Today, BGP is the actual EGP used
BGP:
- Exchange full path (AS sequence)
- Allow policy-based routing decisions
- prevent loops using AS path
pros: - Extremely scalable
- Highly flexible control
cons: - Complex
- Slower convergence tha OSPF
Summary:
- RIP → “Which path has fewer routers?”
- OSPF → “What’s the fastest route based on the whole map?”
- BGP → “Which route do I prefer based on policy and business rules?”
IPv6:
- 128 bits
- supports stateless auto-configuration, SLAAC (IPv4 has DHCP / static configuration)
- addresses
- it is composed of 8 parts, 16 bits each
2001.0db8.85a3.0000.0000.8a2a.6d80.738a->2001.0db8.85a3::8a2a.6d80.738a
48 bits -> global routing prefix
16 bits -> Subnet IP
64 bits -> device interface ID - doesn’t use NAT