Unit 3
Unit 3
()
UNIT 3
Network Layer Design Goals
Computer Networks
Machine A Machine B
Application Application
Transport Transport
Router/Gateway
Internet Internet Internet
Network Network
Network
Interface Interface
Interface
Network 1 Network 2
Computer Networks
Network Layer Design Issues
• Store-and-forward packet switching
• Services provided to transport layer
• Implementation of connectionless service
• Implementation of connection-oriented service
• Comparison of virtual-circuit and datagram networks
Computer Networks
Design issues
• Store-and-forward packet switching
• Equipment of: carrier <> customer
• Algorithm at router
• Receive packet
• Check packet (e.g. checksum)
• Forward packet
Computer Networks
Design issues: services
• Interface
• Important: = interface between carrier and customer
• Designed with following goals in mind:
• Services should be independent of the subnet technology
• Transport layer should be shielded from the number, type,
topology of the subnets
• Network addresses should use a uniform numbering plan, even
across LANs and WANs
• Connections?
• Connection-oriented <> Connectionless!
Computer Networks
Design issues: services
• Connection-oriented <> Connectionless
• PTTs: connection-oriented
• 100 years of experience with the world-wide telephone
system
• Connection time ➔ billing!
• Internet
• Subnets are inherently unreliable
• Real issue: where to put the complexity as some/many
applications require reliable transfer (~ connection-
oriented service)
• Network layer
• Transport layer
Computer Networks
Design issues: services
• Connection-oriented <> Connectionless
(cont.)
• In favour of connectionless service
• Computing power is cheap: hosts can handle the
complexity
• Subnet is a large, long lasting investment: keep it
simple
• For some applications speedy delivery (low,
constant delay) is important
• In favour of connection-oriented service
• Users want a reliable trouble-free service
• Some services are easier to provide on top of
connection-oriented service
Computer Networks
Subnet Types
1. Virtual circuits (VC) - connection setup (choosing of the route to the
destination), forwarding packets over the exactly that route (the
router maintains a table with the unique virtual circuit # ), and
connection release (termination of the VC).
Computer Networks
• Virtual Circuit Network
• Routes chosen at connection time
• Connection identified by a virtual circuit number (VCn)
• Primary service of subnet is connection-oriented
Computer Networks
• Datagram subnet
• Each packet is routed independently
• Subnet has more work to do
• More robust, easier to adapt to failures and congestion
Computer Networks
Comparison of Virtual-Circuit and Datagram Networks
Computer Networks
Function of Network Layer
• Get packets from source host to destination host
• Routing: should know about topology of subnet
• Congestion: should avoid overloading some communication
lines and routers
• Quality of service: offer the appropriate service
• Internetworking: deal with network differences, if source
and destination are connected to different networks
Computer Networks
Routing
Routing is the act of moving information across an inter-network from a source to a
destination. Along the way, at least one intermediate node typically is encountered. It’s
also referred to as the process of choosing a path over which to send the packets.
Routing is often contrasted with bridging, which might seem to accomplish precisely the
same thing to the casual observer. The primary difference between the two is that
bridging occurs at Layer 2 (the data link layer) of the OSI reference model, whereas
routing occurs at Layer 3 (the network layer). This distinction provides routing and
bridging with different information to use in the process of moving information from
source to destination, so the two functions accomplish their tasks in different ways. The
routing algorithm is the part of the network layer software responsible for deciding
which output line an incoming packet should be transmitted on, i.e. what should be the
next intermediate node for the packet.
Routing protocols use metrics to evaluate what path will be the best for a packet to
travel. A metric is a standard of measurement; such as path bandwidth, reliability, delay,
current load on that path etc; that is used by routing algorithms to determine the
optimal path to a destination. To aid the process of path determination, routing
algorithms initialize and maintain routing tables, which contain route information. Route
information varies depending on the routing algorithm used.
Computer Networks
Desirable properties of a Routing Algorithm
❑Correctness and simplicity: The packets are to be correctly
delivered. Simpler the routing algorithm, it is better.
Because static routing systems cannot react to network changes, they generally are
considered unsuitable for today's large, constantly changing networks. Most of the
dominant routing algorithms today are dynamic routing algorithms, which adjust to
changing network circumstances by analyzing incoming routing update messages. If the
message indicates that a network change has occurred, the routing software
recalculates routes and sends out new routing update messages. These messages
permeate the network, stimulating routers to rerun their algorithms and change their
routing tables accordingly. Dynamic routing algorithms can be supplemented with static
routes where appropriate.
Single-Path versus Multi-path
This division is based upon the number of paths a router stores for a single
destination. Single path algorithms are where only a single path (or rather
single next hop) is stored in the routing table. Some sophisticated routing
protocols support multiple paths to the same destination; these are known as
multi-path algorithms. Unlike single-path algorithms, these multipath
algorithms permit traffic multiplexing over multiple lines. The advantages of
multipath algorithms are obvious: They can provide substantially better
throughput and reliability. This is generally called load sharing.
In the first system, the hosts have the routing intelligence. In the latter
system, routers have the routing intelligence.
Routing Algorithm Metrics
Routing tables contain information used by switching software to
select the best route. In this section we will discuss the different nature
of information they contain, and the way they determine that one route
is preferable to others? Routing algorithms have used many different
metrics to determine the best route. Sophisticated routing algorithms
can base route selection on multiple metrics, combining them in a single
(hybrid) metric.
Destination
Routing: shortest path
❑ Algorithm of Dijkstra: shortest path in graph
o Graph
• Node = router
• Arc = communication line
o Metric
• Number of hops
• Geographic distance
• Mean queueing and transmission delay
Routing: shortest path
Initial node
Elements of algorithm:
• Mark all nodes as free:
• Mark initial node as selected: ⚫
• repeat till destination is selected:
•Label all free nodes reachable from selected nodes with shortest
distance to a selected node
•Select free node with shortest distance to a selected node and
mark it as selected
Routing: shortest path
Routing: flooding
Flooding requires no network information whatsoever. Every incoming
packet to a node is sent out on every outgoing line except the one it
arrived on. All possible routes between source and destination are tried.
A packet will always get through if a path exists. As all routes are tried, at
least one packet will pass through the shortest route. All nodes, directly
or indirectly connected, are visited. Main limitation flooding is that it
generates vast number of duplicate packets. It is necessary to use
suitable damping mechanism to overcome this limitation. One simple is
to use hop-count; a hop counter may be contained in the packet header,
which is decremented at each hop, with the packet being discarded when
the counter becomes zero. The sender initializes the hop counter. If no
estimate is known, it is set to the full diameter of the subnet. Another
approach is keep track of packets, which are responsible for flooding
using a sequence number and avoid sending them out a second time. A
variation, which is slightly more practical, is selective flooding. The
routers do not send every incoming packet out on every line, only on
those lines that go in approximately in the direction of destination.
Routing: flooding
Some of the important utilities of flooding are:
❑ Flooding is highly robust, and could be used to
send emergency messages (e.g., military
applications).
❑ It may be used to initially set up the route in a
virtual circuit.
❑ Flooding always chooses the shortest path, since
it explores every possible path in parallel.
❑ Can be useful for the dissemination of important
information to all nodes (e.g., routing
information).
Routing: flooding
Good news:
• A comes up again
Only distances to A
Loops!!
Slow!!
= 5?
Routing: Link State
Key Features:
o LAN
model
Routing: Link State (contd.)
Algorithm:
❑ Building link state packets
o Packet containing: o When to build?
• Identity of sender • periodically
Interdomain routing
Intradomain routing
Path Vector Routing
❑ is similar to distance vector routing
❑ Assuming that there is one node in each AS that acts as
on behalf of the entire AS : Speaker Node
❑ Speaker node creates a routing table and advertises it
speaker nodes in the neighboring ASs
o advertising the path, not the metric of the nodes
Path Vector Routing (cont’d)
❑ Initialization
o Each speaker node can know only the reachability of
nodes inside its AS
Path Vector Routing (cont’d)
❑ Sharing and Updating
- AS3 -
- AS3 -
Popular Routing Protocols
RIP, OSPF, BGP
❑ Dynamic protocols
o Sharing neighborhood information
❑ Use different metrics.
❑ RIP (one hop count, how many networks a packet crosses), Networks are
treated equally
❑ BGP (depend on the policy, set by administrator)
❑ OSPF (TOS, minimize delay, maximize throughput)
Popular Inter / Intra Domain Routing Protocols
RIP, OSPF, BGP
❑ RIP (Routing Information Protocol) : treating each network
equals.
o The cost of passing through each network is the same.
• so if a packet passes through 10 networks to reach the destination,
the total cost is hop counts.
❑ OSPF(Open Shortest Path First)
o allowing the administrator to assign a cost for passing through a
network based on the type of service required.
o A route through a network can have different costs (metrics)
❑ BGP (Border Router Protocol)
o Criterion is the policy, which can be set by the administrator.
o Policy defines what paths should be chosen.
❑ Static and Dynamic tables
❑ Unicast Routing and Multicast Routing
Routing Information Protocol (RIP)
❑ The Routing Information Protocol (RIP) is one of the most commonly used
Interior Gateway Protocol on internal networks which helps a router
dynamically adapt to changes of network connections by communicating
information about which networks each router can reach and how far away
those networks are. Although RIP is still actively used, it is generally
considered to have been obsolete by Link-state routing protocol such as OSPF.
❑ As RIP is a distance vector routing protocol, it represents the routing
information in terms of the cost of reaching the specific destination. Circuit
priorities are represented using numbers between 1 and 15. This scale
establishes the order of use of links. The router decides the path to use base
on the priority list. Once the priorities are established, the information is
stored in a RIP routing table. Each entry in a RIP routing table provides a
variety of information, including the ultimate destination, the next hop on the
way to that destination, and a metric. The metric indicates the distance in
number of hops to the destination. Other information can also be present in
the routing table, including various timers associated with the route; these
timers will be discussed in the next section.
Routing Information Protocol (RIP) – contd.
❑ Close loop: Protocols that allow system to enter congested state, detect
it, and remove it.
Open Loop solutions
❑ The first category of solutions or protocols attempt to solve the
problem by a good design, at first, to make sure that it doesn’t
occur at all.
❑ Once system is up and running, midcourse corrections are not
made. These solutions are somewhat static in nature, as the
policies to control congestion don’t change much according to
the current state of the system. Such Protocols are also known as
Open Loop solutions.
❑ These rules or policies include deciding upon when to accept
traffic, when to discard it, making scheduling decisions and so on.
Main point here is that they make decision without taking into
consideration the current state of the network.
❑ The open loop algorithms are further divided on the basis of
whether these acts on source versus that act upon destination.
Closed Loop solutions
❑ Closed loop solutions are based on the concept of feedback.
During operation, some system parameters are measured and
feed back to portions of the subnet that can take action to
reduce the congestion.
❑ This arrangement can be simulated in the operating system or can be built into the
hardware. Implementation of this algorithm is easy and consists of a finite queue.
Whenever a packet arrives, if there is room in the queue it is queued up and if there
is no room then the packet is discarded.
Figure a) Leaky bucket
Figure b) Leaky bucket implementation
A leaky bucket algorithm shapes bursty traffic
into fixed-rate traffic by averaging the data rate.
It may drop the packets if the bucket is full.
The congestion control in the choke packet scheme can be monitored in the following
manner –
Solution
We replace each group of 8 bits with its equivalent
decimal number and add dots for separation.
Change the following IPv4 addresses from dotted-
decimal notation to binary notation.
Solution
We replace each decimal number with its binary
equivalent.
Find the error, if any, in the following IPv4 addresses.
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
In classful addressing, the address space is
divided into five classes:
A, B, C, D, and E.
Finding the classes in binary and dotted-decimal notation
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
Every IP address also has two parts-
• The first part identifies the network (Network ID) where the system is connected
• the second part identifies the system (Host ID)
Within the address range of each IPv4 network, we have three types of
addresses:
• Network address - The address by which we refer to the network
• Broadcast address - A special address used to send data to all hosts in the
network
• Host addresses - The addresses assigned to the end devices in the network
Class A :
No of Network: 27 (The first bit of a Class A address is always 0.)
No. of Usable Host address per Network: 224-2
(Minus 2 because 2 addresses are reserved for network and broadcast
address)
Class B :
No of Network: 214 (The first two bits of the first octet of a Class B
address are always 10.)
No. of Usable Host address per Network: 216-2
Class C :
No of Network: 221 (A Class C address begins with binary 110. )
No. of Usable Host address per Network: 28-2
Class D : The Class D address class was created to enable
multicasting in an IP address. A multicast address is a unique
network address that directs packets with that destination
address to predefined groups of IP addresses. Therefore, a
single station can simultaneously transmit a single stream of
data to multiple recipients. The Class D address space, much like
the other address spaces, is mathematically constrained. The
first four bits of a Class D address must be 1110.
Class E :
A Class E address has been defined. However, the Internet
Engineering Task Force (IETF) reserves these addresses for its
own research. Therefore, no Class E addresses have been
released for use in the Internet. The first four bits of a Class E
address are always set to 1s. Therefore, the first octet range for
Class E addresses is 11110000 to 11111111, or 240 to 255.
Number of blocks (Networks) and block (Hosts ) size
in classful IPv4 addressing
The addresses in color are the default masks for classes A, B, and C.
Thus, classful addressing is a special case of classless addressing.
In IPv4 addressing, a block of
addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.
Solution
Only two are eligible (a and c).
The address 205.16.37.32 is eligible because 32 is
divisible by 16.
The address 17.17.33.80 is eligible because 80 is
divisible by 16.
Figure below shows a block of addresses, in both binary and
dotted-decimal notation, granted to a small business that needs 16
addresses.
We can see that the restrictions are applied to this block. The
addresses are contiguous. The number of addresses is a power of 2
(16 = 24), and the first address is divisible by 16.
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
Find the last address for the block in previous example
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.16.37.47
Find the number of host addresses in 205.16.37.39/28.
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
Note
N=2
H=6
Total subnets ( 2N ) :- 22 = 4
Block size (256 - subnet mask) :- 256 - 192 = 64
Valid subnets ( Count blocks from 0) :- 0,64,128,192
Total hosts (2H) :- 26 = 64
Valid hosts per subnet ( Total host - 2 ) :- 64 - 2 = 62
in this case, 12 zeroes allow for 212 = 4096 different IP addresses within
the subnet.
Of these, two (the first and the last) are unusable for a host, so you have
a maximum of 4094 hosts.
Example 2:
You work for a large communications corporation which has been assigned a
Class A network address.
Currently, the company has 1,000 subnets in offices around the world. You
want to add 100 new subnets over the next three years, and you want to allow
for the largest possible number of host addresses per subnet.
Answer: 255.255.224.0
Requirements: 1,000 subnets + 100 subnets = 1,100 subnets, and as many host
addresses as possible
2^10-2 = 1022 we Know from memory that 2^10= 1024, and will yield ONLY 1022 usable
subnets with 10 bits of subnetting
Because our requirements ask for over 1024 subnets, we must borrow one more host
bit for our subnetting:
2^11-2 = (1024 * 2) - 2 = 2046 unique usable subnets
Solution
The prefix length is 27, which means that we must
keep the first 27 bits as it is and change the
remaining bits (5) to 0s. The 5 bits affect only the
last byte. The last byte is 01010010. Changing the
last 5 bits to 0s, we get 01000000 or 64. The
network address is 167.199.170.64/27.
Example 8
An organization is granted the block 130.34.12.64/26.
The organization needs to have four subnets. What are the
subnet addresses and the range of addresses for each
subnet?
Solution
Answer: 255.255.240.0
2^3-2 = 6 subnets
2^4-2 = 14 subnets
(2^16 - 2^4) -2 = 2^12 - 2 = 4094 hosts possible per subnet
• ICMP is network diagnostic and error reporting protocol. ICMP belongs to IP protocol suite
and uses IP as carrier protocol. After constructing ICMP packet, it is encapsulated in IP
packet. Because IP itself is a best-effort non-reliable protocol, so is ICMP.
• Any feedback about network is sent back to the originating host. If some error in the
network occurs, it is reported by means of ICMP. ICMP contains dozens of diagnostic and
error reporting messages.
• ICMP-echo and ICMP-echo-reply are the most commonly used ICMP messages to check the
reachability of end-to-end hosts. When a host receives an ICMP-echo request, it is bound
to send back an ICMP-echo-reply. If there is any problem in the transit network, the ICMP
will report that problem.
Address Resolution Protocol(ARP)
If a machine talks to another machine in the same network, it requires its physical or MAC address.
But ,since the application has given the destination's IP address it requires some mechanism to bind
the IP address with its MAC address. This is done through Address Resolution protocol (ARP). IP
address of the destination node is broadcast and the destination node informs the source of its MAC
address.