Typically there is only one router a host is attached to (default or first-hop router). We will refer the default router of the destination as destination router and default router of the source as source router. The problem of routing packets from source host to the destination host is now the problem of routing the packets from source router to the destination router.
We can classify routing algorithms several ways:
Initialization:
N = {A}
for all nodes v
if v adjacent to A
then D(v) = c(A, v)
else D(v) = ¥
Loop
find w not in N such that D(w) is a minimum
add w to N
for v adjacent to w and not in N update D(v):
D(v) = min{ D(v), D(w)+c(w, v) }
/* new cost to v is either the old cost or known shortest path cost to w plus cost from w to v */
until all nodes in N
The following page illustrates how this algorithm works.
On this page you can find graphical illustration to the
algorithm.
The principal data structure for DV algorithm is the distance table maintained at each node (note: each node has its own distance table). Each node's distance table has a row for each destination in the network and a column for each of its directly connected neighbors. Each element of the table can be denoted as
DA(Z,R)This notation means the price for a packet from node A send to the node Z via A's directly attached neighbor R. Thus, this element is an element of the distance table of the node A (since this is the only node interested in such information). Another piece of information each node maintain is the distance to each of its neighbors. We'll use the same notation C(A,R) for the variable storing this data, but notice that each node now has only one row of the matrix. Such, node A knows C(A,B), C(A,C), C(A,D), but doesn't know C(B,R). The goal of the DV algorithm is to compute distance table. To do this the next algorithm is used:
Initialization:
for all nodes v:
if v adjacent to X
then DX(v, v) = C(X,v)
else DX(*,v) = ¥
for all nodes v
find min DX(v,w) for all w from neighbors
send this min DX(v,w) to all neighbors
Loop
wait until either a link cost to neighbor V is changed
or an update from neighbor V received
if C(X,V) changes by d /* d can be both positive and negative */
then for all destinations y : DX(y,V) = DX(y,V) + d
else if update received from V for destination Y (by d) /* shortest path from V to some Y has changed by d */
then DX(Y,V) = C(X,V) + d
if there is a new minwDX(v,w) for any destination v
then send this new value to all neighbors
forever
| Class | Starts with | Bits | Host # bits | IP Range | |||||
|---|---|---|---|---|---|---|---|---|---|
| A | 0 |
|
24 | 1.0.0.0 - 127.255.255.255 | |||||
| B | 10 |
|
16 | 128.0.0.0 - 191.255.255.255 | |||||
| C | 110 |
|
8 | 192.0.0.0 - 223.255.255.255 | |||||
| D | 1110 |
|
Multicast address | 224.0.0.0 - 239.255.255.255 |
Note: The class A network ID 127 is reserved for the loopback interface. By convention, most system assign the IP address of 127.0.0.1 to this interface and asign it the name localhost.
CIDR = Classless InterDomain Routing. Together with the IP address provide network mask - information about how many bits network address takes: a.b.c.d/20.
References:You can find more details in the official documentation RFC 2131.
NAT binds addresses in private network with addresses in global network and vice versa to provide transparent routing for the datagrams traversing between address realms. The binding in some cases may extend to transport level identifiers (such as TCP/UDP ports). Address binding is done at the start of a session. The following sub-sections describe two types of address assignments.
Static Address assignment
In the case of static address assignment, there is one-to-one address mapping for hosts between a private network
address and an external network address for the lifetime of NAT operation. Static address assignment ensures that NAT does
not have to administer address management with session flows.
Dynamic Address assignment
In this case, external addresses are assigned to private network hosts or vice versa, dynamically based on usage
requirements and session flow determined heuristically by NAT. When the last session using an address binding is terminated,
NAT would free the binding so that the global address could be recycled for later use. The exact nature of address
assignment is specific to individual NAT implementations.
There are three blocks of IP address space recommended for private networks, namely
Official documentation:
| 1 | IP version (current version:4) |
IP Header length (in 32-bit words) |
Type of service | |||||||||||||||
| 2 | Total packet length (in bytes from the beginning of IP header) |
|||||||||||||||||
| 3 | IP packet ID number (packet serial number) |
|||||||||||||||||
| 4 | Fragment bit flags | IP fragment offset (location of this packet fragment in original packet, in 8-byte units) |
||||||||||||||||
| 5 | Time to live (maximum router hops remaining) |
Transport protocol (ICMP:1, IGMP:2, TCP:6, UDP:17) |
||||||||||||||||
| 6 | Header checksum (Note: Only the header is checksummed) |
|||||||||||||||||
| 7 | Source IP address | |||||||||||||||||
| 8 | (4-byte IP address for host from which the packet originated) | |||||||||||||||||
| 9 | Destination IP address | |||||||||||||||||
| 10 | (4-byte IP address of the host where the packet is going) | |||||||||||||||||
| 11 | IP options (Length of this part is usually 0 but may vary) |
|||||||||||||||||
| precedence | delay | through put |
relia bility |
cost | reser ved |
||
| 0 | 0 | 0 | |||||
| Application | Minimize delay |
Maximize throughput | Maximize reliability | Minimize monetary cost |
|---|---|---|---|---|
| Telnet/Rlogin | 1 | 0 | 0 | 0 |
| FTP | ||||
| control | 1 | 0 | 0 | 0 |
| data | 0 | 1 | 0 | 0 |
| any bulk data | 0 | 1 | 0 | 0 |
| TFTP | 1 | 0 | 0 | 0 |
| SMTP | ||||
| command phase | 1 | 0 | 0 | 0 |
| data phase | 0 | 1 | 0 | 0 |
| DNS | ||||
| UDP query | 1 | 0 | 0 | 0 |
| TCP query | 0 | 0 | 0 | 0 |
| zone transfer | 0 | 1 | 0 | 0 |
| 0 | IP | # internet protocol, pseudo protocol number |
| 1 | ICMP | # internet control message protocol |
| 2 | IGMP | # internet group management protocol |
| 6 | TCP | # transmission control protocol |
| 17 | UDP | # user datagram protocol |
| 89 | OSPF | # routing protocol |
| value=0: do not copy to fragments | value=1: copy to fragments |
| value=0: control class | value=1: debug and measurement class |
| value=0: end of list | value=1: NOP | |
| value=2: security | value=3: loose resource routing | |
| value=4: internet timestamp | value=7: record route | |
| value=8: stream ID | value=9: strict source routing |
The problem is that each link along the route between the sender and the receiver can use different link-layer protocol, and each of these protocols can have a different MTU. How to squeeze an oversized IP datagram to fit teh next MTU?
The solution to this problem is to fragment the data in the IP datagram among several smaller datagrams. To allow the next router/host to reassemble IP header includes :
Another use of ICMP is for service tools such as ping or traceroute.
ICMP is often considered part of IP but architecturally lies just above IP, as ICMP messages are carried inside IP packets. That is, ICMP messages are carried as IP data, just as TCP or UDP segments. Nevertheless, ICMP is a part of the Network Layer.
ICMP message has the following format:
| 1 | Type | Code | ||||||||||||||
| 2 | Checksum | |||||||||||||||
| 3 | Pointer | Reserved | ||||||||||||||
| 4 | Reserved | |||||||||||||||
| 5 | Data: Internet header + 64 bits of original datagram header | |||||||||||||||
| ... | (the IP packet that generated this ICMP message) | |||||||||||||||
| Type | Description | Code | Description |
|---|---|---|---|
| 0 | echo reply | 0 | unused; data is returned from echo request |
| 3 | Destination unreachable | 0 | Network unreachable |
| 1 | Host unreachable | ||
| 2 | Protocol unreachable | ||
| 3 | Port unreachable | ||
| 4 | Flag needed but IP df set | ||
| 5 | Source route failed | ||
| 4 | Source quench | 0 | unused |
| 5 | Redirect | 0 | Network redirect |
| 1 | Host redirect | ||
| 2 | Type of service net redirect | ||
| 3 | Type of service host redirect | ||
| 8 | Echo request | 0 | unused |
| 9 | Router solicitation | 0 | unused |
| 10 | Router advertisement | 0 | unused |
| 11 | Time exceeded | 0 | IP time-to-live exceeded |
| 1 | flag reassembly timeout | ||
| 12 | Parameter problem | 0 | Pointer field in ICMP header indicates error |
| 13 | Request time | 0 | unused |
| 14 | Reply time | 0 | unused |
| 15 | Information request | 0 | unused |
| 16 | Information reply | 0 | unused |
| 17 | Address mask request | 0 | unused |
| 18 | Address mask reply | 0 | unused |
ICMP is specified in RFC792.
An intra-AS routing protocols are used to determine how routing is performed within an autonomous system (AS). Intra-AS routing protocols are also known as interior gateway protocols.
The first version of RIP uses hop count as a cost metric; that is, each link has cost of 1. The maximum cost of a path is limited to 15, thus limiting the use of RIP to AS that are fewer than 15 hops in diameter. In RIP, routing updates are exchanged between neighbors approximately every 30 seconds using so called RIP response message. The response message contains a list of up to 25 destination networks within the AS, as well as the sender's distance to each of those networks. Response messages are also known as RIP advertisements. If a router does not hear from its neighbor at least once every 180 seconds, that neighbor is considered to be no longer reachable. When this happens, RIP modifies the local forwarding table and then sends this information to its neighboring routers. A router can also request information about its neighbor's cost to a given destination by using RIP's request message. Routers send RIP messages to each other over UDP using port number 520. The UDP datagrams are carried between routers in a standard IP datagram. The fact that RIP uses a transport layer-protocol on top of a network-layer protocol to implement network-layer functionality may seem a little convoluted. Actually, RIP is an application-layer process working with the network-layer routing tables.
OSPF is a link state protocol that uses flooding of link state information and a Dijkstra least cost path algorithm. Individual link cost are configured by the network administrator. The administrator may want to choose to set all links to costs 1 or might choose to set the link weights to be inversely proportional to link capacity in order to discourage traffic from using low-bandwidth links.
With OSPF, a router broadcast routing information to all other routers in the AS. A router broadcasts link state information whenever there is a change in a link's state. It also broadcasts a link's state periodically (at least once in 30 minutes). OSPF messages are carried directly by IP, with an upper-layer protocol 89 for OSPF.
Some of the advances embodies of OSPF include the following:
OSPF hierarchical routing: An OSPF AS can be configured into areas. Each area runs its own OSPF link state algorithm, with each router in an area broadcasting its link state information to all other routers in that area. Within each area, one or more routers are to be configured as area border routers and be responsible for routing packets outside the area. Exactly one OSPF area in the AS is configured to be the backbone area. The primary role of the backbone area is to route traffic between the other areas in the AS. The backbone area always contains all the area border routers and may contain non-border routers as well. We can identify 4 types of OSPF routers :
At the heart of BGP are route advertisements. A route advertisement is sent from one BGP peer to another over a
point-to-point connection. An advertisement consists of a CIDRized destination network address (like
BGP operation revolves around three activities, all involving route advertisement:
BGP peers communicate using the TCP protocol and port 179.
| 1 | Version | Traffic Class | Flow Label | |||||||||||||||||||||||||||||
| 2 | Payload length | Next Header | Hop Limit | |||||||||||||||||||||||||||||
| 3 | ||||||||||||||||||||||||||||||||
| 4 | Source IP address | |||||||||||||||||||||||||||||||
| 5 | (128-bit IP address of the originator of the packet) | |||||||||||||||||||||||||||||||
| 6 | ||||||||||||||||||||||||||||||||
| 7 | ||||||||||||||||||||||||||||||||
| 8 | Destination IP address | |||||||||||||||||||||||||||||||
| 9 | (128-bit IP address of the intended recipient of the packet) | |||||||||||||||||||||||||||||||
| 10 | ||||||||||||||||||||||||||||||||
Field descriptions:
FEDC:BA98:7654:3210:FEDC:BA98:7654:3210An alternative form that is sometimes more convenient when dealing with a mixed environment of IPv4 and IPv6 nodes is x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values of the six high-order 16-bit pieces of the address, and the 'd's are the decimal values of the four low-order 8-bit pieces of the address (standard IPv4 representation). Examples:
0:0:0:0:0:0:13.1.68.3
The most important changes:
Features of IPv4 that are no longer in the IPv6 header: