100% found this document useful (1 vote)
167 views66 pages

Network Layer

The network layer is responsible for end-to-end packet delivery across multiple hops between routers. It must understand network topology and choose efficient paths while avoiding overloading some lines. Connectionless protocols like IP route each packet independently, while connection-oriented protocols establish paths for virtual circuits. Routing algorithms populate routing tables to direct packets and adapt to changes using metrics like hop count or distance.

Uploaded by

Eatus Aspiritus
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (1 vote)
167 views66 pages

Network Layer

The network layer is responsible for end-to-end packet delivery across multiple hops between routers. It must understand network topology and choose efficient paths while avoiding overloading some lines. Connectionless protocols like IP route each packet independently, while connection-oriented protocols establish paths for virtual circuits. Routing algorithms populate routing tables to direct packets and adapt to changes using metrics like hop count or distance.

Uploaded by

Eatus Aspiritus
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 66

THE NETWORK LAYER

• The data link layer, discussed previously, has the goal of just
moving frames from one end of a wire to the other.
• In contrast to the data link layer, the network layer is concerned with
getting packets from the source to the destination.
 Getting to the destination may require making many hops at intermediate
routers along the way.
 The network layer is the lowest layer that deals with end-to-end
transmission.
• To achieve its goals, the network layer must know about the
topology of the network (i.e., the set of all routers and links) and
choose appropriate paths through it, even for large networks.
• It must also take care when choosing routes to avoid overloading
some of the communication lines and routers while leaving others
idle.
• Finally, when the source and destination are in different networks, it
is up to the network layer to deal with them.
Working of Network Layer Protocols

• The major components of the network are the ISP’s equipment (routers
connected by transmission lines), and the customers’ equipment.
• The routers on customer premises are considered part of the ISP network
because they run the same algorithms as the ISP’s routers.
• A host with a packet to send transmits it to the nearest router, either on its
own LAN or over a point-to-point link to the ISP.
• The packet is stored there until it has fully arrived and the link has finished
its processing by verifying the checksum.
• Then it is forwarded to the next router along the path until it reaches the
destination host, where it is delivered.
• This mechanism is store-and-forward packet switching.
NETWORK LAYER DESIGN ISSUES

Services Provided to the Transport Layer

• The network layer provides services to the transport layer at


the network layer/transport layer interface.
• The services need to be carefully designed with the following
goals in mind:
1. The services should be independent of the router technology.
2. The transport layer should be shielded from the number, type, and
topology of the routers present.
3. The network addresses made available to the transport layer should
use a uniform numbering plan, even across LANs and WANs.
Implementation of Connectionless Service
• In connectionless service, the packets are injected into the network
individually and routed independently of each other. No advance
setup is needed.
• In this context, the packets are frequently called datagrams (in
analogy with telegrams) and the network is called a datagram
network.

Working of datagram Network


• Let process P1 on host H1 has a long message for process P2 on host H2. It
hands the message to the transport layer, with instructions to deliver it to
process P2.
• The transport layer add a transport header to the front of the message and hands
the result to the network layer.
• Let the message is longer than the maximum packet size, so the network layer
has to break it into four packets, 1, 2, 3, and 4, and send each of them in turn to
router A using some point-to-point protocol.
• At this point the ISP takes over.
• Every router has an internal table telling it where to send packets for each
of the possible destinations.
• Each table entry is a pair consisting of a destination and the outgoing line to
use for that destination. Only directly connected lines can be used.
• At A, packets 1, 2, and 3 are stored briefly, having arrived on the incoming
link and had their checksums verified. Then each packet is forwarded
according to A’s table.
• However, something different happens to packet 4. When it gets to A it is
sent to router B, even though it is also destined for F. For some reason, A
decided to send packet 4 via a different route than that of the first three
packets. Perhaps it has learned of a traffic jam somewhere along the ACE
path and updated its routing table.
• The algorithm that manages the tables and makes the routing decisions is
called the routing algorithm.

• IP (Internet Protocol), which is the basis for the entire Internet, is the
dominant example of a connectionless network service. Each packet carries
a destination IP address that routers use to individually forward each
packet. The addresses are 32 bits in IPv4 packets and 128 bits in IPv6
packets.
Implementation of Connection-Oriented Service
• In connection-oriented service, a path from the source router all the
way to the destination router must be established before any data
packets can be sent.
• This connection is called a VC (virtual circuit), in analogy with the
physical circuits set up by the telephone system, and the network is
called a virtual-circuit network.

• The idea behind virtual circuits is to avoid having to choose a new route for
every packet sent.
• When a connection is established, a route from the source machine to the
destination machine is chosen as part of the connection setup and stored in
tables inside the routers.
• That route is used for all traffic flowing over the connection, exactly the same
way that the telephone system works.
• When the connection is released, the virtual circuit is also terminated.
• With connection-oriented service, each packet carries an identifier telling which
virtual circuit it belongs to.
Working of virtual-circuit network
• Host H1 has established connection 1 with host H2. This connection is
remembered as the first entry in each of the routing tables.
• The first line of A’s table says that if a packet bearing connection identifier
1 comes in from H1, it is to be sent to router C and given connection
identifier 1. Similarly, the first entry at C routes the packet to E, also with
connection identifier 1.
• Now, if H3 also wants to establish a connection to H2, it chooses
connection identifier 1 and tells the network to establish the virtual circuit.
• This leads to the second row in the tables. Note that we have a conflict here
because although A can easily distinguish connection 1 packets from H1
from connection 1 packets from H3, C cannot do this.
• For this reason, A assigns a different connection identifier to the outgoing
traffic for the second connection.
• To avoid this kind of conflict, routers need the ability to replace connection
identifiers in outgoing packets. This process is called label switching.

• An example of a connection-oriented network service is MPLS


(MultiProtocol Label Switching).
ROUTING ALGORITHMS
• The main function of the network layer is routing packets from
the source machine to the destination machine.
• The routing algorithm is responsible for deciding which output
line an incoming packet should be transmitted on.
 If the network uses datagrams internally, this decision must be made
anew for every arriving data packet since the best route may have
changed since last time.
 If the network uses virtual circuits internally, routing decisions are
made only when a new virtual circuit is being set up. Thereafter, data
packets just follow the already established route. This is called session
routing because a route remains in force for an entire session.

• In particular, routing algorithm is responsible for filling in and


updating the routing tables.
• Routing algorithms can be grouped into two major classes:
nonadaptive and adaptive.

• Nonadaptive algorithms: The routing decisions are not based


on any measurements or estimates of the current topology and
traffic. Instead, the choice of the route to use to get from I to J
(for all I and J) is computed in advance, offline, and
downloaded to the routers when the network is booted.
o These static routing algorithms do not respond to failures and are
mostly useful for situations in which the routing choice is clear.

• Adaptive algorithms: change their routing decisions to reflect


changes in the topology, and sometimes changes in the traffic
as well.
o These dynamic routing algorithms differ in from where they get their
information, when they change the routes, and what metric is used for
optimization.
The Optimality Principle
• If router J is on the optimal path from router I to router K, then
the optimal path from J to K also falls along the same route.
• Let the part of the route from I to J is r1 and the rest of the
route is r2. If a route better than r2 existed for J to K, it could
be concatenated with r1 to improve the route from I to K,
contradicting our statement that r1r2 is optimal.
• The set of optimal routes from all sources to a given
destination form a tree rooted at the destination. Such a tree is
called a sink tree, where the distance metric is the number of
hops.
• The goal of all routing algorithms is to discover and use the
sink trees for all routers.
A Network A sink tree for router B

• A sink tree is not necessarily unique; other trees with the same path lengths
may exist.
• If we allow all of the possible paths to be chosen, the tree becomes a more
general structure called a DAG (Directed Acyclic Graph).
• It is assumed that the paths do not interfere with each other, so, for
example, a traffic jam on one path will not cause another path to divert.
Shortest Path Algorithm
• The idea is to build a graph of the network, with each node of the
graph representing a router and each edge of the graph representing
a communication line, or link. To choose a route between a given
pair of routers, the algorithm just finds the shortest path between
them on the graph.

• One way of measuring path length is the number of hops.


 Using this metric, the paths ABC and ABE in Figure are equally long.
• Another metric is the geographic distance in kilometers.
 In this case ABC is clearly much longer than ABE.
• Many other metrics besides hops and physical distance are also
possible.
 For example, each edge could be labeled with the mean delay of a standard
test packet, as measured by hourly runs. With this graph labeling, the
shortest path is the fastest path.
 The labels on the edges could be computed as a function of the distance,
bandwidth, average traffic, communication cost, measured delay, etc.
• Here, we will consider an algorithm that finds the shortest
paths between a source and all destinations in the network.
• Each node is labeled with its distance from the source node
along the best known path.
• Initially, no paths are known, so all nodes are labeled with
infinity. As the algorithm proceeds and paths are found, the
labels may change, reflecting better paths.
• A label may be either tentative or permanent. Initially, all
labels are tentative. When it is discovered that a label
represents the shortest possible path from the source to that
node, it is made permanent and never changed thereafter.
The shortest path from A to D
Steps
• Let, we want to find the shortest path from A to D.
• We start out by marking node A as permanent, indicated by a filled-
in circle. Then we examine each of the nodes adjacent to A (the
working node), relabeling each one with the distance to A.
• Whenever a node is relabeled, we also label it with the node from
which the probe was made so that we can reconstruct the final path
later.
• Having examined each of the nodes adjacent to A, we examine all
the tentatively labeled nodes in the whole graph and make the one
with the smallest label permanent. This one becomes the new
working node.
• We now start at B and examine all nodes adjacent to it.
• If the sum of the label on B and the distance from B to the node
being considered is less than the label on that node, we have a
shorter path, so the node is relabeled.
Flooding
• When a routing algorithm is implemented, each router must make
decisions based on local knowledge, not the complete picture of the
network.
• Flooding is a simple local technique in which every incoming packet
is sent out on every outgoing line except the one it arrived on.
• Flooding obviously generates vast numbers of duplicate packets, in
fact, an infinite number unless some measures are taken to damp the
process.
• One such measure is to have a hop counter contained in the header
of each packet that is decremented at each hop, with the packet
being discarded when the counter reaches zero.
 Ideally, the hop counter should be initialized to the length of the path from
source to destination.
 If the sender does not know how long the path is, it can initialize the
counter to the worst case, namely, the full diameter of the network.
• A better technique for damming the flood is to have routers keep
track of which packets have been flooded, to avoid sending them out
a second time.
• One way to achieve this goal is to have the source router put a sequence
number in each packet it receives from its hosts. Each router then needs a
list per source router telling which sequence numbers originating at that
source have already been seen. If an incoming packet is on the list, it is not
flooded.

• Flooding is not practical for sending most packets, but it does have
some important uses.
 First, it ensures that a packet is delivered to every node in the network. This
may be wasteful if there is a single destination that needs the packet, but it
is effective for broadcasting information.
 Second, flooding is tremendously robust. Even if large numbers of routers
are blown to bits, flooding will find a path if one exists, to get a packet to
its destination.
 Flooding also requires little in the way of setup. The routers only need to
know their neighbors.
 Flooding always chooses the shortest path because it chooses every
possible path in parallel.
Distance Vector Routing
• It is a dynamic routing algorithms and is more efficient because it
find shortest path for the current topology.
• A distance vector routing algorithm operates by having each router
maintain a table (i.e., a vector) giving the best known distance to
each destination and which link to use to get there.
• These tables are updated by exchanging information with the
neighbors. Eventually, every router knows the best link to reach
each destination.

• In particular, each router maintains a routing table indexed by, and


containing one entry for each router in the network.
 This entry has two parts: the preferred outgoing line to use for that
destination and an estimate of the distance to that destination.
 The distance might be measured as the number of hops or using another
metric.
 The router is assumed to know the distance to each of its neighbors.
 If the metric is hops, the distance is just one hop.
Steps
• Assume that delay is used as a metric and that the router
knows the delay to each of its neighbors.
• Once every T msec, each router sends to each neighbor a list
of its estimated delays to each destination. It also receives a
similar list from each neighbor.
• Imagine that one of these tables has just come in from
neighbor X, with Xi being X’s estimate of how long it takes to
get to router i.
• If the router knows that the delay to X is m msec, it also knows
that it can reach router i via X in Xi+m msec.
• By performing this calculation for each neighbor, a router can
find out which estimate seems the best and use that estimate
and the corresponding link in its new routing table.
• Note that the old routing table is not used in the calculation.
8 10 12 6
• In figure, the first four columns show the delay vectors received
from the neighbors of router J.
• A claims to have a 12-msec delay to B, a 25-msec delay to C, a 40-
msec delay to D, etc.
• Suppose that J has measured or estimated its delay to its neighbors,
A, I, H, and K, as 8, 10, 12, and 6 msec, respectively.
• Consider how J computes its new route to router G.
 It knows that it can get to A in 8 msec, and furthermore A claims to be able
to get to G in 18 msec, so J knows it can count on a delay of 26 msec to G
if it forwards packets bound for G to A.
 Similarly, it computes the delay to G via I, H, and K as 41 (31+10), 18
(6+12), and 37 (31+6) msec, respectively.
 The best of these values is 18, so it makes an entry in its routing table that
the delay to G is 18 msec and that the route to use is via H.
• The same calculation is performed for all the other destinations,
with the new routing table shown in the last column of the figure.
The Count-to-Infinity Problem
• Distance vector routing has a serious drawback in practice: although it
converges to the correct answer, it may do so slowly.
• In particular, it reacts rapidly to good news, but slowly to bad news.
• Consider a five-node (linear) network where the delay metric is the number
of hops. Suppose A is down initially and all the other routers know this.
They have all recorded the delay to A as infinity. When A comes up, the
other routers learn about it via the vector exchanges.

• Settling of routes to best paths across the network is called convergence.


• The good news is spreading at the rate of one hop per exchange. In a
network whose longest path is of length N hops, within N exchanges
everyone will know about newly revived links and routers.
• Now let us consider the situation where all the links and routers are
initially up. Suddenly, A goes down.
• At the first packet exchange, B does not hear anything from A and
try to reach A via C and other nodes.
• From the figure, it is clear that bad news travels slowly: no router
ever has a value more than one higher than the minimum of all its
neighbors.
• Gradually, all routers work their way up to infinity, but the number
of exchanges required depends on the numerical value used for
infinity. For this reason, it is wise to set infinity to the longest path
plus 1.
• This problem is known as the count-to-infinity problem. The core of
the problem is that when X tells Y that it has a path somewhere, Y
has no way of knowing whether it itself is on the path.
Link State Routing
• The primary problem with the distance vector routing is that the
algorithm often took too long to converge after the network
topology changed (due to the count-to-infinity problem).
• Consequently, it was replaced by link state routing algorithm.
• The variants of link state routing called IS-IS and OSPF are the
routing algorithms that are most widely used inside large networks
and the Internet today.

• In link state routing, each router must do the following things to


make it work:
1. Discover its neighbors and learn their network addresses.
2. Set the distance or cost metric to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to and receive packets from all other routers.
5. Compute the shortest path to every other router.
Learning about the Neighbors
• When a router is booted, its first task is to learn who its neighbors
are.
• It accomplishes this goal by sending a special HELLO packet on
each point-to-point line.
• The router on the other end is expected to send back a reply giving
its name.
• These names must be globally unique because when a distant router
later hears that three routers are all connected to F, it is essential that
it can determine whether all three mean the same F.
• When two or more routers are connected by a broadcast link (e.g., a
switch, ring, or classic Ethernet), the situation is slightly more
complicated.
• Figure illustrates a broadcast LAN to which three routers, A, C, and
F, are directly connected. Each of these routers is connected to one
or more additional routers.
• The broadcast LAN provides connectivity between each pair of attached
routers. However, modeling the LAN using point-to-point links increases
the size of the topology and leads to wasteful messages.
• A better way to model the LAN is to consider it as a node itself. Here, we
have introduced a new, artificial node, N, to which A, C, and F are
connected.
• One designated router on the LAN is selected to play the role of N in the
routing protocol.
• The fact that it is possible to go from A to C on the LAN is represented by
the path ANC here.
Setting Link Costs
• The link state routing algorithm requires each link to have a distance
or cost metric for finding shortest paths.
• The cost to reach neighbors can be set automatically, or configured
by the network operator.
• A common choice is to make the cost inversely proportional to the
bandwidth of the link.
 For example, 1-Gbps Ethernet may have a cost of 1 and 100-Mbps Ethernet
a cost of 10.
 This makes higher-capacity paths better choices.

• If the network is geographically spread out, the delay of the links


may be factored into the cost so that paths over shorter links are
better choices.
 The most direct way to determine this delay is to send over the line a
special ECHO packet that the other side is required to send back
immediately.
 By measuring the round-trip time and dividing it by two, the sending router
can get a reasonable estimate of the delay.
Building Link State Packets
• Once the information needed for the exchange has been
collected, the next step is for each router to build a packet
containing all the data.
• The packet starts with the identity of the sender, followed by a
sequence number, age and a list of neighbors. The cost to each
neighbor is also given.

A network with link cost The link state packets for this network
• Building the link state packets is easy. The hard part is
determining when to build them.
 One possibility is to build them periodically, that is, at regular intervals.
 Another possibility is to build them when some significant event
occurs, such as a line or neighbor going down or coming back up again
or changing its properties appreciably.

Distributing the Link State Packets

• Distribution of the link state packets should be in such a


manner that all of the routers must get all of the link state
packets quickly and reliably.
• The fundamental idea is to use flooding to distribute the link
state packets to all routers.
• To keep the flood in check, each packet contains a sequence number
that is incremented for each new packet sent.
 Routers keep track of all the (source router, sequence) pairs they see.
 When a new link state packet comes in, it is checked against the list of
packets already seen.
 If it is new, it is forwarded on all lines except the one it arrived on.
 If it is a duplicate, it is discarded.
 If a packet with a sequence number lower than the highest one seen so far
ever arrives, it is rejected as being obsolete as the router has more recent
data.

• This algorithm has a few manageable problems


 First, if the sequence numbers wrap around, confusion will reign. The
solution here is to use a 32-bit sequence number. With one link state packet
per second, it would take 137 years to wrap around, so this possibility can
be ignored.
 Second, if a router ever crashes, it will lose track of its sequence number. If
it starts again at 0, the next packet it sends will be rejected as a duplicate.
 Third, if a sequence number is ever corrupted and X is received instead of
Y, packets Y through X will be rejected as obsolete, since the current
sequence number will be thought to be X.
• The previous mentioned problems can be solved by including the age of
each packet after the sequence number and decrement it once per second.
• When the age hits zero, the information from that router is discarded.
• Normally, a new packet comes in, say, every 10 sec, so router information
only times out when a router is down (or six consecutive packets have been
lost, an unlikely event).
• The Age field is also decremented by each router during the initial flooding
process, to make sure no packet can get lost and live for an indefinite
period of time (a packet whose age is zero is discarded).

• Some refinements to this algorithm are possible to make it more robust


 When a link state packet comes in to a router for flooding, it is not queued for
transmission immediately. Instead, it is put in a holding area to wait a short while in
case more links are coming up or going down.
 If another link state packet from the same source comes in before the first packet is
transmitted, their sequence numbers are compared. If they are equal, the duplicate is
discarded. If they are different, the older one is thrown out.
 To guard against errors on the links, all link state packets are acknowledged.
• The data structure used by router B for the network shown in the
previous figure is depicted below.

• Each row here corresponds to a recently arrived, but as yet not fully processed,
link state packet.
• The table records where the packet originated, its sequence number and age,
and the data.
• In addition, there are send and acknowledgement flags for each of B’s three
links (to A, C, and F, respectively).
• The send flags mean that the packet must be sent on the indicated link. The
acknowledgement flags mean that it must be acknowledged there.
• The link state packet from A arrives directly, so it must be sent to C
and F and acknowledged to A, as indicated by the flag bits.
• Similarly, the packet from F has to be forwarded to A and C and
acknowledged to F.
• However, the situation with the third packet, from E, is different.
 It arrives twice, once via EAB and once via EFB.
 Consequently, it has to be sent only to C but must be acknowledged to both
A and F, as indicated by the bits.

• If a duplicate arrives while the original is still in the buffer, bits have
to be changed.
 For example, if a copy of C’s state arrives from F before the fourth entry in
the table has been forwarded, the six bits will be changed to 100011 to
indicate that the packet must be acknowledged to F but not sent there.
Computing the New Routes
• Once a router has accumulated a full set of link state packets, it
can construct the entire network graph because every link is
represented.
• Every link is, in fact, represented twice, once for each
direction. The different directions may even have different
costs.
• The shortest-path computations may then find different paths
from router A to B than from router B to A.
• Now shortest-path algorithm can be run locally to construct the
shortest paths to all possible destinations.
• The results of this algorithm tell the router which link to use to
reach each destination. This information is installed in the
routing tables, and normal operation is resumed.
• Compared to distance vector routing, link state routing requires
more memory and computation.
• For a network with n routers, each of which has k neighbors, the
memory required to store the input data is proportional to kn, which
is at least as large as a routing table listing all the destinations.
• Also, the computation time grows faster than kn, even with the most
efficient data structures, an issue in large networks.
• Nevertheless, in many practical situations, link state routing works
well because it does not suffer from slow convergence problems.

• Examples
 IS-IS (Intermediate System-Intermediate System) link state protocol. It was
designed for an early network called DECnet, later adopted by ISO for use
with the OSI protocols.
 OSPF (Open Shortest Path First).
Hierarchical Routing
• As networks grow in size, the router routing tables grow proportionally.
• Not only is router memory consumed by ever-increasing tables, but more
CPU time is needed to scan them and more bandwidth is needed to send
status reports about them.
• At a certain point, the network may grow to the point where it is no longer
feasible for every router to have an entry for every other router, so the
routing will have to be done hierarchically, as it is in the telephone
network.

• When hierarchical routing is used, the routers are divided into regions.
Each router knows all the details about how to route packets to destinations
within its own region but knows nothing about the internal structure of
other regions.
• When different networks are interconnected, it is natural to regard each one
as a separate region to free the routers in one network from having to know
the topological structure of the other ones.

• For huge networks, a two-level hierarchy may be insufficient; it may be


necessary to group the regions into clusters, the clusters into zones, the
zones into groups, and so on, until we run out of names for aggregations.
• An example of routing in a two-level hierarchy with five regions is shown
below.
• The full routing table for router 1A has 17 entries. When routing is done
hierarchically, there are entries for all the local routers, as before, but all
other regions are condensed into a single router, and the table entries are
reduced from 17 to 7.
• As the ratio of the number of regions to the number of routers
per region grows, the savings in table space increase.
• However, these gains in space are not free. There is a penalty
to be paid: increased path length.

• When a single network becomes very large, an interesting


question is ‘‘how many levels should the hierarchy have?’’
• The optimal number of levels for an N router network is ln N,
requiring a total of e ln N entries per router.
• Also, the increase in effective mean path length caused by
hierarchical routing is sufficiently small that it is usually
acceptable.
Broadcast Routing
• In some applications, hosts need to send messages to many or
all other hosts.
• Sending a packet to all destinations simultaneously is called
broadcasting.

• One broadcasting method that requires no special features


from the network is for the source to simply send a distinct
packet to each destination.
 This method is wasteful of bandwidth, slow and it also requires the
source to have a complete list of all destinations.
 This method is not desirable in practice, even though it is widely
applicable.
• An improvement is multidestination routing, in which each packet
contains either a list of destinations or a bit map indicating the
desired destinations.
 When a packet arrives at a router, the router checks all the destinations to
determine the set of output lines that will be needed. (An output line is
needed if it is the best route to at least one of the destinations.)
 The router generates a new copy of the packet for each output line to be
used and includes in each packet only those destinations that are to use the
line. In effect, the destination set is partitioned among the output lines.
 After a sufficient number of hops, each packet will carry only one
destination like a normal packet.
 Multidestination routing is like using separately addressed packets, except
that when several packets must follow the same route, one of them pays
full fare and the rest ride free.
 The network bandwidth is therefore used more efficiently.
 This scheme still requires the source to know all the destinations, plus it is
as much work for a router to determine where to send one multidestination
packet as it is for multiple distinct packets.
• Flooding is also a better broadcast routing technique.
 When implemented with a sequence number per source, flooding uses links
efficiently with a decision rule at routers that is relatively simple.
 Although flooding is ill-suited for ordinary point-to-point communication,
it rates serious consideration for broadcasting.
 However, we can do better still once the shortest path routes for regular
packets have been computed.

• Reverse path forwarding


 When a broadcast packet arrives at a router, the router checks to see if the
packet arrived on the link that is normally used for sending packets toward
the source of the broadcast.
 If so, there is an excellent chance that the broadcast packet itself followed
the best route from the router and is therefore the first copy to arrive at the
router.
 This being the case, the router forwards copies of it onto all links except
the one it arrived on.
 If, however, the broadcast packet arrived on a link other than the preferred
one for reaching the source, the packet is discarded as a likely duplicate.
• An example of reverse path forwarding is shown below in figure.

Sink tree for Tree built by


Network router I reverse path forwarding

• On the first hop, I sends packets to F, H, J, and N, as indicated by the


second row of the tree. Each of these packets arrives on the preferred path
to I (assuming that the preferred path falls along the sink tree) and is so
indicated by a circle around the letter.
• On the second hop, eight packets are generated, two by each of the
routers that received a packet on the first hop.
• As it turns out, all eight of these arrive at previously unvisited
routers, and five of these arrive along the preferred line.
• Of the six packets generated on the third hop, only three arrive on
the preferred path (at C, E, and K); the others are duplicates.
• After five hops and 24 packets, the broadcasting terminates,
compared with four hops and 14 packets had the sink tree been
followed exactly.

• The principal advantage of reverse path forwarding is that it is


efficient while being easy to implement. It sends the broadcast
packet over each link only once in each direction, just as in flooding,
yet it requires only that routers know how to reach all destinations,
without needing to remember sequence numbers (or use other
mechanisms to stop the flood) or list all destinations in the packet.
• A new broadcast algorithm is proposed by improving the behavior of
reverse path forwarding.
• It makes explicit use of the sink tree or any other convenient spanning tree
for the router initiating the broadcast.
• If each router knows which of its lines belong to the spanning tree, it can
copy an incoming broadcast packet onto all the spanning tree lines except
the one it arrived on.
• This method makes excellent use of bandwidth, generating the absolute
minimum number of packets necessary to do the job.
• For example, in previous problem, when the sink tree is used as the
spanning tree, the broadcast packet is sent with the minimum 14 packets.
• The only problem is that each router must have knowledge of some
spanning tree for the method to be applicable.
 Sometimes this information is available (e.g., with link state routing, all routers
know the complete topology, so they can compute a spanning tree) but sometimes it
is not (e.g., with distance vector routing).

 A spanning tree is a subset of the network that includes all the routers but contains
no loops. Sink trees are spanning trees.
Multicast Routing
• Sending messages to well-defined groups that are numerically large in size
but small compared to the network as a whole is known as multicasting.
• All multicasting schemes require some way to create and destroy groups
and to identify which routers are members of a group.
• For now, we will assume that each group is identified by a multicast
address and that routers know the groups to which they belong.
• Multicast routing schemes build on the broadcast routing schemes; sending
packets along spanning trees to deliver the packets to the members of the
group while making efficient use of bandwidth.
• However, the best spanning tree to use depends on whether the group is
dense, with receivers scattered over most of the network, or sparse, with
much of the network not belonging to the group.
• If the group is dense, broadcast is a good start because it efficiently gets the
packet to all parts of the network. But broadcast will reach some routers
that are not members of the group, which is wasteful.
• The solution is to prune the broadcast spanning tree by removing links that
do not lead to members. The result is an efficient multicast spanning tree.
• Example: consider two groups, 1 and 2, in the network in given figure.
• Some routers are attached to hosts that belong to one or both of these
groups.

network A spanning tree for the leftmost router

A multicast tree for group 1 A multicast tree for group 2


• Various ways of pruning the spanning tree are possible.
 Pruning strategy with link state routing and each router is aware of the
complete topology, including which hosts belong to which groups.
• Each router can then construct its own pruned spanning tree for each sender
to the group in question by constructing a sink tree for the sender as usual
and then removing all links that do not connect group members to the sink
node.
• Example: MOSPF (Multicast OSPF)

 Pruning strategy with distance vector routing


• The basic algorithm is reverse path forwarding. However, whenever a
router with no hosts interested in a particular group and no connections to
other routers receives a multicast message for that group, it responds with a
PRUNE message, telling the neighbor that sent the message not to send it
any more multicasts from the sender for that group.
• When a router with no group members among its own hosts has received
such messages on all the lines to which it sends the multicast, it, too, can
respond with a PRUNE message. In this way, the spanning tree is
recursively pruned.
• Example: DVMRP (Distance Vector Multicast Routing Protocol)
• Pruning results in efficient spanning trees that use only the links that
are actually needed to reach members of the group.
• One potential disadvantage is that it is lots of work for routers,
especially for large networks. Suppose that a network has n groups,
each with an average of m nodes. At each router and for each group,
m pruned spanning trees must be stored, for a total of mn trees.
• For example, in previous figure, the spanning tree for the leftmost
router to send to group 1 is given. The spanning tree for the
rightmost router to send to group 1 (not shown) will look quite
different, as packets will head directly for group members rather
than via the left side of the graph.
• This in turn means that routers must forward packets destined to
group 1 in different directions depending on which node is sending
to the group.
• When many large groups with many senders exist, considerable
storage is needed to store all the trees.
• An alternative design uses core-based trees to compute a single spanning
tree for the group.
• All of the routers agree on a root (called the core or rendezvous point) and
build the tree by sending a packet from each member to the root. The tree is
the union of the paths traced by these packets.
• The figure given below shows a core-based tree for group 1. To send to this
group, a sender sends a packet to the core. When the packet reaches the
core, it is forwarded down the tree.

Core-based tree for group 1 Sending to group 1


• Having a shared tree is not optimal for all sources.
• For example, in previous figure, the packet from the sender on
the righthand side reaches the top-right group member via the
core in three hops, instead of directly.
• The inefficiency depends on where the core and senders are
located, but often it is reasonable when the core is in the
middle of the senders. When there is only a single sender, as in
a video that is streamed to a group, using the sender as the core
is optimal.

• Example: shared tree approaches like core-based trees are used


for multicasting to sparse groups in the Internet as part of
popular protocols such as PIM (Protocol Independent
Multicast)
Anycast Routing
• In anycast, a packet is delivered to the nearest member of a group.
Schemes that find these paths are called anycast routing.
• Why would we want anycast? Sometimes nodes provide a service,
such as time of day or content distribution for which it is getting the
right information all that matters, not the node that is contacted; any
node will do.
• Example: anycast is used in the Internet as part of DNS.
• Luckily, we will not have to devise new routing schemes for anycast
because regular distance vector and link state routing can produce
anycast routes.
• Suppose, we want to anycast to the members of group 1. They will
all be given the address ‘1’ instead of different addresses.
• Distance vector routing will distribute vectors as usual, and nodes
will choose the shortest path to destination 1. This will result in
nodes sending to the nearest instance of destination 1.
• The routes are shown in the figure given below.
• This procedure works because the routing protocol does not realize that
there are multiple instances of destination 1. It believes that all the
instances of node 1 are the same node.

Topology seen by
Anycast routes to group 1
routing protocol

• This procedure works for link state routing as well.


Routing for Mobile Hosts
• Millions of people use computers while on the go. The term
mobile hosts is used to represent these non-stationary hosts.
• These mobile hosts introduce a new complication: to route a
packet to a mobile host, the network first has to find it.

 In one model, all hosts are assumed to have a permanent home


location that never changes. Each hosts also has a permanent
home address that can be used to determine its home location.
 It is analogous to the telephone number, where country code and city
code is included.
 The routing goal in systems with mobile hosts is to make it possible to
send packets to mobile hosts using their fixed home addresses and have
the packets efficiently reach them wherever they may be.
 The trick, of course, is to find them.
 A different model would be to recompute routes as the mobile host
moves and the topology changes.
 We could then simply use the routing schemes described earlier.
 However, with a growing number of mobile hosts, this model would soon
lead to the entire network endlessly computing new routes.
 Using the home addresses greatly reduces this burden.

 Another alternative model provides mobility above the network


layer.
 When the devices are moved to new Internet locations, they acquire new
network addresses.
 There is no association between the old and new addresses; the network
does not know that they belonged to the same device.
 In this model, a laptop can be used to browse the Web, but other hosts
cannot send packets to it (for example, for an incoming call), without
building a higher layer location service, for example, signing into Skype
again after moving.
 Moreover, connections cannot be maintained while the host is moving; new
connections must be started up instead.
 Network-layer mobility is useful to fix these problems.
• The basic idea used for mobile routing in the Internet and cellular networks
is for the mobile host to tell a host at the home location where it is now.
• This host, which acts on behalf of the mobile host, is called the home agent.
Once it knows where the mobile host is currently located, it can forward
packets so that they are delivered.
• The figure given below shows mobile routing in action.
• A sender wants to send a packet to a host. The case of interest to us is when
the mobile host is not at home.
• The mobile host must acquire a local network address before it can use the
network. The local address is called a care of address.
• Once the mobile host has this address, it can tell its home agent where it is
now. It does this by sending a registration message to the home agent (step
1) with the care of address.
• Next, the sender sends a data packet to the mobile host using its permanent
address (step 2). This packet is routed by the network to the host’s home
location because that is where the home address belongs.
• The home agent intercepts this packet because the mobile host is away
from home. It then encapsulates the packet with a new header and sends
this bundle to the care of address (step 3). This mechanism is called
tunneling.
• When the encapsulated packet arrives at the care of address, the mobile
host unwraps it and retrieves the packet from the sender. The mobile host
then sends its reply packet directly to the sender (step 4). The overall route
is called triangle routing because it may be circuitous if the remote location
is far from the home location.
• Now, the sender may learn the current care of address. Subsequent packets
can be routed directly to the mobile host by tunneling them to the care of
address (step 5). If connectivity is lost for any reason as the mobile moves,
the home address can always be used to reach the mobile.
Routing in Ad Hoc Networks
• The previous routing strategy deals with the situation where the
hosts are mobile but the routers are fixed. An even more extreme
case is one in which the routers themselves are mobile.
• In these cases, each node communicates wirelessly and acts as both
a host and a router.
• Networks of nodes that just happen to be near each other are called
ad hoc networks or MANETs (Mobile Ad hoc NETworks).

• The ad hoc networks differ from wired networks in the sense that in
the former case, the topology is suddenly tossed out the window.
Nodes can come and go or appear in new places at the drop of a bit.
• With an ad hoc network, the topology may be changing all the time,
so the desirability and even the validity of paths can change
spontaneously without warning.
• These circumstances make routing in ad hoc networks more
challenging than routing in their fixed counterparts.
AODV (Ad hoc On-demand Distance Vector)

Route Discovery
• In AODV, routes to a destination are discovered on demand.
• At any instant, the topology of an ad hoc network can be described
by a graph of connected nodes.
• Two nodes are connected if they can communicate directly using
their radios.
• A basic but adequate model is sufficient for our purposes in which
each node can communicate with all other nodes that lie within its
coverage circle.
• Real networks are more complicated, with buildings, hills, and other
obstacles that block communication, and nodes for which A is
connected to B but B is not connected to A because A has a more
powerful transmitter than B.
• For simplicity, we will assume all connections are symmetric.
• To describe the algorithm, consider the ad hoc network given in figure.
• Suppose that a process at node A wants to send a packet to node I.
• The AODV algorithm maintains a distance vector table at each node, keyed
by destination, giving information about that destination, including the
neighbor to which to send packets to reach the destination.
• First, A looks in its table and does not find an entry for I. It now has to
discover a route to I.

* The shaded nodes are new recipients.


* The dashed lines show possible reverse routes.
* The solid lines show the discovered route.
• To locate I, A constructs a ROUTE REQUEST packet and
broadcasts it using flooding.
• The transmission from A reaches B and D. Each node rebroadcasts
the request, which continues to reach nodes F, G, and C and nodes
H, E, and I.
• A sequence number set at the source is used to weed out duplicates
during the flood.
• For example, D discards the transmission from B because it has
already forwarded the request.
• Eventually, the request reaches node I, which constructs a ROUTE
REPLY packet. This packet is unicast to the sender along the reverse
of the path followed by the request.
• For this to work, each intermediate node must remember the node
that sent it the request.
• Each intermediate node also increments a hop count as it forwards
the reply. This tells the nodes how far they are from the destination.
• The replies tell each intermediate node which neighbor to use to
reach the destination. Intermediate nodes G and D put the best route
they hear into their routing tables as they process the reply. When
the reply reaches A, a new route, ADGI, has been created.
Route Maintenance
• Because nodes can move or be switched off, the topology can
change spontaneously.
• For example, if G is switched off, A will not realize that the
route it was using to I (ADGI) is no longer valid.
• To deal with this, each node broadcasts a Hello message
periodically.
• Each of its neighbors is expected to respond to it. If no
response is forthcoming, the broadcaster knows that that
neighbor has moved out of range or failed and is no longer
connected to it.
• Similarly, if it tries to send a packet to a neighbor that does not
respond, it learns that the neighbor is no longer available.
• This information is used to purge routes that no longer work.
• For each possible destination, each node (N) keeps track of its active
neighbors that have fed it a packet for that destination during the last
ΔT seconds.
• When any of N’s neighbors becomes unreachable, it checks its
routing table to see which destinations have routes using the now-
gone neighbor.
• For each of these routes, the active neighbors are informed that their
route via N is now invalid and must be purged from their routing
tables.

• In the given example, D purges its entries for G and I from its
routing table and notifies A, which purges its entry for I.
• In the general case, the active neighbors tell their active neighbors,
and so on, recursively, until all routes depending on the now-gone
node are purged from all routing tables.
• At this stage, the invalid routes have been purged from the network,
and senders can find new, valid routes by using the discovery
mechanism that is described.
• However, there is a complication of slow convergence or count-to-
infinity problems after a topology change in which the routing
confuses old, invalid routes with new, valid routes.
• To ensure rapid convergence, routes include a sequence number that
is controlled by the destination.
 The destination sequence number is like a logical clock.
 The destination increments it every time that it sends a fresh ROUTE
REPLY.
 Senders ask for a fresh route by including in the ROUTE REQUEST the
destination sequence number of the last route they used, which will either
be the sequence number of the route that was just purged, or 0 as an initial
value.
 The request will be broadcast until a route with a higher sequence number
is found.
 Intermediate nodes store the routes that have a higher sequence number, or
the fewest hops for the current sequence number.

You might also like