Network Layer
- 4-1 Network Layer Overview
- 4-2 Network Services
- 4-3 Internetworking
- 4-4 IP Address & IP Prefixes
- 4-5 IP Forwarding
- 4-6 IP Helpers (ARP and DHCP)
- 4-7 Packet Fragmentation
- 4-8 IP Error --> ICMP
- 4-9 IPv6
- 4-10 NAT (Network Address Translation)
- 5-1 Routing Overview
- 5-2 Shortest Path Routing
- 5-3 Dijkstra Algorithm
- 5-4 Distance Vector Routing
- 5-6 Link State Routing --> in practice
- 5-7 Equal Cost Multi Path Routing
- 5-8 Hosts and Routers
- 5-9 Hierarchical Routing
- 5-10 Prefix Aggregation and Subnets
- 5-12 BGP (Border Gateway Protocol)
4-1 Network Layer Overview
- Shortcomings of Switches
- Don’t scale to large networks
–> Scale to large networks
- Don’t work across more than one link layer technology
–> Support diverse technologies
- Don’t give much traffic control
–> Use link bandwidth well
4-2 Network Services
Two Network Service Models
- datagram model:
Packet is indenpendent, self-contained, fully addressed
-> IP (Internet Protocol)
- Virtual circuits: make a connectation first.
use distinguish label number
go through three phases:
- Connection establishment phase (Set up --> Finding a path through the Network)
- Data transfer phase
- Connection teardown phase
-> MPLS (Multi-Protocol Label Switching) --used in–> ISPs
-> Both Store-and-Forward Packet Switching --> statistical multiplexing
4-3 Internetworking
IP : Connecting different kinds of networks. — A “narrow waist” of the Internet
IP Header
4-4 IP Address & IP Prefixes
IPv4: 32-bit address --> written in “dotted quad” notation
-
“IP Address / lenth” notation
fixed / free
/ --> slash : /24 --> slash 24 -
More specific prefix --> smaller number of IP address
-
Less specific prefix --> larger number of IP address
IP Address Classes --> Historical
Originally, IP address came in fixed size blocks with the class
/ size encoded in the high-order bits
Public / Private IP Addresses
- Public IP Address:
valid destination on the global Internet
- Private IP Address:
Like: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16
Need public IP addresses and NAT to connect to global Internet
4-5 IP Forwarding
- The distinction between routing and forwarding:
Forwarding: is a process of handling a packet when it arrives. Sending it on its merry way.
Routing: is the process of computing all of the paths through the network so that you’ll be prepared later on to forward packets, because you 'll know which way to send them when they arrive.
Longest Matching Prefix
-> The more specific entry
-> Uses hierarchy for a compact table
Host Forwarding Table
-> Host just need to know the nearest router to help it forward message
using a default route to 0.0.0.0/0 --> everything all of the IP address (follow by the Longest Matching Prefix, it can not match any IP addresses) --> its Next Hop: send to my router
4-6 IP Helpers (ARP and DHCP)
DHCP (Dynamic Host Configuration Protocol)
How to getting IP Addresses
Ethernet Address is set on your hardware – NIC
-> Manual configuration(90s)
-> DHCP: automatically configuring
it uses UDP’s port 67 and 68 to identify itself. it is an application.
- Process: DORA
- Client --broadcast(255.255.255.255, FF-FF-FF-FF-FF-FF) “Discover” to find–> All nodes
- DHCP Sever --Offer an IP address–> Client
- Client --broadcast: Request–> All nodes
- DHCP --ACK–> Client
ARP (Address Resolution Protocol)
How to send an IP packet
.jpg
-> To transfer in the link layer (get the destination Ethernet address by ARP --> broadcast)
- Process:
Source – Broadcast: Request --> All nodes
Target – Reply --> Source
Discovery Protocols
Both DHCP and ARP use discovery protocolst to find one another. Like: zeroconf, Bonjour …
Often involve broadcast trick.
4-7 Packet Fragmentation
Different network has different packet sizes
MTU (Maximum Transmission Unit)
Source -> Router --Fragment to shorter than MTU-> Router -> Router --Reassemble–> Dest
Path MTU Discovery (in practice now)
Discovery the MTU that will fit
–> Implemented with ICMP : set DF(Don’t Fragment) bit in IP header to get feedback message
4-8 IP Error --> ICMP
ICMP (Internet Control Message Protocol)
Sit on top IP (IP Protocol = 1) , the IP packet is carrying ICMP message.
Error: Router discard the packet and send a ICMP report to Source.
- Traceroute:
TTL : 1, … ,n -> the router send back an ICMP message
4-9 IPv6
How to connect IPv4 and IPv6
Tunneling
like a tunnel (Must go through the network, can not stop), when through IPv4 network, we wrap IPv6 packet inside an IPv4 Header.
4-10 NAT (Network Address Translation)
NAT is widely used to connect home network to The Internet.
Middleboxes
- advantages:
- A possible rapid deployment path when there is no other option
- control over many hosts
- disadvantages:
Complicate -> higher than network layer
NAT (Network Address Translation) Box
A kind of middlebox --> Translate addresses
Mapping: Private IP addresses : port --NAT(in AP / Firewall)–> Public IP addresses : port
Like: 快递:送到寝室,再分给每个人
- The pros and cons of NAT
NAT Downsides:
- Connectivity has been broken:
-> can only send incoming packets after an outgoing connection is set up
-> difficult to run server or p2p apps at home
- doesn’t work well when there are no connections ( UDP apps)
- Breaks apps that unwisely expose their IP addresses (FTP)
NAT Upsides:
- Relives IP address pressure
- easy to deploy
- Usefully unctionality: firewall …
5-1 Routing Overview
Routing is a process that involves all of nodes in the network.
LAN: Spanning Tree --> basic connectivity (Ignore some links)
-> Delivery Models:
Unicast
Broadcast
Multicast
Anycast
5-2 Shortest Path Routing
Dijkstra
To choose the best cost path.
Step 1: Assign each link a cost
Step 2: Define the best path between each pair of nodes
Step 3: Pick randomly to any break ties
- Sink Tree:
5-3 Dijkstra Algorithm
A single-source shortest paths algorithm
Optimality Property–> Subpaths of shortest paths are also shortest paths
5-4 Distance Vector Routing
Each node maintains a vector of distance (and next hops) to all destinations --> d[]
- When you remove a node:
Good news travels quickly, bad news slowly (inferred)
Example:
1 -- 2 -- 3:
-------------
0 -- 1 -- inf
0 -- 1 -- 2
|
V
1 -x- 2 -- 3
x --- 1 -- 2
x --- 3 -- 2
x --- 3 -- 4
...
RIP (Routing Information Protocol) --> old
- It uses hop count as a metric.
- Infinity is 16 hops ( limits network size )
RIPv1 specified in RFC1058(1988)
–>run on top of UDP
–>send vector every 30s
–>timeout in 180s to detect failures
Flooding
relay messages one by one to all of the nodes in the network
Each link carries the message, and in at least one direction --> reduency
To stop flood:
- remember message --> to using source and sequence number (only recive higher seq number from one source --> which is new!)
–> Use ARQ
5-6 Link State Routing --> in practice
–> Each node learns the full topology, use flooding (Link State Packet: LSP, with a time stamp) create and maintain that.
–> Use Dijkstra to find route
- Compare between Distance Vector Approach and Link State Routing:
- The Distance Vector Approach:
Spead the work of commuting the roots out across all the nodes of the network.
- Link State Routing:
Give everyone a copy of the topology and let everyone compute their own roots.
IS-IS (Intermediate Sysyem to Intermediate Sysyem)
OSPF (Open Shortest Path First)
5-7 Equal Cost Multi Path Routing
Allow multiple routing paths from node to destination be used at once -> In case one link fail, you want to be able to have a different link to reach your destination
–> keeping a set if there are ties
–> With ECMP, source / sink “tree” is a DAG (Directed Acyclic Graph)
- ach node has set of next hops
5-8 Hosts and Routers
5-9 Hierarchical Routing
–> Collapsed into a single entry
–> we’re hiding what’s inside that region. --> gives savings in table size, messages and computation.
5-10 Prefix Aggregation and Subnets
–> manage the network
–> reduce the size of table
Subnets
- Internally split one less specific prefix (shorter) into multiple more specific prefixes (longer)
Aggregation
- Externally join multiple more specific prefixes into one larger prefix
Routing with Multiple Parties
Networks are richly interconnected by IXP: Internet Exchange Point
A node B1 in ISP B want to connect with other node A1 in another ISP A, it will always choose the shortest IXP form itself to ISPA
5-12 BGP (Border Gateway Protocol)
used to find routes across the internet
- properities:
- different parties like ISPs are called AS (Autonomous Systems)
- Path vector protocol: in BGP, we just send the whole path as a list of ASes. (To solve the loop)