Unit 3 PPT

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 131

Computer Networks

( KCS-603 )

Routing
Routin
 Routing is a process of selecting g
path along which the data can be transferred from
source to the destination. Routing is performed by a special device known as a router.

 Router is a networking device that forwards the packet based on the information
available in the packet header and forwarding table. A Router works at the network
layer in the OSI model and internet layer in TCP/IP model.

 Routing Algorithms are used for routing the packets. Routing algorithm initializes and
maintains the routing table for the process of path determination.

 Routing Algorithms use the metric to determine the best path for the packet delivery.
The metric is the standard of measurement such as hop count, bandwidth, delay,
current load on the path etc. used by the routing algorithm to determine the optimal
path to the destination.
Desirable properties of a Routing
Algorithm
 Correctness: The routing should be done properly and correctly so that the packets may reach their proper
destination.

 Simplicity: The routing should be done in a simple manner so that the overhead is as low as possible. With
increasing complexity of the routing algorithms the overhead also increases.

 Robustness: Once a major network becomes operative, it may be expected to run continuously for years
without any failures. The algorithms designed for routing should be robust enough to handle hardware and
software failures.

 Stability: The routing algorithms should be stable under all possible circumstances.

 Fairness: Every node connected to the network should get a fair chance of transmitting their packets. This is
generally done on a first come first serve basis.

 Optimality: The routing algorithms should be optimal in terms of throughput and minimizing mean packet
delays.
Design Parameters of a Routing
Algorithm
 Performance Criteria: Number of hops, Cost, Delay, Throughput, etc.

 Decision Time: Per packet basis (Datagram) or per session (Virtual-circuit) basis

 Decision Place: Each node (distributed), Central node (centralized), Originated node (source)

 Network Information Source: None, Local, Adjacent node, Nodes along route, All nodes

 Network Information Update Timing: Continuous, Periodic, Major load change, Topology
change
Classification of a Routing
Algorithm

 Static (Nonadaptive) Routing vs Dynamic (Nonadaptive)


Routing

 Single-Path vs Multi-path Routing

 Flat vs Hierarchical ( based on network topology ) Routing

 Intra-domain vs Inter-domain Routing


Static (Nonadaptive) Routing vs Dynamic (Adaptive)
This category is Routing
based on how and when the routing tables are set-up and how they can be modified, if
at
all.
 In the Static routing, the routing table is set up and modified manually whereas in the Dynamic
routing the table is built automatically with the help of the routing protocols.
 Dynamic routing is preferred over static routing because of the major issue in static routing where in
case of link/node failure the system cannot recover because of the changed network condition.

Single-path vs Multi-path Routing


This category is based upon the number of paths a router stores for a single destination.
 Single path algorithms learn routes and select a single best route to each destination. These
algorithms are incapable of load balancing traffic.

 Multi-path routing algorithms learn routes and can select more than one path to a destination. These
protocols are better for performing load balancing.
Flat vs Hierarchical
Routing
 Flat routing algorithm propagates all routing information throughout the network.

 Hierarchical routing algorithm divides large networks into smaller areas for routing.

Intradomain vs Interdomain Routing


 Intra-domain (within domain) is any routing on your own network. For that you can use RIP and
OSPF routing protocols.

 Inter-domain (between domains) is any routing protocols that you have setup between two
different networks. These are usually called Autonomous Systems (AS). The main inter-domain
protocol is BGP. Most of the time when talking about inter-domain is routing on the internet.
Autonomous
Systems

Interdomain
Intradomain routing
routing

 An autonomous system (AS) is a group of networks and routers under the authority of a single
administration.
 An internet or a bigger collection of networks can be so large, one routing protocol cannot
handle the task of updating routing tables of all routers. So, internet or a bigger collection of
networks is divided into autonomous systems.
Unicast
Routing
Most of the traffic on the network known as unicast data or unicast traffic is
sent with specified destination. Routing unicast data over the internet is called
unicast routing. It is the simplest form of routing because the destination is
already known.
Hence the router just has to look up the routing table and forward the packet
to
next hop.

There are three major algorithms for unicast routing:

 Distance Vector Routing


 Link State Routing
 Path-Vector Routing
Goal of Routing Algorithms:
( Optimality Principle & Sink Tree )
One can make a general statement about optimal routes without regard to network topology or traffic.
Optimality Principle states that 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.
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 that is illustrated in figure below, where the distance metric is the
number of hops.
Note that - a sink tree is not necessarily unique; other trees with the same path lengths may exist.
The goal of all routing algorithms is to discover and use the sink trees for all routers.
Destination

A A sink tree for router


subnet B
Static / Non
Adaptive Routing
Algorithms

 Shortest Path
Routing
 Flooding
 Flow Based Routing
Shortest Path
Routing
Algorithm of Dijkstra: shortest path in graph
 Several algorithms ( like Dijkstra Shortest Path Algorithm ) are available for computing the shortest path
between two nodes of a graph.
 In Dijkstra Shortest Path Algorithm, 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.

Graph Metric
• Node = router • Number of hops
• Edge = communication line • Geographic distance
• Mean queueing
• Transmission delay
Shortest Path Routing
(contd.)
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
Shortest Path Routing
(contd.)

A -> B -> E -> F ->H ->


Floodin

g
Simplest static routing algorithm that requires no network information.
 In flooding, 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, which is
decremented at each hop, with the packet being discarded when the counter reaches zero.
 Another technique is to keep the track of the packed that have been flooded, to avoid sending them a
second time. For this, the source router put a sequence number in each packet it receives from its
hosts.
 A variation of flooding that is slightly more practical is selective flooding. In this algorithm the routers
do not send every incoming packet out on every line, only on those lines that are going
approximately in the right direction.
Flow Based
Routing
 This is a static algorithm which uses topology and load condition
(traffic) for deciding a route.
 To use this algorithm, following information should be known in advance -
o Subnet Topology
o Traffic Matrix
o Line Capacity Matrix

For example, If there is always a huge amount of traffic from A to B in figure above, then it
may be better to route traffic from A to C via AGEFC, even though this path is much longer
than ABC.
Dynamic /
Adaptive Routing
Algorithms
Distance Vector
Routing
 Distance Vector Algorithm (based on Bellman-Ford algorithm)
is a Adaptive / Dynamic algorithm.

 Key features:
o In Distance Vector Routing Algorithm, each node shares its
routes in the network only to the neighbors and does not
broadcast it. (not to all)
o Whenever any node receives the Routing Information it updates
its own routing table and inform to its neighbors.
Distance Vector Routing
(contd.)
Algorithm
 A router transmits its distance vector to each of its neighbors in a routing packet.

 Each router receives and saves the most recently received distance vector from each of its
neighbors.

 A router recalculates its distance vector when:


 It receives a distance vector from a neighbor containing different information than before.
 It discovers that a link to a neighbor has gone down.

 The DV ( Distance Vector ) calculation is based on minimizing the cost to each destination

Note –
 From time-to-time, each node sends its own distance vector estimate to neighbors.
 When a node x receives new DV estimate from any neighbor v, it saves v’s distance vector and it updates its
own DV.
Distance Vector Routing
(contd.)
Routing Table for
AT cost via
o
A 0 -
B 12 B
C 25 B
D 40 B
E 14 E
F 23 E
G 18 B
H 17 J
I 21 E
J 9 J
K 24 J
L 29 J
Distance Vector Routing
(contd.)
Drawback of Distance Vector Algorithm
Count to Infinity Problem

The main issue with Distance Vector Routing (DVR) protocols is Routing Loops, since
Bellman-Ford Algorithm cannot prevent loops. This routing loop in Distance Vector
routing network causes Count to Infinity Problem. Routing loops usually occur when
any interface goes down or two-routers send updates at the same time.
How fast are changes propagated?
• Good news?
• Bad news?
Distance Vector Routing
(contd.) Count to Infinity Problem
How fast are changes propagated?

Good news? Bad news?

From the previous figure, it should be clear why 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.

If the metric is time delay, there is no well-defined upper bound, so a high value is needed to prevent a path with a long
delay from being treated as down. Not entirely surprisingly, this problem is known as the count-to-infinity problem.
Link State
Routing
Key Features:

 The routers share the knowledge only about their neighbors compared to all
the routers in the autonomous system.

 Sharing of information takes place only with all the routers in the network, by
sending small updates using flooding compared to sending larger updates to
their neighbors

 Sharing of information takes place only when there is a change, which leads to
lesser internet traffic compared to distance vector routing.
Link State Routing
(contd.)
Overview of algorithm:

Each router must:


1) Discover its neighbours and learn their network
addresses
2) Measure the delay or cost to each of its neighbours
3) Construct a link state packet with these distances
4) Send this packet to all other routers
5) Compute the shortest path to every other router
Link State Routing
(contd.)
1) Learning about neighbours:
o Upon boot of router
• Send HELLO packet on each point-to-point line
• Routers are supposed to send reply with a globally unique
name
o LAN model

4
Link State Routing
(contd.)
2) Measuring Line Cost
 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.

5
Link State Routing
(contd.)
3) Building link state packets
o When to build?
o Packet containing:
• periodically
• Identity of sender
• when significant events occur
• Sequence number + age
• For each neighbour: name +
distance
Link State Routing
4)
(contd.)
Distributing link state packets
o Trickiest part of algorithm
• Arrival time for packets different
• How to keep consistent routing tables
o Basic algorithm
• Flooding + Sequence number (in each packet) to limit
duplicates
o Manageable problems
• Wrap around of sequence numbers:
• Wrong sequence number used:
– lost in case of crash
– Corruption
o Refinements
• Link state packets are not forwarded immediately
• During holding time:
– duplicates are discarded
– Old packets are thrown out
Packet buffer for router B
Link State Routing o ACK flag: ACK to send
o Send flag: packet to forward
(contd.)

The packet buffer for router B


Link State Routing
(contd.)
5) Computing new routes:
o With a full set of link state packets, a router can:
• Construct the entire subnet graph
• Run Dijkstra’s algorithm to compute the shortest path to
each
destination
o Problems for large subnets
• Memory to store data
• Compute time
Path Vector
 Path Vector RoutingRouting
is similar to distance vector routing.
 Assuming that there is one node in each Autonomous System (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
(contd.)
 Initialization
o Each speaker node can only know the reachability of nodes inside
its AS
Path Vector Routing
(contd.)
 Sharing and
Updating
Popular Routing
Protocols
RIP, OSPF, BGP
 Routing Information Protocol (RIP) is an implementation of the distance vector
algorithm.
 Open Shortest Path First (OSPF) is an implementation of the link state algorithm.
 Border Gateway Protocol (BGP) is an implementation of the path vector algorithm.
Comparison b/w RIP, OSPF &
BGP
Hierarchical
Routing

 Routers grouped in regions


 Each routers knows how to reach:  Smaller tables
o Other routers in its own group
 Longer paths
o Other regions
CONGESTION CONTROL
DATA TRAFFIC

The main focus of congestion control and quality of


service is data traffic. In congestion control we try to
avoid traffic congestion. In quality of service, we try to
create an appropriate environment for the traffic. So,
before talking about congestion control and quality of
service, we discuss the data traffic itself.

Topics discussed in this section:


Traffic Descriptor
Traffic Profiles
Traffic descriptors
Three traffic profiles
CONGESTION

Congestion in a network may occur if the load on the


network—the number of packets sent to the network—
is greater than the capacity of the network—the
number of packets a network can handle. Congestion
control refers to the mechanisms and techniques to
control the congestion and keep the load below the
capacity..

Topics discussed in this section:


Network Performance
Queues in a
router
Figure Packet delay and throughput as functions of
load
CONGESTION CONTROL

Congestion control refers to techniques


and mechanisms that can either prevent congestion,
before
it happens, or remove after it has
congestion,

happened. In general, we can divide congestion control


mechanisms into two broad categories: open- loop
congestion control (prevention) and closed-loop
congestion control (removal)....

Topics discussed in this section:


Open-Loop Congestion Control
Closed-Loop Congestion Control
Congestion control
categories
Open Loop

a. Retransmission Policy

Retransmission in general may increase congestion in the network. However, a


good retransmission policy can prevent congestion. The retransmission policy and
the retransmission timers must be designed to optimize efficiency and at the same
time prevent congestion. For example, the retransmission policy used by TCP.

b. Window Policy

The type of window at the sender may also affect congestion. The Selective
Repeat window is better than the Go-Back-N window for congestion control.

c. Acknowledgment Policy
The acknowledgment policy imposed by the receiver may also affect congestion.
If the receiver does not acknowledge every packet it receives, it may slow down
the sender and help prevent congestion.
d. Discarding Policy

A good discarding policy by the routers may prevent congestion and at the same
time may not harm the integrity of the transmission. For example, in audio
transmission, if the policy is to discard less sensitive packets when congestion is
likely to happen, the quality of sound is still preserved and congestion is prevented
or alleviated.

e. Admission Policy

An admission policy, which is a quality-of-service mechanism, can also prevent


congestion in virtual-circuit networks. Switches in a flow, first check the resource
requirement of a flow before admitting it to the network. A router can deny
establishing a virtual circuit connection if there is congestion in the network or if
there is a possibility of future congestion.
Backpressure method for alleviating
congestion
Choke packet
TWO EXAMPLES

To better understand the concept of congestion control,


let us give two examples: one in TCP and the other in
Frame Relay..

Topics discussed in this section:


Congestion Control in TCP
Congestion Control in Frame Relay
Slow start, exponential
increase
Note

In the slow-start algorithm, the size


of the congestion window increases
exponentially until it reaches a
threshold.
Congestion avoidance, additive
increase
Note

In the congestion avoidance


algorithm, the size of the congestion
window increases additively until
congestion is detected.
Congestion example
BECN
FECN
Four cases of
congestion
Quality of Service (QoS)

Quality of service (QoS) is an internetworking issue that has


been discussed more than defined. We can informally define
quality of service as something a flow seeks to attain.

we discuss some techniques that can be used to improve the


quality of service.
1. Scheduling
2. Traffic Shaping
Scheduling

FIFO queue
Priority
queuing
Weighted fair queuing
Traffic Shaping

Leaky bucket
Leaky bucket implementation
Note

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.
Note

The token bucket allows bursty traffic


at a regulated maximum rate.
Token bucket
IP & SUBNET MASKING
IP ADDRESS
An IPv4 address is a 32-bit address that uniquely and universally
defines the connection of a device (for example, a computer or a
router) to the Internet.
Dotted-decimal notation and binary notation for an IPv4 address
Change the following IPv4 addresses from binary notation
to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent decimal number
and add dots for separation.
Change the following
GraphicalIPv4 addresses from
dotted- decimal notation to binary notation.
Illustration

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 and dotted-decimal
notation 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

In classful addressing, a large part of


the available addresses were
wasted.
Classful vs. Classless
Addressing
• Classful addressing, as we have seen, has too many problems
• Classless addressing, announced in 1996, allows an ISP to assign as
few or as many IP addresses as requested
• The entire 2^32 address space is divided into variable-sized blocks,
which are multiples of powers of 2
• Masking-
• Masking is finding the network address from an IP
address.
Table Default masks for classful addressing

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.
Table Prefix lengths
-

The addresses in color are the default masks for classes A, B, and
C.
Thus, classful addressing is a special case of classless addressing
The last address in the block can be
found by setting the rightmost
32 − n bits to 1s.

The number of addresses in the block


can be found by using the formula
232−n.
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.

The first address in a block is


normally not assigned to any device;
it is used as the network address that represents the organization
to the rest of the world.
How can we prove that we have 2,147,483,648 addresses in class
A? Solution
In class A, only 1 bit defines the class. The remaining 31 bits
are available for the address. With 31 bits, we can have 2^31
or 2,147,483,648 addresses.
Example Given the network address 17.0.0.0, find the class, the
block, and the range of the addresses.
Solution
The class is A because the first byte is between 0 and 127. The
block has a netid of 17. The addresses range from 17.0.0.0 to
17.255.255.255.
Example
Given the address 23.56.7.91 and the default class A mask, find
the beginning address (network address).
Solution
The default mask is 255.0.0.0, which means that only the first byte
is preserved and the other 3 bytes are set to 0s. The network
address is 23.0.0.0.
CIDR [ Classless Inter Domain Routing]
 CIDR is a slash notation of subnet mask. CIDR tells us number of
on bits in a network address.
 Class A has default subnet mask 255.0.0.0. that means first octet of
the subnet mask has all on bits. In slash notation it would be written
as /8, means address has 8 bits on.
 Class B has default subnet mask 255.255.0.0. that means first two
octets of the subnet mask have all on bits. In slash notation it would
be written as /16, means address has 16 bits on.
 Class C has default subnet mask 255.255.255.0. that means first
three octets of the subnet mask have all on bits. In slash notation it
would be written as /24, means address has 24 bits on.
Subnetting

Subnetting is a process of dividing large network into the smaller


networks based on layer 3 IP address. Every computer in network
has an IP address which represents its location in network.

Subnetting reduces the size of the routing tables stored in routers.


Subnetting extends the existing IP address base & restructures the IP
address. As a result, routers must have a way to extract from a IP
address both the Network address & the Host address.
A Network with Three Levels of
Hierarchy
Addresses with and without
Subnetting
Default mask and subnet
mask
Comparison of a default mask
and a subnet mask
Key terms to remember
 A subnet is a smaller portion of large network treated as its own separate network. To
create subnet we borrow bits from host portion and assign them as network bits. This
mean more networks, fewer hosts.
 If the network bits on two addresses do not match, then the two packets are intended for
two separate networks.
 On a 32 bits IP address at least eight bits must belong to the network portion and at least
2 bits must belong to the host portion.
 Each IP address has a predefined IP class and that cannot be changed.
 Each class has a predefined default subnet mask that tell us the octets, which
are
already part of the network portion, as well as how many bits we have available to work
with.
 Whatever network class is it, we cannot change those bits that are already assigned.
 We cannot assign the network ID and the broadcast address to a host.
 Regardless how many bits are left in the host field, network ID and the broadcast address
must be reserved.
 Subnet bits start at the left and go to the right, without skipping bits.
Method of subnetting
In subnetting we find the answer of following
questions-
 What is subnet mask for given address?
 How many subnets does given subnet mask provide ?
 What is block size for given subnet mask?
 What are the valid subnets?
 What are the total hosts?
 How many valid hosts are available per subnet?
 What is broadcast address of each subnet?
 What is network address of each subnet?
Method of subnetting
What is subnet mask for given address?
 Subnetting take places when we extend the default subnet mask. We cannot perform
subnetting with default subnet mask and every classes have default subnet mask.
 To figure out subnetted subnet mask ,we first need to write down the default subnet
mask. Now find the host bits borrowed to create subnets and convert them in decimal.
 For example find the subnet mask of address 188.25.45.48/20 ?
 This address belong to class B and class B has default subnet mask 255.255.0.0[ /16 in
CIDR ]. We borrowed 4 bits from hosts portion. As you know subnetting move from left
to right and it cannot skip any network bit. So this subnet mask in binary would be
11111111. 11111111.11110000.00000000.
 First two octet have default value so its decimal value would be 255.255. We will
convert
third octet in decimal value.
 To convert a binary number in decimal we add its decimal equivalent value. In our
example it would be 128+64+32+16+0+0+0+0 = 240.
 Our fourth octet has all bits off so its decimal value would be 0+0+0+0+0+0+0+0 =0. Our
answer subnet mask would be 255.255.240.0
Method of subnetting
 How many subnets does given subnet mask provide ?
To calculate the number of subnets provided by given subnet mask we use 2N ,
where N = number of bits borrowed from host bits to create subnets.
For example in 192.168.1.0/27, N is 3. By looking at address we can determined
that this address is belong to class C and class C has default subnet mask
255.255.255.0 [/24 in CIDR].
In given address we borrowed 27 - 24 = 3 host bits to create subnets. Now 23 = 8,
so our answer is 8.

 What is block size for subnet mask?


Block size or increment number is used to calculate the valid subnets. Once you
figure out the block size, calculation of valid subnets become piece of cake. To
figure out the block size, use this formula 256 - Subnet mask = block size.
For example block size for subnet mask 255.255.255.240 is 256 - 240 = 16.
Method of subnetting
 What are the valid subnets?
Calculating valid subnet is two steps process. First calculate total subnet by using
formula 2N. In second step find the block size and count from zero in block until you
reach the subnet mask value.
For example calculate the valid subnets for 192.168.1.0/26.
Borrowed host bits are 2 [26-24].
Total subnets are 22 = 4.
Subnet mask would be
255.255.255.192. Block size would be
256-192 = 64.
Start counting from zero at blocks of
64,
so our valid subnets would be
0,64,128,192.

 What are the total hosts?


Total hosts are the hosts available per subnet. To calculate total hosts use formula 2H =
Total hosts.
H is the number of host bits. For example in address 192.168.1.0/26 we have 32 - 26
[Total bits in IP address - Bits consumed by network address] = 6.
Method of subnetting
 How many valid hosts are available per subnet?
Valid hosts are the number of hosts those can be assigned to devices. As we
know, we need to reduce two address per subnet, one for network ID and
another for broadcast ID. So our formula, to calculate valid hosts would be Total
hosts - 2 = Valid hosts.
In above example we have 64 hosts per subnet, so valid hosts in each subnet
would be 64 - 2 = 62.

 What is the network address of each subnet?


Network address is the first address of subnet. This address is used to locate
the network, and cannot be assigned to any host. In above example address
0,64,128,192 are the network address.
Network address is always the first IP address of subnet.
Broadcast address is always the last IP address of subnet ( IP address before
the
next subnet).
Valid hosts are the IP addresses between network address and broadcast
address.
Method of subnetting
 What is broadcast address of each subnet?
Broadcast address is the last address of subnet. This address is reserve
for
network broadcast, and cannot be assigned to any host.

In the previous example-


0 Subnet has broadcast address 63
64 Subnet has broadcast address 127
128 Subnet has broadcast address 191
192 Subnet has broadcast address 255
Method of subnetting
/26
CIDR /26 has subnet mask 255.255.255.192 and 192 is 11000000
in binary. We used two host bits in network address.

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
Subnets Subnet 1 Subnet 2 Subnet 3 Subnet 4
Network ID 0 64 128 192
First host 1 65 129 193
Last host 62 126 190 254
Broadcast ID 63 127 191 255
What is the maximum number of hosts which a network
on internet having a subnet mask of 255.255.240.0 can
handle? Answer:
Convert the subnet mask to binary:
11111111.11111111.11110000.00000000

The zeroes tell you which bytes indicate the host;

in this case, 12 zeroes allow for 2^12 = 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.
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 subnet
Which possible numberyou of
mask would choose?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
Default class A subnet mask 11111111 00000000 00000000 00000000 = 255.0.0.0
SUBNET MASK REQUIRED 11111111 11111111 11100000 00000000 = 255.255.224.0
i.e. Default Class A subnet mask with ANOTHER 11 bits of subnetting
What is the subnetwork address if the
destination address is 200.45.34.56 and the
subnet mask is 255.255.240.0?

11001000 00101101 00100010 00111000


11111111 11111111 11110000 00000000
11001000 00101101 00100000 00000000

The subnetwork address is 200.45.32.0.


What is the subnetwork address if the destination address
is 19.30.84.5 and the mask is 255.255.192.0?
IP & SUBNET MASKING : NUMERICALS
NUMERICAL
S the site address 201.70.64.0
A company is granted
(class C). The company needs six subnets. Design the
subnets.
Solutio
n
The number of 1s in the default
mask is 24 (class C).
Solution
(Continued)
The company needs six subnets. This number
6 is not a power of 2. The next number that is
a power of 2 is 8 (23). We need 3 more 1s in
the subnet mask. The total number of 1s in
the subnet mask is 27 (24  3).
The total number of 0s is 5 (32  27). The
mask is
Solution
(Continued)
11111111 11111111 11111111 11100000
or
255.255.255.224
The number of subnets is 8.
The number of addresses in each subnet
is 25 (5 is the number of 0s) or 32.
Questio
A small organizationnis given a block with the beginning
address and the prefix length 205.16.37.24/29 (in slash
notation). What is the range of the block?
Solution
The beginning address is 205.16.37.24. To find the
last address we keep the first 29 bits and change the
last 3 bits to 1s.
Beginning:11001111 00010000 00100101 00011000
Ending : 11001111 00010000 00100101
00011111
There are only 8 addresses in this block.
Questio
n
What is the network address if one of the
addresses is 167.199.170.82/27?

Solution

The prefix length is 27, which means that we must keep the first 27
bits as 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.
Questio
n
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

The suffix length is 6. This means the total number


of addresses in the block is 64 (26). If we create
four subnets, each subnet will have 16 addresses.
Solution (Continued)

Let us first find the subnet prefix (subnet mask).


We need four subnets, which means we need to add
two more 1s to the site prefix. The subnet prefix
is then /28.
Subnet 1: 130.34.12.64/28 to 130.34.12.79/28.
Subnet 2 : 130.34.12.80/28 to 130.34.12.95/28.
Subnet 3: 130.34.12.96/28 to 130.34.12.111/28.
Subnet 4: 130.34.12.112/28 to 130.34.12.127/28.
Questio
n
A Corporation has been assigned the Class B network address 165.87.0.0. Company needs to divide the
network into eight subnets. What subnet mask should be applied to the network to provide the most
hosts per subnet?
a. 255.255.192.0
b. 255.255.224.0
c. 255.255.240.0
d. 255.255.248.0

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

Because 3 bits of subnetting will only yield 6 usable subnets (7 if ip subnet-zero is enabled), you will need
to borrow another bit. To meet your minimum requirement of 8 subnets, and the maximum number of
hosts per subnet, this Subnet mask will be correct: 255.255.240.0
Questio
n
If a class B network on the Internet has a subnet mask of
255.255.248.0, what is the maximum number of hosts per subnet?
Solution: The binary representation of subnet mask is
11111111.11111111.11111000.00000000. There are 21 bits set in subnet.
So 11 (32-21) bits are left for host ids.
Total possible values of host ids is 2^11 = 2048.
Out of these 2048 values, 2 addresses are reserved = 2046.
The address with all bits as 1 is reserved as broadcast address and
address with all host id bits as 0 is used as network address of subnet.
In general, the number of addresses usable for addressing specific hosts
in each network is always 2^N – 2 where N is the number of bits for
host id.
Questio
n
Consider-
• We have a big single network having IP Address 200.1.2.0. We
want to do subnetting and divide this network into 2 subnets.
Solution:
• Clearly, the given network belongs to class C.
• For creating two subnets and to represent their subnet IDs,
we require 1 bit. So,
• We borrow one bit from the Host ID part.
• After borrowing one bit, Host ID part remains with only 7
bits.
• If borrowed bit = 0, then it represents the first subnet.
• If borrowed bit = 1, then it represents the second
subnet.
• IP Address of the two subnets are-
• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.10000000 = 200.1.2.128
• For 1st Subnet-

• IP Address of the subnet = 200.1.2.0


• Total number of IP Addresses = 27 = 128
• Total number of hosts that can be configured = 128 – 2 = 126
• Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] =
[200.1.2.0, 200.1.2.127]
• Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
• Limited Broadcast Address = 255.255.255.255
• For 2nd Subnet-

• IP Address of the subnet = 200.1.2.128


• Total number of IP Addresses = 27 = 128
• Total number of hosts that can be configured = 128 – 2 = 126
• Range of IP Addresses = [200.1.2.10000000, 200.1.2.11111111] =
[200.1.2.128, 200.1.2.255]
• Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
• Limited Broadcast Address = 255.255.255.255
Questio
n
Consider-
• We have a big single network having IP Address 200.1.2.0.
•We want to do subnetting and divide this network into 4
subnets. Solution
Clearly, the given network belongs to class C.
• For creating four subnets and to represent their subnet IDs,
we require 2 bits.
So,
• We borrow two bits from the Host ID part.
• After borrowing two bits, Host ID part remains with only 6
bits.
• If borrowed bits = 00, then it represents the 1st
subnet.
• If borrowed bits = 01, then it represents the 2nd
subnet.
• If borrowed bits = 10, then it represents the 3rd
subnet.
• If borrowed bits = 11, then it represents the 4th
subnet.

• IP Address of the four subnets are-


• 200.1.2.00000000 = 200.1.2.0
• 200.1.2.01000000 = 200.1.2.64
• For 1st Subnet-

• IP Address of the subnet = 200.1.2.0


• Total number of IP Addresses = 26 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.00000000, 200.1.2.00111111] =
[200.1.2.0, 200.1.2.63]
• Direct Broadcast Address = 200.1.2.00111111 = 200.1.2.63
• Limited Broadcast Address = 255.255.255.255
• For 2nd Subnet-

• IP Address of the subnet = 200.1.2.64


• Total number of IP Addresses = 26 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.01000000, 200.1.2.01111111] =
[200.1.2.64, 200.1.2.127]
• Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
• Limited Broadcast Address = 255.255.255.255
• For 3rd Subnet-

• IP Address of the subnet = 200.1.2.128


• Total number of IP Addresses = 26 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] =
[200.1.2.128, 200.1.2.191]
• Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
• Limited Broadcast Address = 255.255.255.255
• For 4th Subnet-

• IP Address of the subnet = 200.1.2.192


• Total number of IP Addresses = 26 = 64
• Total number of hosts that can be configured = 64 – 2 = 62
• Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] =
[200.1.2.192, 200.1.2.255]
• Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
• Limited Broadcast Address = 255.255.255.255
Questio
n
• Suppose a network with IP Address 192.16.0.0. is divided into
2 subnets, find number of hosts per subnet.
Also for the first subnet, find-
• Subnet Address
• First Host ID
• Last Host ID
• Broadcast Address
Solution:
• Given IP Address belongs to class C.
• So, 24 bits are reserved for the Net ID.
• The given network is divided into 2 subnets.
• So, 1 bit is borrowed from the host ID part for the subnet IDs.
• Then, Number of bits remaining for the Host ID = 7.
• Thus, Number of hosts per subnet = 27 = 128.
For 1st Subnet-
• Subnet Address = First IP Address = 192.16.0.00000000 = 172.16.0.0
• First Host ID = 192.16.0.00000001 = 192.16.0.1
• Last Host ID = 192.16.0.01111110 = 192.16.0.126
• Broadcast Address = Last IP Address = 192.16.0.01111111 =
172.16.0.127
Questio
n
• What is not true about subnetting?
• It is applied for a single network
• It is used to improve security
• Bits are borrowed from network
portion
• Bits are borrowed from Host portion

Clearly, Option (C) is correct.

You might also like