Monday, August 29, 2016

Principles of the Routing Protocols



The router is necessary in the internet, and the main function of the router is to interconnect different networks together.

A route is the path information to guide IP packets to be transferred


The router

The router provides the mechanism for interconnection of the heterogeneous networks, thus implementing transmission of a data packet from one network to another network. The route refers to the path information for guiding the IP data packet transmission.
Routing in the Internet needs the routers. The router selects an appropriate path (through a network) according to the destination address of the packet header it receives, and transmits it to the next router. So when a router think about how to guide a ip packet to be transferred, it should know that is this destination network that  can reach or not? the cost to the destination network and the next hop router from this router to the destination network. The last router on the path sends the data packet to the destination host. Data packet transmission in the network is like the relay in the athletic sports. Each router is responsible for forwarding the data packet of this station through the optimal path. With relays of the routers, the data packet will be transmitted to the destination through the optimal path. Sometimes, some routing policies are implemented, so the path taken by the data packet may not necessarily be the optimal route.

Based on the destination, the routes can be classified into:
Subnet route: destination is the subnet
Host route: destination is a host.

Besides, based on whether the destination is connected to the router directly, the routes can again be classified into:
Direct route: the network of the destination is connected to the router directly.
Indirect route: the network of the destination is not connected to the router directly.

The Routing Table Information

The routing table is the key for the router to forward the data packet. Each router keeps a routing table. Each routing item in the table points out from which physical port the data packet destined for a subnet or host will be sent to the next router of the route or to the destination host in the directly-connected network without passing any other router.


Routing Tables

The routing table contains the following key items:
Destination address: used to identify the destination address or destination network of the IP packet.
Network Mask: used together with the Destination  address to identify the address of the network segment where the destination host or router is located. After the Destination is "Logic AND" the Mask, the address of the network segment where the destination host or router is located can be obtained. For example, if the Destination address and Mask of the host of router are 8.0.0.1 and 255.0.0.0 respectively, the address of the network segment where the host or router is located is 8.0.0.0. Mask consists of some consecutive "1s". The mask can be represented by dotted decimal or the number of consecutive "1s".
Interface: indicate from which interface of the router the IP packets will be forwarded.
Nexthop: indicate the interface address of the next router that the IP packet passes.

Protocol

Protocol field in the routing table: indicate the route origination (i.e. how the route is generated). The route has 3 origination :
(1).  The route discovered by the link-layer protocol (Direct)
Small overhead, simple configuration, manual maintenance not needed, only the route of the network segment of this interface can be discovered.
(2).  Static route configured manually  (Static)
As a special route, the static route is configured by the administrator. An interworking network can be established by configuring the static route. However, such configuration has a problem: when a network fault occurs, the static route cannot repair it automatically and the administrator's intervention is needed. Characterized by no overhead and simple configuration, the static route is suitable for the network of simple topological structure.
(3). Route discovered by the dynamic routing protocol (RIP, OSPF ...)
When the network topological structure is very complex, the workload of manual configuration of the static route is so heavy that error will occur easily. In this case, the dynamic routing protocol can be used to discover and modify the route. Besides, manual maintenance is not needed, but the dynamic routing protocol brings large overhead and complex configuration.

Route Preference

Different routing protocols (including the static route) may discover different routes towards the same destination. However, these routes are not always optimal. In fact, the current route towards a destination at a time can only be decided by a unique routing protocol. Thus, a preference is assigned to each routing protocol (including the static route). In this way, when there are multiple routing information sources, the route discovered by the routing protocol of higher preference (the smaller the numerical value, the higher the preference) will become the optimal route and then will be added in the routing table. 

Routing Protocol
Preference
DIRECT
0
OSPF
10
IS-IS
15
STATIC
60
RIP
100
IBGP
255
OSPF ASE
150
EBGP
255
Untrustworthy
255

Route Metric

The route metric identifies the cost for arriving at the destination address. Generally, the route metric value will be influenced by the line delay, bandwidth, line seizure ratio, degree of line reliability, hop count, MTU, etc. Different dynamic routing protocols will select one or several factor(s) to calculate the metric value. For example, the hop count is used to calculate the metric in RIP. The metric value is meaningful for comparison of the routing protocols of a type. The metric values of different routing protocols are not comparable and thus no conversion relationship exists. The metric value of the static route is 0.

Route Matching Fundamental

Longest matching means that when a IP packet is match  more than one route in the routing table, the router will select the longest matching route ,for example, here is a packet to the 10.1.1.2,when the router received this packet ,and then check the routing table, there are two route matching this destination, one route is 10.1.1.0/24 and the another  route is 10.0.0.0/8, so the router will select the route with 10.1.1.0/24 because this route match 24 bits while the route 10.0.0.0/8 only match 8 bits.
Preference is metric to select the best route discovery by different routing  protocol when they are have the same longest matching route. Route will prefer the small preference value as the best route .for example ,one route to 10.1.1.0/24 discovery by OSPF with the preference 10 and another route to 10.1.1.0/24 discovery by RIP with the preference 100, the route will select the OSPF route as the best route.
Cost is used to select the best route when there are more than one path to the same destination discovery by the same routing protocol .the less cost is prefer as the best route .

Static Route Configuration

In the network with simple networking, only the static route configuration is needed for enabling the router to work normal. Setting and using the static route carefully can improve the network performance and ensures bandwidth for the key applications.
There is another static route, called "interface static route", which indicates the destination network directly connected to the router's interface. The preference of the interface static route is 0, indicating the route is directly connected to the network.
The static route also has the following attributes:
Reachable route: IP packet is sent to the next hop according to the route identified by the destination, which is the general function of the static route. All normal routes fall in this case.
Destination unreachable route: when the static route towards a destination is of the "reject" parameter, all IP packets to the destination will be rejected. Besides, with the ICMP message, the source host will be notified of the unreachable destination.
Destination blackhole route: when the static route towards a destination is of the "blackhole" parameter, all IP packets to the destination will be discarded. However, no message is sent to the source host, which is different from the "reject" parameter.

The parameters are described as follows:
<ip_address>[<mask>|<masklen>]: destination IP address and mask
The IP address is in the dotted decimal format. Mask can be represented by either the dotted decimal or the mask length (i.e. the number of "1s" in the mask).
<interface_name>|<gateway_address>: transmitting interface or the next hop address
In configuring the static route, either the transmitting interface (interface-name) or the next hop address (gateway-address) can be specified according to the actual conditions.

In fact, all route items must have clear next hop address. When sending a packet, the IP searches the routing table for the matched route based on the destination of the packet. Only when the route specifies the next hop address, can the link layer find the relevant link layer address according to the next hop IP address and then forward the packet based on the link layer address.
The transmitting interface can be specified in the following cases:
For the interface that supports resolution from the network address to the link layer address (such as the Ethernet interface that supports ARP), the transmitting interface can be specified when: the ip-address and mask (or mask-length) specify a host address and the destination address is located in the network directly connected to the interface.


Configuration command and configuration mode

For the point-to-point interface, the next hop address can be specified by specifying the transmitting interface. In this case, the address of the peer interface connected to this interface is deemed to be the next hop address of the route. For example, the serial port that encapsulates the PPP can obtain the peer IP address through PPP negotiation. So only the transmitting interface instead of the next hop address needs to be specified.
The NBMA interface (such as the interface that encapsulates the X.25 or frame relay, dialing interface) supports point-to-multipoint. In this case, in addition to configuration of the IP route, secondary route should be established at the link layer, i.e. mapping from the IP address to the link layer address (such as dialer map ip, x.25 map ip or frame-relay map ip). So in configuring the static route, do not specify the transmitting interface but configure the next hop IP address.
<preference_value>:
Different preference configurations can be made through flexible application of the route management strategy. For example, in configuring multiple routes towards the network destination, load sharing can be implemented if the routes are assigned with the same preference; standby routes can be implemented if the routes are assigned with different preferences. Multiple preferences can be input in a command, but only the last preference is valid.
Other parameters:
parameters reject and blackhole: indicate the unreachable route and blackhole route respectively.

On the Router A router, configure a static route towards the destination network segment 129.1.0.0/16, whose next hop address is 10.0.0.2, the IP address of serial 2/0 interface of Router B router. If the link encapsulates PPP or HDLC, forwarding interface of the router can also be specified.
Configuration commands for the static route:
[RouterA]ip route-static 129.1.0.0 16   serial 2/0        or:
[RouterA]ip route-static 129.1.0.0 16   10.0.0.2          or:
[RouterA]ip route-static 129.1.0.0 255.255.0.0   10.0.0.2.

Static Route

Default Route

The default route is also a static route. In brief, it is used when no matched route item can be found in the routing table. In other words, only if there is not an appropriate route, the default route is used. In the routing table, the default route is the route towards the network 0.0.0.0 (mask is 0.0.0.0). The display ip routing command can be used to check whether the default route has been set. If the packet destination matches no route item in the routing table, the default route will be used. If there is no default route and the packet destination is not in the routing table, the packet will be discarded and an ICMP packet will be sent back to the source end to indicate "destination or network unreachable".
The default route is very useful in network. In the typical network with as many as a hundred routers, using the dynamic routing protocol may seize very large amount of bandwidth resources. While using the default route implies replacing the high-bandwidth link with the appropriate-bandwidth link to satisfy the communication requirements of large number of subscribers.
In the Internet, 99.99% of the routers have a default route.
The default route is not always the static route manually configured. Sometimes, the default route can be generated by the dynamic routing protocol. For example, the OSPF routing protocol configured with the Stub area will generate a default route dynamically
On the  router A, configure
ip route-static 0.0.0.0 0.0.0.0  10.0.0.2


Default Route

Route Self-Loop

"Route self-loop" refers to the case where a packet sent from a router is forwarded several times and then returns to the original router again because an error occurs to the routing tables of some routers. The cause may be that the static route is configured wrongly or the dynamic routing protocol calculates the route wrongly (although the probability is very small). When route self-loop occurs, the packet will be forwarded among the routers circularly and will not be discarded until TTL=0, thus greatly wasting the network resource. Therefore, "route self-loop" should be avoided as much as possible.

 
Route Self-Loop

As it shows in the above figure, we configure the static route on the Router A : ip route 20.0.0.0 8 10.0.0.2 , then configure the static route  on the Router B: ip rout 20.0.0.0 8 10.0.0.1 . When the data packet  which the desitation IP address is 20.0.0.0/8 reaches at Router A , the data packet will be sent to route B according to the static route configured on Router A. When Router B receives the data packet, it will be sent back to Router A again because of the static route configured on Router B . The data packet will be transmitted between Router A and Router B until the TTL=0, and the data packet will be discarded. That is the route self-loop.
Share:

0 komentar:

Post a Comment

ppcsh

engineer Gaptek. Powered by Blogger.

Labels

Translate