Você está na página 1de 52

MITA DUTTA Electrical Engineering Department Jadavpur University

Routing Protocols
The routers in an internet are responsible for receiving and forwarding IP datagrams through the interconnected set of sub-networks from source to destination. Routing protocols essential to operation of an internet. Router must have idea of topology and condition of internet. Routing protocols provide this information. Routing algorithm is used to make a routing decision for a particular datagram, based on current routing information. Decisions based on some least cost criterion.

Routing Table
One required for each router Entry for each network Not for each destination Routing only needs network portion
1

MITA DUTTA Electrical Engineering Department Jadavpur University

Once datagram reaches router attached to destination network, that router can deliver to host. Each entry shows next node on route Not whole route

Routing Tables in Hosts


May also exist in hosts If attached to single network with single router then not needed All traffic must go through that router (called the gateway) If multiple routers attached to network, host needs table saying which to use

A routing protocol is the implementation of a routing algorithm in software or hardware. A routing protocol uses metrics to determine which path to utilize to transmit a packet across an internetwork.
2

MITA DUTTA Electrical Engineering Department Jadavpur University

The metrics used by routing protocols include: Number of network layer devices along the path (hop count) Delay Load Cost

Static routing and Dynamic Routing :


The router learns about remote networks from neighbor routers or from an administrator. The router then builds a routing table, that describes how to find the remote networks. If the network is directly connected then the router already knows how to get to the network. If the networks are not attached, the router must learn how to get to the remote network with either static routing (administrator manually enters the routes in the router's table) or dynamic routing. The routers then update each other about all the networks they know. If a change occurs e.g. a router goes down, the dynamic
3

MITA DUTTA Electrical Engineering Department Jadavpur University

routing protocols automatically inform all routers about the change. If static routing is used, then the administrator has to update all changes into all routers and therefore no routing protocol is used.

Only dynamic routing uses routing protocols, which enable routers to : Dynamically discover and maintain routes Calculate routes Distribute routing updates to other routers Reach agreement with other routers about the network topology

Autonomous Systems (AS)


An autonomous system is an internet connected by homogeneous routers; generally, the routers are under the administrative control of a single entity.
4

MITA DUTTA Electrical Engineering Department Jadavpur University

Group of routers exchanging information via common routing protocol Set of routers and networks managed by single organization Connected Except in time of failure An interior router protocol (IRP) passes routing information between routers within an autonomous system. The protocol used within the autonomous system does not need to be implemented outside of the system.

Interior Routing Protocol (IRP)


Passes routing information between routers within AS Does not need to be implemented outside AS Allows IRP to be tailored May be different algorithms and routing information in different connected AS Need minimum information from other connected AS
5

MITA DUTTA Electrical Engineering Department Jadavpur University

At least one router in each AS must talk Use Exterior Routing Protocol (ERP) Examples of an IRP: Routing Information Protocol (RIP) Open Shortest Path First (OSPF) Protocol

Exterior Routing Protocol


The protocol used to pass routing information between routers in different autonomous systems is referred to as an exterior router protocol (ERP). Pass less information than IRP Router in first system determines route to target AS Routers in target AS then co-operate to deliver datagram ERP does not deal with details within target AS Examples of an EGP: Border Gateway Protocol (BGP) Exterior Gateway Protocol (Replaced by BGP)
6

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. Application of Exterior and Interior Routing Protocols

MITA DUTTA Electrical Engineering Department Jadavpur University

Approaches to Routing Protocols


"Distance Vector" and "Link State" are terms used to describe routing protocols which are used by routers to forward packets between networks. The purpose of any routing protocol is to dynamically communicate information about all network paths used to reach a destination and to select the from those paths, the best path to reach a destination network. The terms distance vector and link state are used to group routing protocols into two broad categories based on whether the routing protocol selects the best routing path based on a distance metric (the distance) and an interface (the vector), or selects the best routing path by calculating the state of each link in a path and finding the path that has the lowest total metric to reach the destination.

Distance Vector Routing

MITA DUTTA Electrical Engineering Department Jadavpur University

Distance means how far and vector means in which direction. Distance Vector Routing calculate a best route to reach a destination. Distance Vector means that Routers are advertised as vector of Distance and Direction.

Distance Vector Algorithm


Dx(y) = estimate of least cost from x to y Distance vector: Dx = [Dx(y): y N ] Node x knows cost to each neighbor v: c(x,v) Node x maintains Dx = [Dx(y): y N ] Node x also maintains its neighbors distance vectors For each neighbor v, x maintains Dv = [Dv(y): y N ]

Basic Idea:
Each node periodically sends its own distance vector estimate to neighbors
9

MITA DUTTA Electrical Engineering Department Jadavpur University

When a node x receives new DV estimate from neighbor, it updates its own DV using B-F equation: Dx(y) min{c(x,v) + Dv(y)} for each node y N

Under minor, natural conditions, the estimate Dx(y) converge to the actual least cost dx(y)

Bellman-Ford Equation:
Define dx(y) := cost of least-cost path from x to y Then Dx(y) min{c(x,v) + Dv(y)} for each node y where min is taken over all neighbors v of x N

Bellman-Ford example

10

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. Packet Switched Network

Clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3 du(z) = min { c(u,v) + dv(z), c(u,x) + dx(z), c(u,w) + dw(z) } = min {2 + 5, 1 + 3, 5 + 3} = 4 Node that achieves minimum is next hop in shortest path

DV EXAMPLE 1:

11

MITA DUTTA Electrical Engineering Department Jadavpur University

Packet Switched Network

In this network we have 3 routers X, Y and Z: Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} = min{2+0 , 7+1} = 2 Dx(z) = min{c(x,y) + Dy(z), c(x,z) + Dz(z)} = min{2+1 , 7+0} = 3 Node that achieves minimum is the next hop in the shortest path.

12

MITA DUTTA Electrical Engineering Department Jadavpur University

13

MITA DUTTA Electrical Engineering Department Jadavpur University

DV EXAMPLE 2

The current time (or iteration) in the algorithm with T, and shall begin (at time 0, or T=0) by creating distance matrices for each router to its immediate neighbors. The routing tables below, are build with the shortest path is highlighted with the color green, a new shortest path is highlighted with the color yellow.

14

MITA DUTTA Electrical Engineering Department Jadavpur University

At this point, all the routers (A,B,C,D) have new "shortest-paths" for their DV (the list of distances that are from them to another router via a neighbor). They each broadcast this new DV to all their neighbors: A to B and C, B to C and A, C to A, B, and D, and D to C. As each of these neighbors receives this information, they now recalculate the shortest path using it. For example: A receives a DV from C that tells A there is a path via C to D, with a distance (or cost) of 5. Since the current "shortestpath" to C is 23, then A knows it has a path to D that costs 23+5=28. As there are no other shorter paths that A knows about, it puts this as its current estimate for the shortest-path from itself (A) to D, via C.
15

MITA DUTTA Electrical Engineering Department Jadavpur University

At T =1

Again, all the routers have gained in the last iteration (at T=1) new "shortest-paths", so they all broadcast their DVs to their neighbors; This prompts each neighbor to re-calculate their shortest distances again. For instance: A receives a DV from B that tells A there is a path via B to D, with a distance (or cost) of 7. Since the current "shortestpath" to B is 3, then A knows it has a path to D that costs 7+3=10. This path to D of length 10 (via B) is shorter than the existing "shortest-path" to D of length 28 (via C), so it becomes the new "shortest-path" to D.
16

MITA DUTTA Electrical Engineering Department Jadavpur University

At T=2

This time, only routers A and D have new shortest-paths for their DVs. So they broadcast their new DVs to their neighbors: A broadcasts to B and C, and D broadcasts to C. This causes each of the neighbors receiving the new DVs to re-calculate their shortest paths. However, since the information from the DVs doesn't yield any shorter paths than they already have in their routing tables, then there are no changes to the routing tables. At T=3

17

MITA DUTTA Electrical Engineering Department Jadavpur University

None of the routers have any new shortest-paths to broadcast. Therefore, none of the routers receive any new information that might change their routing tables. So the algorithm comes to a stop. Distance vector routing protocols pass periodic copies of routing table to neighbor routers and accumulate distance vectors. In distance vector routing protocol, routers discover the best path to destination from each neighbor. The routing table updates proceed step by step from router to router.
Periodic Updates

Periodic updates means that at the end of a certain time period, updates will be transmitted.

18

MITA DUTTA Electrical Engineering Department Jadavpur University

Neighbors

In the context of routers, neighbors always means routers sharing a common data link. A distance vector routing protocol sends its updates to neighboring routers and depends on them to pass the update information along to their neighbors. For this reason, distance vector routing is said to use hop-by-hop updates.
Broadcast Updates

When a router first becomes active on a network, how does it find other routers and how does it announce its own presence? Several methods are available. The simplest is to send the updates to the broadcast address. Neighboring routers speaking the same routing protocol will hear the broadcasts and take appropriate action. Hosts and other devices uninterested in the routing updates will simply drop the packets.

Link State Routing :


19

MITA DUTTA Electrical Engineering Department Jadavpur University

A Link-state routing is a concept used in routing of packet-switched networks in computer communications. Link-state routing works by having the routers tell every router on the network about its closest neighbors. Each router does the following: Keeps track of its neighbors: the neighbors name, and the cost of the link to the neighbor. Construct an LSA (Link state Advertisement) packet that lists its neighbors router names and link costs. This includes new neighbors, changes in link costs and links to neighbors that have gone down. Sends out LSA packet so that all routers receive it. Records each LSA packet it receives in its database immediately, to ensure that it has the most recently generated LSA packet from every other router. Using accumulated LSA packet data to construct a complete map of internetwork topology.
20

MITA DUTTA Electrical Engineering Department Jadavpur University

Can calculate shortest path to each destination network Router use routing algorithm to determine shortest paths In practice, Dijkstra's algorithm Open shortest path first (OSPF) protocol uses link-state routing.

Dijkstra's Algorithm : Find shortest paths from given source node to all other nodes, by developing paths in order of increasing path length Proceeds in stages Let
N s M = set of nodes in the network = source node = set of nodes so far incorporated

dij = link cost from node i to node j


21

MITA DUTTA Electrical Engineering Department Jadavpur University

dii = 0 dij = if nodes are not directly connected dij 0 if nodes directly connected Dn= cost of least-cost path s to n currently known At termination, cost of least-cost path in graph from s to n The algorithm has three steps; steps 2 and 3 are repeated until M = N. That is, steps 2and 3 are repeated until final paths have been assigned to all nodes in the network: 1. Initialization M = {s} i.e. set of nodes so far incorporated consists of only source node Dn = dsn for n s i.e. initial path costs to neighboring nodes are link costs 2. Get Next Node Find neighboring node not in M with least-cost path from s
22

MITA DUTTA Electrical Engineering Department Jadavpur University

Incorporate node into M Incorporate that node in M that contributes to the path. This can be expressed as: Find wM such that Add w to M; 3. Update Least-Cost Paths

Dn = min[Dn, Dw + dwn] for all n M If the latter term is the minimum, the path from s to n is now the path from s to w concatenated with the link from w to n. The algorithm terminates when all nodes have been added to M.

23

MITA DUTTA Electrical Engineering Department Jadavpur University

Figure. Packet-switched Network Table below shows the result of applying this algorithm to the above Figure using s = 1. Note that at each step, the path to each node plus the total cost of that path is generated. After the final iteration, the least-cost path to each node and the cost of that path have been developed. The same procedure can be used with node 2 as source node, and so on.

24

MITA DUTTA Electrical Engineering Department Jadavpur University

Table

25

MITA DUTTA Electrical Engineering Department Jadavpur University

Figure. Example of Dijkstras algorithm based on above Table

Bellman-Ford Algorithm:
Find shortest paths from source node such that paths contain at most one link Find shortest paths such that paths have at most two links
26

MITA DUTTA Electrical Engineering Department Jadavpur University

= source node

w(i, j) = link cost from node i to node j w(i, i) = 0 w(i, j) = if nodes are not directly connected w(i, j) 0 if nodes directly connected h = maximum number of links in path at current stage

Lh(n) =cost of least-cost path from s to n such that no more than h links

The algorithm has the following steps, step 2 of which is repeated until none of the costs change:

1. Initialization

L0(n) = , for all n s Lh(s) = 0, for all h 2. Update For each successive h 0: For each n s, compute
27

MITA DUTTA Electrical Engineering Department Jadavpur University

Connect n with predecessor node j that achieves minimum Eliminate any connection of n with different predecessor node formed during an earlier iteration. Path from s to n terminates with link from j to n Table b shows the result of applying this algorithm to Figure, using s = 1. At each step, the least-cost paths with a maximum number of links equal to h are found. After the final iteration, the least-cost path to each node, and the cost of that path, have been developed. The same procedure can be used with node 2 as source node, and so on. Note that the results agree with those obtained using Dijkstra's algorithm. Figure illustrate the results of Table . Table b Bellman-Ford Algorithm (s=1)

28

MITA DUTTA Electrical Engineering Department Jadavpur University

29

MITA DUTTA Electrical Engineering Department Jadavpur University

Figure. Example of Bellman-Ford algorithm based on above Table

Open Shortest Path First Protocol


OSPF (Open Shortest Path First) is a router protocol used within larger autonomous system networks OSPF is interior routing protocol for TCP/IP based internets Link state routing used Router maintains descriptions of state of local links Transmits updated state information to all routers it knows about Router receiving update must acknowledge Each router maintains database Directed graph

Router Database Graph


30

MITA DUTTA Electrical Engineering Department Jadavpur University

Vertices Router Network


Transit, if it can carry data that neither originates nor terminates on an end system attached to this network.

Stub, if it is not transit Edges graph edges that connect two router vertices when the corresponding routers are connected to each other by a direct point-to-point link. graph edges that connect a router vertex to a network vertex when the router is directly connected to the network.

Figure below shows an autonomous system.


31

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. An Autonomous system Figure below shows the directed graph of an above autonomous system.
32

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. Directed graph of autonomous system

The mapping is straightforward:


33

MITA DUTTA Electrical Engineering Department Jadavpur University

Two routers joined by a point-to-point link are represented in the graph as being directly connected by a pair of edges, one in each direction (e.g., routers 6 and 10). When multiple routers are attached to a network, the directed graph shows all routers bi-directionally connected to the network vertex (e.g., routers 1,2,3, and 4 all connect to network 3). If a single router is attached to a network, the network will appear in the graph as a stub connection (e.g., network 7). An end system, called a host, can be directly connected to a router; such a case is depicted in the corresponding graph (e.g., host 1). If a router is connected to other autonomous systems, then the path cost to each network in the other system must be obtained by some exterior routing protocol (ERP). Each such network is

34

MITA DUTTA Electrical Engineering Department Jadavpur University

represented on the graph by a stub and an edge to the router with the known path cost (e.g., networks 12 through 15). A cost is associated with the output side of each router interface. This cost is configurable by the system administrator. Arcs on the graph are labeled with the cost of the corresponding router-output interface. Arcs having no labeled cost have a cost of 0. Note that arcs leading from networks to routers always have a cost of 0. A database corresponding to the directed graph is maintained by each router. It is pieced together from link-state messages from other routers in the internet. Using Dijkstra's algorithm a router calculates the least-cost path to all destination networks. The result for router 6 of Figure (Directed graph) is shown as a tree in Figure below, with R6 as the root of the tree. The tree gives the entire route to any destination network or host. However, only the next hop to the destination is used in the forwarding process. The resulting routing table for router 6 is shown in Table. The table includes
35

MITA DUTTA Electrical Engineering Department Jadavpur University

entries for routers advertising external routes (routers 5 and 7). For external networks whose identity is known, entries are also provided.

36

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. The Shortest Path Tree for router R6

Routing table for router R6

37

MITA DUTTA Electrical Engineering Department Jadavpur University

OSPF Packet Header

38

MITA DUTTA Electrical Engineering Department Jadavpur University

Version number: 2 is current Type: one of 5 Packet length: in octets including header Router id: This field contains the 4-byte IP address. The router (source) ID is used to uni-quely identify the router throughout the autonomous system. Area id: Area to which source router belongs. This is also a 4byte number.
39

MITA DUTTA Electrical Engineering Department Jadavpur University

Checksum This field includes the checksum for the entire OSPF packet, excluding the authentication for data

corruption. Authentication type: This field contains the code for the authentication.

Authentication data: used by authentication procedure OSPF Packet Types


Hello: used in neighbour discovery. Hello packets are used to form a neighbor relationship between two routers. Database description: the database description (DBD) packet, is used mostly during the database exchange. Link state request a link-state request packet, is sent if part of the database is missing or out-of-date. The link-state request packet is used

40

MITA DUTTA Electrical Engineering Department Jadavpur University

to retrieve that precise piece of database information that is missing. Link state update Responds to a link-state request packet. Link state acknowledgement Acknowledges link-state update packets

Routing Information Protocol (RIP)


The Routing Information Protocol (RIP) is a distance-vector protocol that uses hop count as its metric. RIP is widely used for routing traffic in the global Internet and is an interior gateway protocol (IGP), which means that it performs routing within a single autonomous system. Features associated with RIP include the routing-update process, RIP routing metrics, routing stability, and routing timers.

Routing Updates

41

MITA DUTTA Electrical Engineering Department Jadavpur University

RIP sends routing-update messages at regular intervals and when the network topology changes. After updating its routing table, the router immediately begins transmitting routing updates to inform other network routers of the change.

RIP Routing Metric


RIP uses a routing metric (hop count) to measure the distance between the source and a destination network. The maximum number of hops in a path is 15. If the metric value increases by one causes the metric to be infinity (that is, 16), the network destination is considered unreachable.

RIP Stability Features


To adjust for rapid network-topology changes, RIP specifies a number of stability features that are common to many routing protocols. RIP, for example, implements the split-horizon and holddown mechanisms to prevent incorrect routing information from

42

MITA DUTTA Electrical Engineering Department Jadavpur University

being propagated. In addition, the RIP hop-count limit prevents routing loops from continuing indefinitely.

RIP Timers
RIP uses numerous timers to regulate its performance. These include a routing-update timer, a route timeout, and a route-flush timer. The routing-update timer clocks the interval between periodic routing updates. Generally, it is set to 30 seconds. Each routingtable entry has a route-timeout timer associated with it. When the route-timeout timer expires, the route is marked invalid but is retained in the table until the route-flush timer expires.

RIP Packet Format

43

MITA DUTTA Electrical Engineering Department Jadavpur University

Fig. RIP Packet A = Command (Request or Response) B = Version Number C = Zero D = Address Family Identifier E = Address F = Metric CommandIndicates whether the packet is a request or a response. The request asks that a router send all or part of its routing table. The response can be an unsolicited regular routing update or a reply to a request. Responses contain routing table entries. Version NumberSpecifies the RIP version used. ZeroNot used.

44

MITA DUTTA Electrical Engineering Department Jadavpur University

Address-Family Identifier (AFI)Specifies the address family used. RIP is designed to carry routing information for several different protocols. The AFI for IP is 2. AddressSpecifies the IP address for the router. MetricIndicates how many internetwork hops (routers) have been traversed in the trip to the destination. This value is between 1 and 15 for a valid route, or 16 for an unreachable route.

Border Gateway Protocol (BGP)


Allows routers (gateways) in different ASs to exchange routing information The protocol operates in terms of messages

BGP Messages Open Start neighbour relationship with another router Update
45

MITA DUTTA Electrical Engineering Department Jadavpur University

Transmit information about single route List multiple routes to be withdrawn Keep-alive Acknowledge open message Periodically confirm neighbour relationship Notification Send when error condition detected
It has three functional procedures Neighbour acquisition Neighbour reach-ability Network reach-ability

Neighbor acquisition
routers are considered to be neighbors if they are attached to the same sub-network
46

MITA DUTTA Electrical Engineering Department Jadavpur University

If in different ASs routers may wish to exchange information Neighbour acquisition is when two neighbouring routers agree to exchange routing information regularly One router sends request (Open Message), the other acknowledges (Keep-alive Message)

Neighbor reach-ability
Once a neighbor relationship is established, the neighbour reach-ability procedure is used to maintain the relationship. Periodic issue of keep-alive messages. Between all routers that are neighbours.

Network reachability
Each router keeps database of sub-networks it can reach and preferred route.

47

MITA DUTTA Electrical Engineering Department Jadavpur University

When change made, router issues update message that is broadcast to all other routers implementing BGP. All BGP routers build up and maintain routing information.

Figure below illustrates the formats of all of the BGP messages. Each message begins with a 19-octet header containing three fields : Marker : Reserved for authentication. The sender may insert a value in this field that would be used as part of an authentication mechanism to enable the recipient to verify the identity of the sender. Length : Length of message in octets. Type: Type of message: Open, Update, Notification, Keepalive.

48

MITA DUTTA Electrical Engineering Department Jadavpur University

49

MITA DUTTA Electrical Engineering Department Jadavpur University

Open Message Format Sends open message Identifies senders AS and gives IP address Includes Hold Time As proposed by sender If recipient prepared to open neighbour relationship Calculate hold time Reply with keep-alive Keep-alive Message Format Header only Update Message Format Information about single route through internet Information to be added to database of any recipient router Network layer reach-ability information (NLRI)

50

MITA DUTTA Electrical Engineering Department Jadavpur University

List of network portions of IP addresses of subnets reached by this route Total path attributes length field Path attributes field List of previously advertised routes being withdrawn May contain both Notification Message Format Error notification Message header error Includes authentication and syntax errors Open message error Syntax errors and option not recognised Proposed hold time unacceptable Update message error Syntax and validity errors Hold time expired
51

MITA DUTTA Electrical Engineering Department Jadavpur University

Close connection in absence of any other error Finite state machine error Includes any procedural error. Cease Used by a router to close a connection with another router in the absence of any other error.

52

Você também pode gostar