Network Layer
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
• 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.
• 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.
• 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.
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.
• 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.
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.
Topology seen by
Anycast routes to group 1
routing protocol
• 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.
• 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.