Routing Algorithm
Routing Algorithm
The main function of NL (Network Layer) is routing packets from the source machine to the
destination machine.
There are two processes inside router:
a) One of them handles each packet as it arrives, looking up the outgoing line to use for it in
the routing table. This process is forwarding.
b) The other process is responsible for filling in and updating the routing tables. That is where
the routing algorithm comes into play. This process is routing.
Nonadaptive algorithm –
do not base their routing decisions on measurements or estimates of the current traffic
and topology.
Instead, the choice of the route to use to get from I to J is computed in advance, off line,
and downloaded to the routers when the network is booted. This procedure is sometimes
called static routing.
Adaptive algorithm-
in contrast, change their routing decisions to reflect changes in the topology, and usually
the traffic as well.
In distance vector routing, the least-cost route between any two nodes is the route with
minimum distance.
In this protocol, as the name implies, each node maintains a vector (table) of minimum
distances to every node.
Initialization
Sharing
Updating
Initialization
Each node can know only the distance between itself and its immediate neighbors, those
directly connected to it. So for the moment, we assume that each node can send a
message to the immediate neighbors and find the distance between itself and these
neighbors. Below fig shows the initial tables for each node.
The distance for any entry that is not a neighbor is marked as infinite (unreachable).
Initialization of tables in distance vector routing
Sharing
The whole idea of distance vector routing is the sharing of information between
neighbors.
Although node A does not know about node E, node C does. So if node C shares its
routing table with A, node A can also know how to reach node E.
On the other hand, node C does not know how to reach node D, but node A does. If node
A shares its routing table with node C, node C also knows how to reach node D. In other
words, nodes A and C, as immediate neighbors, can improve their routing tables if they
help each other.
NOTE: In distance vector routing, each node shares its routing table with its immediate
neighbors periodically and when there is a change
Updating
When a node receives a two-column table from a neighbor, it needs to update its routing
table. Updating takes three steps:
1. The receiving node needs to add the cost between itself and the sending node to each value in
the second column. (x+y)
2. The receiving node needs to compare each row of its old table with the corresponding row of
the modified version of the received table.
a. If the next-node entry is different, the receiving node chooses the row with the
smaller cost. If there is a tie, the old one is kept.
b. If the next-node entry is the same, the receiving node chooses the new row.
For example, suppose node C has previously advertised a route to node X with distance 2.
Suppose that now there is no path between C and X; node C now advertises this route with a
distance of infinity.
C share its table to A and A update its table.
A’s modified table = Table receive from C + add cost (C-A=2) in each col.
Now compare modified A’s table with its old table and taking min value.
Final Diagram
When to Share
The table is sent both periodically and when there is a change in the table.
Periodic Update A node sends its routing table, normally every 30 s, in a periodic
update. The period depends on the protocol that is using distance vector routing.
Triggered Update A node sends its two-column routing table to its neighbors anytime
there is a change in its routing table. This is called a triggered update. The change can
result from the following.
1. A node receives a table from a neighbor, resulting in changes in its own table after updating.
2. A node detects some failure in the neighboring links which results in a distance change to
infinity.
Two-node instability
2. Split Horizon: In this strategy, instead of flooding the table through each interface, each
node sends only part of its table through each interface. If, according to its table, node B
thinks that the optimum route to reach X is via A, it does not need to advertise this piece of
information to A; the information has come from A (A already knows). Taking information
from node A, modifying it, and sending it back to node A creates the confusion. In our
scenario, node B eliminates the last line of its routing table before it sends it to A. In this
case, node A keeps the value of infinity as the distance to X. Later when node A sends its
routing table to B, node B also corrects its routing table. The system becomes stable after the
first update: both node A and B know that X is not reachable.
3. Split Horizon and Poison Reverse Using the split horizon strategy has one drawback.
Normally, the distance vector protocol uses a timer, and if there is no news about a route, the
node deletes the route from its table. When node B in the previous scenario eliminates the
route to X from its advertisement to A, node A cannot guess that this is due to the split
horizon strategy (the source of information was A) or because B has not received any news
about X recently. The split horizon strategy can be combined with the poison reverse
strategy. Node B can still advertise the value for X, but if the source of information is A, it
can replace the distance with infinity as a warning: "Do not use this value; what I know
about this route comes from you."
4. Send this LSPs to every other router, called flooding, in an efficient and reliable way.
4 3
A D
A
1
6
5 7
F
E 8
B 4 A 4 B 2 C 3 A 5 B 6
E 5 C 2 D 3 F 7 C 1 D 7
F 6 E 1 F 8 E 8
Sequence No is 32 bit.
Above Figure depicts the onset of congestion. When the number of packets hosts send
into the network is well within its carrying capacity, the number delivered is proportional
to the number sent. If twice as many are sent, twice as many are delivered. However, as
the offered load approaches the carrying capacity, bursts of traffic occasionally fill up the
buffers inside routers and some packets are lost. These lost packets consume some of the
capacity, so the number of delivered packets falls below the ideal curve. The network is
now congested. Unless the network is well designed, it may experience a congestion
collapse
difference between congestion control and flow control.
Congestion control has to do with making sure the network is able to carry the offered traffic. It
is a global issue, involving the behavior of all the hosts and routers.
Flow control, in contrast, relates to the traffic between a particular sender and a particular
receiver. Its job is to make sure that a fast sender cannot continually transmit data faster than the
receiver is able to absorb it.
To see the difference between these two concepts, consider a network made up of 100-Gbps
fiber optic links on which a supercomputer is trying to force feed a large file to a personal
computer that is capable of handling only 1 Gbps. Although there is no congestion (the network
itself is not in trouble), flow control is needed to force the supercomputer to stop frequently to
give the personal computer a chance to breathe.
At the other extreme, consider a network with 1-Mbps lines and 1000 large computers, half of
which are trying to transfer files at 100 kbps to the other half. Here, the problem is not that of
fast senders overpowering slow receivers, but that the total offered traffic exceeds what the
network can handle.
The reason congestion control and flow control are often confused is that the best way to handle
both problems is to get the host to slow down. Thus, a host can get a ‘‘slow down’’ message
either because the receiver cannot handle the load or because the network cannot handle it.
Warning Bit
1. A special bit in the packet header is set by the router to warn the source when congestion is
detected.
2. The bit is copied and piggy-backed on the ACK and sent to the sender.
3. The sender monitors the number of ACK packets it receives with the warning bit set and
adjusts its transmission rate accordingly.
Choke Packets
1. A more direct way of telling the source to slow down.
2. A choke packet is a control packet generated at a congested node and transmitted to
restrict traffic flow.
3. The source, on receiving the choke packet must reduce its transmission rate by a certain
percentage.
4. An example of a choke packet is the ICMP Source Quench
Packet. Hop-by-Hop Choke Packets
1. Over long distances or at high speeds choke packets are not very effective.
2. A more efficient method is to send to choke packets hop-by-hop.
3. This requires each hop to reduce its transmission even before the choke packet arrive at
the source
Load Shedding
1. When buffers become full, routers simply discard packets.
2. Which packet is chosen to be the victim depends on the application and on the error
strategy used in the data link layer.
3. For a file transfer, for, e.g. cannot discard older packets since this will cause a gap in the
received data.
4. For real-time voice or video it is probably better to throw away old data and keep new
packets.
5. Get the application to mark packets with discard priority.
The Leaky Bucket Algorithm used to control rate in a network. It is implemented as a single-
server queue with constant service time. If the bucket (buffer) overflows then packets are
discarded.
(a) A leaky bucket with water. (b) a leaky bucket with packets.
1. The leaky bucket enforces a constant output rate (average rate) regardless of the burstiness
of the input. Does nothing when input is idle.
2. The host injects one packet per clock tick onto the network. This results in a uniform flow
of packets, smoothing out bursts and reducing congestion.
3. When packets are the same size (as in ATM cells), the one packet per tick is okay. For
variable length packets though, it is better to allow a fixed number of bytes per tick. E.g.
1024 bytes per tick will allow one 1024-byte packet or two 512-byte packets or four 256-
byte packets on 1 tick
Token Bucket Algorithm
1. In contrast to the LB, the Token Bucket Algorithm, allows the output rate to vary,
depending on the size of the burst.
2. In the TB algorithm, the bucket holds tokens. To transmit a packet, the host must capture
and destroy one token.
3. Tokens are generated by a clock at the rate of one token every t sec.
4. Idle hosts can capture and save up tokens (up to the max. size of the bucket) in order to
send larger bursts later.