Download Linux and Shell Programming

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Distributed firewall wikipedia , lookup

Backpressure routing wikipedia , lookup

Net neutrality law wikipedia , lookup

Network tap wikipedia , lookup

IEEE 1355 wikipedia , lookup

Net bias wikipedia , lookup

Piggybacking (Internet access) wikipedia , lookup

List of wireless community networks by region wikipedia , lookup

IEEE 802.1aq wikipedia , lookup

Multiprotocol Label Switching wikipedia , lookup

Wake-on-LAN wikipedia , lookup

Peering wikipedia , lookup

Computer network wikipedia , lookup

Airborne Networking wikipedia , lookup

Zero-configuration networking wikipedia , lookup

Cracking of wireless networks wikipedia , lookup

Recursive InterNetwork Architecture (RINA) wikipedia , lookup

Routing wikipedia , lookup

Routing in delay-tolerant networking wikipedia , lookup

Transcript
Internet Protocol: IP Routing
Linda Wu
(CMPT 471 • 2003-3)
Content







Definitions
Direct / indirect delivery
Table-driven IP routing
IP routing algorithms
Routing with IP addresses
Incoming datagram handling
Routing in Linux
References: chapter 8 & 10
Notes-6
CMPT 471  2003-3
2
Definitions
In packet-switched systems:

Routing


The process of choosing a path over
which to send packet
IP routing


The process of choosing a path within a
single network or across multiple
networks over which a datagram should
be sent
2 forms of routing
Direct delivery
 Indirect delivery

Notes-6
CMPT 471  2003-3
3
Definitions (cont.)

Router


Host


A computer which interconnects multiple
physical networks and makes routing decisions
A computer that usually connects directly to
one physical network
Multi-homed host

A host that connects directly to multiple
networks
* TCP/IP standards draw a sharp distinction
between the functions of a router and of a
host
Notes-6
CMPT 471  2003-3
4
Direct / Indirect Delivery

Direct delivery



The ultimate destination connects to
the same physical network as the
deliverer
No router involved
Direct delivery occurs when:
Source and destination are in the same
physical network, or,
 The delivery is between the last router
and the destination

Notes-6
CMPT 471  2003-3
5
Direct / Indirect Delivery (cont.)
Host
Direct delivery
Host
Direct
delivery
Net 1
Router
Notes-6
CMPT 471  2003-3
To the rest
of internet
6
Direct / Indirect Delivery (cont.)

The source determines whether the
delivery is direct by:
Extracting the destination network
address from the destination IP address
 Comparing the destination network
address with its own network address
 If a match is found  direct delivery


How is datagram delivered?
Map the destination IP address into a
physical address (mapping table, ARP)
 Encapsulate datagram in a frame
 Use physical hardware to deliver it

Notes-6
CMPT 471  2003-3
7
Direct / Indirect Delivery (cont.)

Indirect delivery



Notes-6
The destination is not on the same
physical network as the source
The datagram goes from router to router
till it reaches the one connected to the
same physical network as the
destination
Note: a delivery always involves one
direct delivery but zero or more indirect
delivery, with the direct delivery as the
last one
CMPT 471  2003-3
8
Direct / Indirect Delivery (cont.)
Host (source)
Net 1
Indirect delivery
Router
Net 2
Router
Indirect delivery
Net 3
Direct delivery
Host
(destination)
Notes-6
CMPT 471  2003-3
9
Direct / Indirect Delivery (cont.)

How is datagram delivered?
The source maps the nearest router’s IP
address into a physical address,
encapsulates the datagram in a frame,
and sends the frame to the router
 The router extracts the datagram and
selects the next router on the path
towards the destination
 Datagram is again placed in a frame and
sent over next physical network to a
second router
 So on till it can be delivered directly

Notes-6
CMPT 471  2003-3
10
Table-Driven IP Routing

Routing table



Stores information about possible
destinations and how to reach them
Both hosts and routers have routing
tables
Reduce the size of routing table
Contains next hop addresses instead of
the routes to the ultimate destinations
 Contains destination network address
instead of every possible IP address (i.e.,
network-specific routing instead of hostspecific routing)

Notes-6
CMPT 471  2003-3
11
Table-Driven IP Routing (cont.)
Routing table for A
Routing table for R1
Routing table for R2
Destination
Route
Destination
Route
Destination
Route
Host B
R1, R2, B
Host B
R2, B
Host B
B
(a) Routing tables based on route
B
A
Net 1
R1
Net 2
R2
Net 3
Routing table for A
Routing table for R1
Routing table for R2
Destination
Next
Hop
Destination
Next
Hop
Destination
Next
Hop
Host B
R1
Host B
R2
Host B
---
(b) Routing tables based on next hop
Notes-6
CMPT 471  2003-3
12
Table-Driven IP Routing (cont.)
Routing table for S using
destination IP address
(host-specific routing)
Destination
Next hop
A
R1
B
R1
C
R1
D
R1
Routing table for S using
destination network
address
(network-specific routing)
Destination
Next hop
Net 2
R1
S
Net 1
Notes-6
A
R1
CMPT 471  2003-3
B
C
D
Net 2
13
Table-Driven IP Routing (cont.)

Consequences of routing based on next
hop and destination network address
All traffic destined for a given network
takes the same path without regard to the
delay or throughput of the physical
network
 Only the final router along the path can
determine whether the destination host
exists or is operational
 Datagrams from A to B may follow an
entirely different path than that from B to
A

Notes-6
CMPT 471  2003-3
14
Table-Driven IP Routing (cont.)

Next-hop routing


Notes-6
The routing table holds only the address of next
hop instead of the complete route
A machine M’s routing table contains pairs (N, R)
 N: the destination network address
 R: the IP address of the next router along the
path to N; router R is called next hop
* R must lie on the network to which M connects
directly
* The routing table on M only specifies one step
along the path from M to a destination network;
M does not know the complete path to a
destination
CMPT 471  2003-3
15
Table-Driven IP Routing (cont.)
20.0.0.5
Net 1
10.0.0.0
Q
10.0.0.5
30.0.0.6
Net 2
20.0.0.0
Notes-6
Net 3
30.0.0.0
R
Destination
Next hop
20.0.0.0
Deliver directly
30.0.0.0
Deliver directly
10.0.0.0
20.0.0.5
40.0.0.0
30.0.0.7
S
Net 4
40.0.0.0
30.0.0.7
20.0.0.6
Routing table on R
40.0.0.7
• The size of routing table
depends on the number of
networks in the internet
• The size of routing table
is independent of the
number of individual hosts
connect to the networks
CMPT 471  2003-3
16
Table-Driven IP Routing (cont.)

Host-specific routing


The destination host address is given in the
routing table
Efficiency is sacrificed for other advantages:

A
The local network administrator is given more
control over routing
R1
Net 2
Routing table on A
Net 1
R3
R2
Net 3
Destination
Next hop
B
R1
Net 2
R1
Net 3
R3
……
……
B
Notes-6
CMPT 471  2003-3
17
Table-Driven IP Routing (cont.)

Default routing



Consolidates multiple entries into a default case
First look in the routing table for the destination
network; if no route appears in the table, send
the datagram to the default router
Especially useful when a site has a small set of
local addresses and only one connection to the
rest of the internet
Routing table on A
Notes-6
Destination
Next hop
Net 2
R1
……
……
Default
R2
A
CMPT 471  2003-3
Net 1
R1
Net 2
R2 (default router)
To the rest
of internet
18
Table-Driven IP Routing (cont.)

Static v.s. dynamic routing table


Notes-6
Static routing table
 The administrator enters the route for each
destination into the table
 The table cannot update automatically when
there is a change in internet; it must be
manually altered by the administrator
 Can be used in a small internet that does not
change very often
Dynamic routing table
 The routing table is updated periodically using
dynamic routing protocol: RIP, OSPF, BGP
 Used in large internet
CMPT 471  2003-3
19
IP Routing Algorithms

Standard routing algorithm for
classful addressing

routing table entries
(network address, next hop)

Hierarchical strategy for routing lookup
Direct delivery
 Host-specific routing
 Network-specific routing
 Default routing

Notes-6
CMPT 471  2003-3
20
IP Routing Algorithms (cont.)
Input: datagram DG, routing table T
D  extract destination IP address from DG
N  compute destination network address
if N matches any directly connected network address
map D to a physical address PD
encapsulate DG in a frame
send the frame to PD over that network
else if T contains a host-specific route for D
send DG to next hop specified in T
else if T contains a route for network N
send DG to next hop specified in T
else if T contains a default route
send DG to the default router
else declare a routing error
Notes-6
CMPT 471  2003-3
21
IP Routing Algorithms (cont.)

Subnet routing algorithm

Routing table entries
(subnet mask, network address, next hop)

Subsumes all special cases of the
standard algorithm
Host-specific routing: mask = all 1s,
network address = host IP address
 Routing to a classful network: using default
mask of that class
 Default routing: mask = all 0s, network
address = all 0s

Notes-6
CMPT 471  2003-3
22
IP Routing Algorithms (cont.)
Input: datagram DG, routing table T
D  extract destination IP address from DG
if prefix of D matches any directly connected network
address
map D to a physical address PD
encapsulate DG in a frame
send the frame to PD over that network
else
for each entry in T do
N = D & subnet mask
if (N == network address field of the entry)
route DG to the specified next hop
endfor
if no match found, declare a routing error
Notes-6
CMPT 471  2003-3
23
Routing with IP Addresses

IP routing does not alter datagram
except for,




Source and destination IP addresses
always specify the original source and
ultimate destination
Next-hop address



Notes-6
Decrementing time to live (TTL)
Recomputing checksum
Selected by IP routing algorithm
Used by network interface software to get
physical address
Discarded after physical address is found
CMPT 471  2003-3
24
Routing with IP Addresses (cont.)

Why use IP address in routing
table?


Notes-6
Provide an clean interface between IP
routing software and high-level
software that manipulates routes
The objective of IP protocol is to hide
the details of underlying networks
CMPT 471  2003-3
25
Income Datagram Handling
When a datagram arrives at a machine:


The machine compares the destination
address with the IP address for each of its
network connection
If the destination address matches the
machine’s IP address



If not match


Notes-6
IP software accepts the datagram
Passes it to the appropriate higher-level
protocol for further processing
Host: discard the datagram
Router: forward the datagram using routing
algorithm
CMPT 471  2003-3
26
Routing in Linux

Route command


Show / manipulate the IP routing table
Run “route” on July (172.16.1.7 / 172.18.1.7)
Kernel IP routing table
Notes-6
Destination
Gateway
Genmask
Flags Metric Ref Use Iface
172.18.0.0
*
255.255.0.0 U
172.19.0.0
0
0
0
eth1
march.net18 255.255.0.0 UG
1
0
0
eth1
172.16.0.0
*
255.255.0.0 U
0
0
0
eth0
172.17.0.0
cisco.net18
255.255.0.0 UG
2
0
0
eth1
127.0.0.0
*
255.0.0.0
0
0
0
lo
CMPT 471  2003-3
U
27
Routing in Linux (cont.)





Notes-6
Flags
 U (up): the router is up and running
 G (gateway): the destination is in another
network, use gateway for delivery
 H (host-specific): destination is a host
 D (added by redirection): the entry is added
to the routing table by a redirect message
 M (modified by redirection): the entry is
modified by a redirect message
Metric: distance (# of hops) to the destination
address
Ref: # of users that are using this route
Use: # of packets transmitted through this
router for the corresponding destination
Iface: the name of the interface
CMPT 471  2003-3
28
Routing in Linux (cont.)

Manipulate routing table
route add/del –net
route add/del –host
Examples:
route add -net 192.56.76.0 255.255.0.0 gw
192.56.76.9 eth0
route del -net 192.56.76.0 255.255.0.0 gw
192.56.76.9 eth0
route add -host 192.168.0.253 gw 192.168.1.3

Notes-6
More details: man route
CMPT 471  2003-3
29
Routing in Linux (cont.)

Traceroute command


Track packet’s routing path to a host
Run “traceroute spring.net17” on July
traceroute to spring.net17 (172.17.1.250), 30 hops max, 38
byte packets
1 cisco.net18 (172.18.1.254) 3.964 ms 1.787 ms 1.925 ms
2 january (172.16.1.253) 6.898 ms 0.935 ms 0.827 ms
3 spring.net17 (172.17.1.250) 1.712 ms 0.566 ms 0.599 ms
Path: july  cisco.net18  january  spring.net17
Notes-6
CMPT 471  2003-3
30
Routing in Linux (cont.)

How traceroute works?
Launch UDP probe packet with ttl =1, and
listen for reply; increase ttl by 1, or stop
probing, after receiving the reply
 2 types of reply




-p: to set the base UDP port number used
in probes


Notes-6
ICMP time exceeded message (from router)
ICMP port unreachable message (from the
destination)
Default base port: 33434; traceroute hopes
that nothing is listening on UDP port (base ~
base + nhops – 1) on destination
The port number is incremented by 1 for
each subsequent packet
CMPT 471  2003-3
31
Routing in Linux (cont.)

-q: number of probes


-m: maximal ttl used in outgoing probe
packets


Notes-6
Default: 3s (if there is no response within
3s, “*” is printed for that probe)
Output


Default: 30
-w: time to wait for a response to a probe


Default: 3 (3 probes are sent at each ttl
setting)
Each line is composed of ttl, address of
router, round trip time of each probe
More details: man traceroute
CMPT 471  2003-3
32