IP Routing Reading Chapter 16 Fall 2004 FSU

  • Slides: 18
Download presentation
IP Routing Reading: Chapter 16 Fall 2004 FSU CIS 5930 Internet Protocols 1

IP Routing Reading: Chapter 16 Fall 2004 FSU CIS 5930 Internet Protocols 1

IP routing End system Intermediate system (Router) End system Transport TCP Network IP IP

IP routing End system Intermediate system (Router) End system Transport TCP Network IP IP IP Data link and physical PPP Fall 2004 PPP IEEE 802. 3 FSU CIS 5930 Internet Protocols IEEE 802. 3 2

Networks and routers Connection to the other networks of the Internet Router B Router

Networks and routers Connection to the other networks of the Internet Router B Router A Network 3: Ethernet (IEEE 802. 3) Network 2: PPP Network 4: Fast Ethernet Network 1: Token Ring (IEEE 802. 5) Network 5: Wireless LAN (IEEE 802. 11) Router C Fall 2004 FSU CIS 5930 Internet Protocols 3

Forwarding vs. routing • Forwarding – Given a packet, determining the next hop toward

Forwarding vs. routing • Forwarding – Given a packet, determining the next hop toward destination by consulting some routing table – Per packet behavior – In kernel • Routing – Collecting/exchanging topology and state information, computing shortest path to destinations, constructing routing table – Periodically or event driven – In user space (some routing daemon) Fall 2004 FSU CIS 5930 Internet Protocols 4

IP addresses • Class-based ones – A, B, C, D, E – Inferring network

IP addresses • Class-based ones – A, B, C, D, E – Inferring network part from addresses • Classless one (CIDR) – Explicitly network mask – 192. 168. 152. 0/21 – 192. 168. 152. 0/255. 248. 0 Fall 2004 FSU CIS 5930 Internet Protocols 5

An example Connection to the other networks of the Internet Router B 10. 0.

An example Connection to the other networks of the Internet Router B 10. 0. 0. 1 Router A 10. 0. 2. 1 10. 0. 1. 1 10. 0. 2. 2 10. 0. 3. 1 10. 0. 3. 2 10. 0. 3. 3 10. 0. 5. 2 10. 0. 5. 3 10. 0. 4. 1 10. 0. 4. 2 10. 0. 1. 4 10. 0. 4. 3 10. 0. 5. 1 10. 0. 1. 3 Router C Fall 2004 FSU CIS 5930 Internet Protocols 6

Routing table for Routing B Destination Network mask 10. 0. 3. 0 255. 0

Routing table for Routing B Destination Network mask 10. 0. 3. 0 255. 0 eth 0 10. 0. 4. 0 255. 0 eth 1 10. 0. 5. 0 255. 0 10. 0. 2. 0 255. 0 0. 0 Fall 2004 Router 10. 0. 4. 3 Interface eth 1 ppp 0 10. 0. 2. 1 FSU CIS 5930 Internet Protocols ppp 0 7

Some concepts • Longest prefix matching – More specific entries are preferred • Routing

Some concepts • Longest prefix matching – More specific entries are preferred • Routing cache – Most recently used routing entries – To speed up forwarding • Rule-based routing – A unified way to organize different routing tables – local (local router), main (general table), default (default routing entry) – Each with a priority Fall 2004 FSU CIS 5930 Internet Protocols 8

Implementation • Data structures – Routing rules – Routing tables – Routing cache •

Implementation • Data structures – Routing rules – Routing tables – Routing cache • Functions – Forwarding lookup functions – Management functions Fall 2004 FSU CIS 5930 Internet Protocols 9

Routing rules fib_rule r_next r_clntref: 2 r_preference: 0 r_preference: 32766 r_table: RT_TABLE_LOCAL r_table: RT_TABLE_MAIN

Routing rules fib_rule r_next r_clntref: 2 r_preference: 0 r_preference: 32766 r_table: RT_TABLE_LOCAL r_table: RT_TABLE_MAIN r_action: RTN_UNICAST r_dst_len: 0 . . . r_src_len: 0 r_src: 0 x 0 r_srcmask: 0 x 0 fib_rule r_dst: 0 x 0 r_next: 0 x 0 r_dstmask: 0 x 0 r_srcmap: 0 x 0 r_flags: 0 r_tos: 0 r_ifindex: 0 r_clntref: 2 r_preference: 32767 r_table: RT_TABLE_DEFAULT r_action: RTN_UNICAST r_ifname[. . . ]: ““ . . . r_dead: 0 Fall 2004 FSU CIS 5930 Internet Protocols 10

Functions • fib_lookup(rt_key, …) – Searching for matching rules – If found • Get

Functions • fib_lookup(rt_key, …) – Searching for matching rules – If found • Get the routing table (fib_get_table()) • Looking up an entry in the table (tb_lookup()) • rt_key structure – dst, src, iif, oif, tos, scope, etc Fall 2004 FSU CIS 5930 Internet Protocols 11

Routing tables fib_tables[255] 1 fib_table tb_id: 1 0 . . . fn_zone fz_next: 0

Routing tables fib_tables[255] 1 fib_table tb_id: 1 0 . . . fn_zone fz_next: 0 x 0 fib_node*[1] fz_hash fz_divisor: 1 fib_table fz_hashmask: 0 x 0 fz_order: 0 254 fib_table fz_mask: 0 tb_id: 254 tb_stamp tb_lookup() 16 fn_zone fz_next tb_insert() fz_hash tb_delete() fz_divisor: 16 tb_dump() fz_hashmask: 0 xf tb_flush() fz_order: 16 tb_get_info() fz_mask: 0 xffff fib_node*[16] tb_select_default() fn_hash fn_zones[33] fn_zone_list 24 fn_zone fz_next fib_node*[16] fz_hash fz_divisor: 16 255 Fall 2004 fib_table fz_hashmask: 0 xf tb_id: 255 fz_order: 24 . . . fz_mask: 0 xffffff FSU CIS 5930 Internet Protocols 12

Zone, node, and info fib_node*[16] 0 fib_node fn_next fn_info fn_key . . . fib_node

Zone, node, and info fib_node*[16] 0 fib_node fn_next fn_info fn_key . . . fib_node fn_tos fn_type fib_info fn_scope next fn_state fib_info prev fib_treeref fib_node fib_clntref fib_dead 15 fib_flags fib_node fib_prefsrc fib_priority fib_metrics[. . . ] fib_info_list fib_info_cnt next prev: 0 x 0 ? ? ? . . . fib_nhs fib_nh nh_dev net_dev nh_flags nh_scope nh_oif nh_gw Fall 2004 FSU CIS 5930 Internet Protocols 13

Routing cache rtable rt_hash_table[] dst_entry rtable next 0 . . . rt_hash_bucket dev net_dev

Routing cache rtable rt_hash_table[] dst_entry rtable next 0 . . . rt_hash_bucket dev net_dev . . . neighbour rt_hash_bucket hh hh_cache chain input() lock 16 rt_hash_bucket output() dst_ops . . . rt_flags gc() rt_type check() rt_dst reroute() rt_src destroy() rt_iif negative_advice() rt_gateway link_failure() rt_key negative_advice() entries rt_spec_dst inet_peer Fall 2004 inet_peer FSU CIS 5930 Internet Protocols . . . 14

Forwarding functions • ip_route_input() – For handling incoming packet – Searching cache first, done

Forwarding functions • ip_route_input() – For handling incoming packet – Searching cache first, done if found – Depending on destination address • Multicast: ip_route_input_mc() • Otherwise: ip_route_input_slow() Fall 2004 FSU CIS 5930 Internet Protocols 15

Forwarding functions • ip_route_input_slow() – Sanity checking – FIB query by fib_lookup() – Depending

Forwarding functions • ip_route_input_slow() – Sanity checking – FIB query by fib_lookup() – Depending on if local address • If local: dst. input <- ip_local_delivery() • Otherwise: – Making the outgoing interface is up – dst. Input <- ip_forward() – dst. Output <- ip_output() Fall 2004 FSU CIS 5930 Internet Protocols 16

Forwarding functions • ip_route_output() – For locally generated packets – Creating rt_key structure –

Forwarding functions • ip_route_output() – For locally generated packets – Creating rt_key structure – Passing on to ip_route_output_key() • ip_route_output_key() – Searching routing cache – If not found • ip_route_output_slow() Fall 2004 FSU CIS 5930 Internet Protocols 17

Forwarding functions • ip_route_output_slow() – Searching routing table – Local vs. nonlocal • Local:

Forwarding functions • ip_route_output_slow() – Searching routing table – Local vs. nonlocal • Local: ip_local_delivery() • Nonlocal: – Dst. output <- ip_ouput() – Entering the result into routing cache Fall 2004 FSU CIS 5930 Internet Protocols 18