Unit 3
Unit 3
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.
2 Services provided to 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. Services independent of router technology.
2. Transport layer shielded from number, type, topology of routers.
3. Network addresses available to transport layer use uniform numbering plan
– even across LANs and WANs
3 Implementation of connectionless service
If connectionless service is offered, 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.
A’s table (initially) A’s table (later) C’s Table E’s Table
Let us assume for this example that the message is four times 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.
Every router has an internal table telling it where to send packets for each of the possible
destinations. Each table entry is a pair(destination and the outgoing line). Only directly
connected lines can be used.
A’s initial routing table is shown in the figure under the label ‘‘initially.’’
At A, packets 1, 2, and 3 are stored briefly, having arrived on the incoming link. Then each
packet is forwarded according to A’s table, onto the outgoing link to C within a new frame.
Packet 1 is then forwarded to E and then to F.
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 (traffic jam along ACE path), A decided to
send packet 4 via a different route than that of the first three packets. Router A updated its
routing table, as shown under the label ‘‘later.’’
The algorithm that manages the tables and makes the routing decisions is called the routing
algorithm.
4 Implementation of connection-oriented service
If connection-oriented service is used, 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), and the network is called a virtual-circuit network
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.
As an example, consider the situation shown in Figure. Here, 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 let us consider what happens if H3 also wants to establish a connection to H2. It chooses
connection identifier 1 (because it is initiating the connection and this is its only connection)
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. Avoiding conflicts of this kind is why routers need the ability to
replace connection identifiers in outgoing packets.
In some contexts, this process is called label switching. An example of a connection-oriented
network service is MPLS (Multi Protocol Label Switching).
Routing Algorithms
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.
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, optimality
Routing algorithms can be grouped into two major classes:
1) nonadaptive (Static Routing)
2) adaptive. (Dynamic 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.
Adaptive algorithms differ in
1) Where they get their information (e.g., locally, from adjacent routers, or from all routers),
2) When they change the routes (e.g., every ∆T sec, when the load changes or when the
topology changes), and
3) What metric is used for optimization (e.g., distance, number of hops, or estimated transit
time).
This procedure is called dynamic routing
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. If the receiving node uses information from any row. The sending node is the next node in
the route.
3. 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 3.
Suppose that now there is no path between C and X; node C now advertises this route with a
distance of infinity. Node A must not ignore this value even though its old entry is smaller. The
old route does not exist anymore. The new route has a distance of infinity.
Final Diagram
When to Share
The question now is, When does a node send its partial routing table (only two columns) to all
its immediate neighbors? 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
Three-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."
I. Creation of Link State Packet (LSP) A link state packet can carry a large amount of
information. For the moment, we assume that it carries a minimum amount of data: the node
identity, the list of links, a sequence number, and age. The first two, node identity and the
list of links, are needed to make the topology. The third, sequence number, facilitates
flooding and distinguishes new LSPs from old ones. The fourth, age, prevents old LSPs from
remaining in the domain for a long time.
LSPs are generated on two occasions:
1. When there is a change in the topology of the domain
2. on a periodic basis: The period in this case is much longer compared to distance vector.
The timer set for periodic dissemination is normally in the range of 60 min or 2 h based on
the implementation. A longer period ensures that flooding does not create too much traffic
on the network.
II. Flooding of LSPs: After a node has prepared an LSP, it must be disseminated to all
other nodes, not only to its neighbors. The process is called flooding and based on the
following
1. The creating node sends a copy of the LSP out of each interface
2. A node that receives an LSP compares it with the copy it may already have. If the
newly arrived LSP is older than the one it has (found by checking the sequence number),
it discards the LSP. If it is newer, the node does the following:
a. It discards the old LSP and keeps the new one.
b. It sends a copy of it out of each interface except the one from which the packet
arrived. This guarantees that flooding stops somewhere in the domain (where a node has
only one interface).
III. Formation of Shortest Path Tree: Dijkstra Algorithm
A shortest path tree is a tree in which the path between the root and every other node is the
shortest.
The Dijkstra algorithm creates a shortest path tree from a graph. The algorithm divides the
nodes into two sets: tentative and permanent. It finds the neighbors of a current node, makes
them tentative, examines them, and if they pass the criteria, makes them permanent.
IV. Calculation of a routing table
routing table for node A
Path vector routing proved to be useful for inter domain routing. The principle of path vector
routing is similar to that of distance vector routing. In path vector routing, we assume that
there is one node (there can be more, but one is enough for our conceptual discussion) in each
AS that acts on behalf of the entire AS. Let us call it the speaker node. The speaker node in an
AS creates a routing table and advertises it to speaker nodes in the neighboring ASs. The idea is
the same as for distance vector routing except that only speaker nodes in each AS can
communicate with each other. However, what is advertised is different. A speaker node
advertises the path, not the metric of the nodes, in its autonomous system or other autonomous
systems
Initialization
Initial routing tables in path vector routing
Sharing
Just as in distance vector routing, in path vector routing, a speaker in an autonomous system shares
its table with immediate neighbors. In Figure, node A1 shares its table with nodes B1
and C1. Node C1 shares its table with nodes D1, B1, and A1. Node B1 shares its table with C1
and A1. Node D1 shares its table with C1.
Updating When a speaker node receives a two-column table from a neighbor, it updates its own
table by adding the nodes that are not in its routing table and adding its own autonomous system
and the autonomous system that sent the table. After a while each speaker has a table and knows
how to reach each node in other Ass
a) Loop prevention. The instability of distance vector routing and the creation of loops can be
avoided in path vector routing. When a router receives a message, it checks to see if its AS is
in the path list to the destination. If it is, looping is involved and the message is ignored.
b) Policy routing. Policy routing can be easily implemented through path vector routing.
When a router receives a message, it can check the path. If one of the AS listed in the path is
against its policy, it can ignore that path and that destination. It does not update its routing
table with this path, and it does not send this message to its neighbors.
c) Optimum path. What is the optimum path in path vector routing? We are looking for a path
to a destination that is the best for the organization that runs the AS. One system may use
RIP, which defines hop count as the metric; another may use OSPF with minimum delay
defined as the metric. In our previous figure, each AS may have more than one path to a
destination. For example, a path from AS4 to ASI can be AS4-AS3-AS2-AS1, or it can be
AS4- AS3-ASI. For the tables, we chose the one that had the smaller number of ASs, but
this is not always the case. Other criteria, such as security, safety, and reliability, can also be
applied
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 what we will call 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.
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
When a single network becomes very large, an interesting question is ‘‘how many levels
should the hierarchy have?’’
For example, consider a network with 720 routers. If there is no hierarchy, each router needs 720
routing table entries.
If the network is partitioned into 24 regions of 30 routers each, each router needs 30 local entries
plus 23 remote entries for a total of 53 entries.
If a three-level hierarchy is chosen, with 8 clusters each containing 9 regions of 10 routers, each
router needs 10 entries for local routers, 8 entries for routing to other regions within its own
cluster, and 7 entries for distant clusters, for a total of 25 entries
Kamoun and Kleinrock (1979) discovered that the optimal number of levels for an N router
network is ln N, requiring a total of e ln N entries per router
When too much traffic is offered, congestion sets in and performance degrades sharply
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.
Traffic Shaping
1. Another method of congestion control is to “shape” the traffic before it enters the
network.
2. Traffic shaping controls the rate at which packets are sent (not just how many). Used in
ATM and Integrated Services networks.
3. At connection set-up time, the sender and carrier negotiate a traffic pattern (shape).
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:
The glue that holds the Internet together is the network layer protocol, IP
(Internet Protocol). Unlike most 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. Its job is to provide a best - efforts way to transport
datagrams from source to destination, without regard to whether or not these
machines are on the same network, or whether or not there are other networks in
between them.
Communication in the Internet works as follows. The transport layer takes data
streams and breaks them up into datagrams. In theory, datagrams can be up to
64 Kbytes each, but in practice they are usually around 1500 bytes. Each
datagram is transmitted through the Internet, possibly being fragmented into
smaller units as it goes. When all the pieces finally get to the destination
machine, they are reassembled by the network layer into the original datagram.
This datagram is then handed to the transport layer, which inserts it into the
receiving process input stream
The IP Protocol:
An appropriate place to start our study of the network layer in the Internet is the
format of the IP datagrams themselves. 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 figure below. 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.) On little
endian machines, software conversion is required on both transmission and
reception.
he 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 months, or even years, with some
machines running the old version and others running the new one.
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 the option useless.
The Type of service field allows the host to tell the subnet what kind of service
it wants. Various combinations of reliability and speed are possible. For
digitized voice, fast delivery beats accurate delivery. For file transfer, error-free
transmission is more important than fast transmission.
The field itself contains (from left to right), a three-bit Precedence field, three
flags, D, T, and R, and 2 unused bits. The Precedence field is a priority, from 0
(normal) to 7 (network control packet). The three flag bits allow the host to
specify what it cares 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 ignore the Type of
Service field altogether.
IP Addresses:
Every host and router on the Internet has an IP address, which encodes its
network number and host number. The combination is unique: no two machines
have the same IP address. All IP addresses are 32 bits long and are used in the
Source address and Destination address fields of IP packets. The formats used
for IP address are shown in figure below. Those machines connected to multiple
networks have a different IP address on each network.
The class A, B, C, and D formats allow for up to 126 networks with 16 million
hosts each, 16,382 networks with up to 64K hosts, 2 million networks, (e.g.
LANs), with up to 254 hosts each, and multicast, in which a datagram is
directed to multiple hosts. Addresses beginning with 11110 are reserved for
future use. Tens of thousands of networks are now connected to the Internet,
and the number doubles every year. Network numbers are assigned by the NIC
(Network Information Centre) to avoid conflicts.
Network addresses, which are 32-bit numbers, are usually written in dotted
decimal notation. In this format, each of the 4 bytes is written in decimal, from
0 to 255. For example, 192.41.6.20. The lowest IP address is 0.0.0.0 and the
highest is 255.255.255.255.
SUBNETS:
As we already understand, all the hosts in a network must have the same
network number. This property of IP addressing can cause problems as
networks grow, For example, consider a company that starts out with one class
C LAN on the Internet. As time goes on, it might acquire more than 254
machines, and thus need a second class C address. Alternatively, it might
acquire a second LAN of a different type and want a separate IP address for it
(the LANs could be bridged to form a single IP network, but bridges have their
own problems). Eventually, it might end up with many LANs, each with its own
router and each with its own class C network number.
As the number of distinct local networks grows, managing them can become a
serious headache. Every time a new network is installed the system
administrator has to contact NIC to get a new network number. Then this
number must be announced worldwide. Furthermore, moving a machine from
one LAN to another requires it to change its IP address, which in turn may mean
modifying its configuration files and also announcing the new IP address to the
world. If some other machine is given the newly - released IP address, that
machine will get email and other data intended for the original machine.