CN Notes
CN Notes
Network layer is majorly focused on getting packets from the source to the destination, routing error handling
and congestion control.
Before learning about design issues in the network layer, let’s learn about it’s various functions.
Addressing:
Maintains the address at the frame header of both source and destination and performs addressing to
detect various devices in network.
Packeting:
This is performed by Internet Protocol. The network layer converts the packets from its upper layer.
Routing:
It is the most important functionality. The network layer chooses the most relevant and best path for the
data transmission from source to destination.
Inter-networking:
It works to deliver a logical connection across multiple devices
The main function of the network layer is routing packets from the source machine to the destination machine. In
most subnets, packets will require multiple hops to make the journey.
The algorithms that choose the routes and the data structures that they use are a major area of network layer
design.
The routing algorithm is that part of the network layer software responsible for deciding which output line an
incoming packet should be transmitted on.
If the subnet 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 subnet uses virtual circuits internally, routing decisions are made only when a new virtual circuit is being set
up.
Thereafter, data packets just follow the previously-established route.
The latter case is sometimes called session routing because a route remains in force for an entire user session
(e.g., a login session at a terminal or a file transfer).
It is sometimes useful to make a distinction between routing, which is making the decision which routes to use, and
forwarding, which is what happens when a packet arrives.
One can think of a router as having two processes inside it.
One of them handles each packet as it arrives, looking up the outgoing line to use for it in the routing tables.
This process is forwarding.
The other process is responsible for filling in and updating the routing tables.
That is where the routing algorithm comes into play.
Regardless of whether routes are chosen independently for each packet or only when new connections are
established, certain properties are desirable in a routing algorithm: correctness, simplicity, robustness,
stability, fairness, and optimality.
Stability is also an important goal for the routing algorithm.
There exist routing algorithms that never converge to equilibrium, no matter how long they run.
A stable algorithm reaches equilibrium and stays there.
Fairness and optimality may sound obvious-surely no reasonable person would oppose them-but as it turns out,
they are often contradictory goals.
Suppose that there is enough traffic between A and A', between B and B', and between C and C' to saturate the
horizontal links.
To maximize the total flow, the X to X' traffic should be shut off altogether. Unfortunately, X and X' may not see it
that way.
Evidently, some compromise between global efficiency and fairness to individual connections is needed.
To see this, call the part of the route from I to J r1 and the rest of the route r2. If a route better than r2 existed from J to
K, it could be concatenated with r1 to improve the route from I to K, contradicting our statement that r 1r2 is optimal.
As a direct consequence of the optimality principle, we can see that 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 and is illustrated in Fig. , where the distance metric is the number of hops.
(a) A
subnet. (b) A sink tree for router B.
Since a sink tree is indeed a tree, it does not contain any loops, so each packet will be delivered within a finite and
bounded number of hops. In practice, life is not quite this easy.
Links and routers can go down and come back up during operation, so different routers may have different ideas
about the current topology.
Shortest Path Routing
The idea is to build a graph of the subnet, with each node of the graph representing a router and each arc of the
graph representing a communication line (often called a 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 Fig are
equally long. Another metric is the geographic distance in kilometers, in which case ABC is clearly much longer than
ABE (assuming the figure is drawn to scale).
Several algorithms for computing the shortest path between two nodes of a graph are known. This one is due to
Dijkstra (1959). (Dijkstra's algorithm is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for
example, road networks.) Each node is labeled (in parentheses) 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.
To illustrate how the labeling algorithm works, look at the weighted, undirected graph of Fig.(a), where the weights
represent, for example, distance. We want to find the shortest path from A to D. Mark node A as permanent, indicated
by a filled-in circle. Then examine, in turn, each of the nodes adjacent to A (the working node), relabeling each one
with the distance to A. Whenever a node is relabeled, label it with the node from which the probe was made so that
one can reconstruct the final path later. Having examined each of the nodes adjacent to A, examine all the tentatively
labeled nodes in the whole graph and make the one with the smallest label permanent, as shown in Fig.(b). This
becomes the new working node.
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, is is the shorter path, so the node is relabeled.
After all the nodes adjacent to the working node have been inspected and the tentative labels changed if possible, the
entire graph is searched for the tentatively-labeled node with the smallest value. This node is made permanent and
becomes the working node for the next round. Fig. shows the first five steps of the algorithm.
To see why the algorithm works, consider Fig.(c). At that point E is made permanent. Suppose that there were a
shorter path than ABE, say AXYZE. There are two possibilities: either node Z has already been made permanent, or
it has not been. If it has, then E has already been probed (on the round following the one when Z was made
permanent), so the AXYZE path has not escaped our attention and thus cannot be a shorter path.
Now consider the case where Z is still tentatively labeled. Either the label at Z is greater than or equal to that at E, in
which case AXYZE cannot be a shorter path than ABE, or it is less than that of E, in which case Z and not E will
become permanent first, allowing E to be probed from Z.
Fig. The first five steps used in computing the shortest path from A to D. The arrows indicate the working
node.
Distance vector routing algorithms operate by having each router maintain a table (i.e., a vector) giving the best
known distance to each destination and which line to use to get there.
These tables are updated by exchanging information with the neighbors.
In distance vector routing, each router maintains a routing table indexed by, and containing one entry for, each
router in the subnet.
This entry contains two parts: the preferred outgoing line to use for that destination and an estimate of the time or
distance to that destination.
The metric used might be number of hops, time delay in milliseconds, total number of packets queued along the
path, or something similar.
The router is assumed to know the ''distance'' to each of its neighbors.
If the metric is hops, the distance is just one hop.
If the metric is queue length, the router simply examines each queue.
If the metric is delay, the router can measure it directly with special ECHO packets that the receiver just
timestamps and sends back as fast as it can.
Illustration of an example:
As an example, 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 line in its new routing table.
Note that the old routing table is not used in the calculation.
This updating process is illustrated in Fig. 3.4. Part (a) shows a subnet.
The first four columns of part (b) 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.
Figure (a) A subnet. (b) Input from A, I, H, K, and the new routing table for J.
Consider how J computes its new route to router G. It knows that it can get to A in 8 msec, and 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.
Link State Routing
General Description: The idea behind link state routing is simple and can be stated as five parts. Each router must
do the following:
In effect, the complete topology and all delays are experimentally measured and distributed to every router.Then
Dijkstra's algorithm can be run to find the shortest path to every other router. Below we will consider each of these
five steps in more detail.
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 telling who it is.
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 LAN, the situation is slightly more complicated. Fig. 3.5(a) illustrates
a LAN to which three routers, A, C, and F, are directly connected.
Each of these routers is connected to one or more additional routers, as shown.
Figure (a) Nine routers and a LAN. (b) A graph model of (a).
The link state routing algorithm requires each router to know, or at least have a reasonable estimate of, the delay
to each of its neighbors.
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.
For even better results, the test can be conducted several times, and the average used.
Of course, this method implicitly assumes the delays are symmetric, which may not always be the case.
An interesting issue is whether to take the load into account when measuring the delay.
To factor the load in, the round-trip timer must be started when the ECHO packet is queued.
To ignore the load, the timer should be started when the ECHO packet reaches the front of the queue.
Arguments can be made both ways.
Including traffic-induced delays in the measurements means that when a router has a choice between two lines
with the same bandwidth, one of which is heavily loaded all the time and one of which is not, the router will regard
the route over the unloaded line as a shorter path.
This choice will result in better performance.
Unfortunately, there is also an argument against including the load in the delay calculation.
Consider the subnet of Fig. 3.6, which is divided into two parts, East and West, connected by two lines, CF and EI.
Figure : A subnet in which the East and West parts are connected by two lines.
Suppose that most of the traffic between East and West is using line CF, and as a result, this line is heavily loaded
with long delays. Including queuing delay in the shortest path calculation will make EI more attractive.
After the new routing tables have been installed, most of the East-West traffic will now go over EI, overloading this
line. Consequently, in the next update, CF will appear to be the shortest path. As a result, the routing tables may
oscillate wildly, leading to erratic routing and many potential problems.
If load is ignored and only bandwidth is considered, this problem does not occur.
Alternatively, the load can be spread over both lines, but this solution does not fully utilize the best path.
Nevertheless, to avoid oscillations in the choice of best path, it may be wise to distribute the load over multiple
lines, with some known fraction going over each line.
Too many packets present in (a part of) the network causes packet delay and loss that
degrades performance. This situation is called congestion.
general principle
Presence of too many packets leads to degrade in the performance. The following section explains the Congestion
and the algorithms to control it.
Congestion:
When too many packets are present in (a part of) the subnet, performance degrades.
a. If all of a sudden, streams of packets begin arriving on three or four input lines and all need the same output
line, a queue will build up.
The presence of congestion means that the load is (temporarily) greater than the resources (in a
part of the network) can handle. Two solutions come to mind: increase the resources or
decrease the load. As shown in Fig., these solutions are usually applied on different time scales
to either prevent congestion or react to it once it has occurred.
The most basic way to avoid congestion is to build a network that is well matched to the traffic
that it carries. If there is a low-bandwidth link on the path along which most traffic is directed,
congestion is likely. Sometimes resources can be added dynamically when there is serious
congestion, for example, turning on spare routers or enabling lines that are normally used only
as backups (to make the system fault tolerant) or purchasing bandwidth on the open market.
More often, links and routers that are regularly heavily utilized are upgraded at the earliest
opportunity. This is called provisioning and happens on a time scale of months, driven by long-
term traffic trends.
To make the most of the existing network capacity, routes can be tailored to traffic patterns that
change during the day as network users wake and sleep in different time zones. For example,
routes may be changed to shift traffic away from heavily used paths by changing the shortest
path weights. Some local radio stations have helicopters flying around their cities to report on
road congestion to make it possible for their mobile listeners to route their packets (cars) around
hotspots. This is called traffic-aware routing. Splitting traffic across multiple paths is also
helpful.
However, sometimes it is not possible to increase capacity. The only way then to beat back the
congestion is to decrease the load. In a virtual-circuit network, new connections can be refused
if they would cause the network to become congested. This is called admission control. At a
finer granularity, when congestion is imminent the network can deliver feedback to the sources
whose traffic flows are responsible for the problem. The network can request these sources to
throttle their traffic, or it can slow down the traffic itself.
An added concern is having routers send more messages when the network is already
congested. Finally, when all else fails, the network is forced to discard packets that it cannot
deliver. The general name for this is load shedding. A good policy for choosing which packets
to discard can help to prevent congestion collapse.
Admission Control
One technique that is widely used in virtual-circuit networks to keep congestion at bay is
admission control.
Traffic is often described in terms of its rate and shape. The problem of how to describe it in a
simple yet meaningful way is difficult because traffic is typically bursty—the average rate is only
half the story. For example, traffic that varies while browsing the Web is more difficult to handle
than a streaming movie with the same long-term throughput because the bursts of Web traffic
are more likely to congest routers in the network. A commonly used descriptor that captures this
effect is the leaky bucket or token bucket. A leaky bucket has two parameters that bound the
average rate and the instantaneous burst size of traffic. Since leaky buckets are widely used for
quality of service.
The Internet can be viewed as a collection of sub networks or Autonomous Systems (ASes) that are interconnected
at the Network layer.
Quasi-hierarchical organization:
The glue that holds the whole Internet together is the network layer protocol, IP (Internet Protocol).
Unlike older network layer protocols, it was designed from the beginning with internetworking in mind.
A good way to think of the network layer is this.
IP Protocol
IP datagram:
An IP datagram consists of a header part and a text part. The header has a 20-byte fixed part and a
variable length optional part.
The header format is shown in Fig.
It is transmitted in big-endian order: from left to right, with the high-order bit of the Version field going first.
(The SPARC is big endian; the Pentium is little-endian.
Figure: the IPv4 (Internet Protocol) header.
Version:
The Version field keeps track of which version of the protocol the datagram belongs to.
By including the version in each datagram, it becomes possible to have the transition between versions take years,
with some machines running the old version and others running the new one.
Currently a transition between IPv4 and IPv6 is going on.
IHL:
Since the header length is not constant, a field in the header, IHL, is provided to tell how long the header is, in 32-
bit words.
The minimum value is 5, which applies when no options are present.
The maximum value of this 4-bit field is 15, which limits the header to 60 bytes, and thus the Options field to 40
bytes.
For some options, such as one that records the route a packet has taken, 40 bytes is far too small, making that
option useless.
Type of Service:
The Type of service field is one of the few fields that have changed its meaning (slightly) over the years.
Originally, the 6-bit field contained (from left to right), a three-bit Precedence field and three flags, D, T, and R.
The Precedence field was a priority, from 0 (normal) to 7 (network control packet).
The three flag bits allowed the host to specify what it cared most about from the set {Delay, Throughput,
Reliability}.
In theory, these fields allow routers to make choices between, for example, a satellite link with high throughput and
high delay or a leased line with low throughput and low delay.
In practice, current routers often ignore the Type of service field altogether.
Six of the bits are used to indicate which of the service classes discussed earlier each packet belongs to.
These classes include the four queuing priorities, three discard probabilities, and the historical classes.
Total Length:
The Total length includes everything in the datagram-both header and data.
The maximum length is 65,535 bytes.
Identification:
The Identification field is needed to allow the destination host to determine which datagram a newly arrived
fragment belongs to.
All the fragments of a datagram contain the same Identification value.
DF:
A packet is a small amount of data sent over a network, such as a LAN or the Internet.
hop: A hop is a computer networking term that refers to the number of routers that a packet (a portion
of data) passes through from its source to its destination. ... An actual hop is an action that occurs
when a packet jumps from one router to the next
Network topology refers to the manner in which the links and nodes of a network are arranged to
relate to each other. ... Physical network topology examples include star, mesh, tree, ring, point-to-point,
circular, hybrid, and bus topology networks, each consisting of different configurations of nodes and
links.
A checksum is a value that represents the number of bits in a transmission message and is used by IT
professionals to detect high-level errors within data transmissions. Prior to transmission, every piece of
data or file can be assigned a checksum value after running a cryptographic hash function.
what is router ?
A router is a switching device for networks, which is able to route network packets, based on their
addresses, to other networks or devices. Among other things, they are used for Internet access, for
coupling networks or for connecting branch offices to a central office via VPN (Virtual Private Network).
What is checksum ?
A checksum is a value that represents the number of bits in a transmission message and is used by IT
professionals to detect high-level errors within data transmissions. Prior to transmission, every piece of
data or file can be assigned a checksum value after running a cryptographic hash function.
What is in a packet?
Packets consist of two portions: the header and the payload. The header contains information about the
packet, such as its origin and destination IP addresses (an IP address is like a computer's mailing address).
The payload is the actual data.
What is optimal?
Sink trees of a given node in a computer network is a tree formed by connecting the node with all the other
nodes of in the network with the optimal path, or more precisely the shortest path.
What is bandwidth ?
a range of frequencies within a given band, in particular that used for transmitting a signal.