Skip to content

Routing Basics

1.jpg

25.jpg

2.jpg

Route algorithm

Routers forward a packet for one hop by looking at the IP address。

3.jpg

4.jpg

How to send the packet without knowing anything about the topology?

  • Send it to a random next hop.
  • Flooding: send it to everybody.
  • Source Routing: the original sender list all routers along the path
  • Distributed algorithm: routers construct a forwarding table by talking with each other

5.jpg

Flooding

6.jpg

Flooding: routers forward a packet to every interface, except for the one it comes from

Cons:

  • infinite loops. TTL field was originally designed to avoid the infinite loops.
  • Inefficient usage of links: a packet would use all links at least once
  • Packets are delivered to everyone

Pros: packets arrive the destination at the shortest possible path

Source Routing

7.jpg

Source Routing: the source hosts specify the whole path (A -> R1 -> R2 -> R3 -> B) or part of the path (the path has to go through R2)

Cons:

  • Revealing the underlying network topology causes potential vulnerabilities, and ISPs do not want to reveal that to users (due to security/competition)
  • Potentially large headers and all sources need to know the networking topology to do this

Pros:

  • No loops
  • No need for tables at routers

Routing tables

8.jpg

Routing tables: map prefix of IP destination addresses to next hop IP address

  • X.Y/Z is a Z-bit prefix IP destination address
  • Looking up in the routing tables looks for the longest prefix match
If (the packet is for this router’s Ethernet address) {
        Check the IP version number and length of datagram;
        Decrement TTL, and update IP header checksum;
           If (TTL == 0)  drop;
           If (IP destination address is in the forwarding table) {
                Forward to the correct port;

9.jpg

Routing tables

10.jpg

11.jpg

12.jpg

How to construct routing tables?

  • If packets from any source router should be delivered to router X exactly once along the shortest path, the routing table for destination router X, is a spanning tree with root at router X.
  • Routers build a spanning tree for each destination.

13.jpg

14.jpg

15.jpg

16.jpg

17.jpg

18.jpg

19.jpg

20.jpg

21.jpg

22.jpg

23.jpg

24.jpg

26.jpg

27.jpg

28.jpg

29.jpg

Bellman-Ford algorithm

Bellman-Ford algorithm: every router advising its # hops from the destination, and update that number when they received a smaller # hops (new number + 1 < old number) from its neighbors, and breaks ties at random.

30.jpg

31.jpg

32.jpg

33.jpg

34.jpg

35.jpg

36.jpg

37.jpg

38.jpg

39.jpg

40.jpg

41.jpg

42.jpg

用心记录,持续成长