CN UNIT 2
CN UNIT 2
CN UNIT 2
2. Routing
• Routing is the process of identifying the best path to transmit the packets,
Network Layer not only just sends packets from sender to receiver, but also
determines the best route to send them. Numerous routers are used to
find out the best and safest route to transmit the data packets.
3. Host-to-Host delivery
4. Logical Subnetting
• Network Layer also allows a bigger network to be divided into smaller chunks
of network known as Logical Subnetting. It helps the IP addresses to be used
more efficiently and less amount of IP address will be wasted.
• It is also helpful to manage a larger network more efficiently. Due to smaller
networks, it would be easier to find the device if any troubleshooting is
needed.
5. Fragmentation and Reassembly
• Each device / node has a maximum capacity to receive data (it may differ from Node to
Node), which is called Maximum Transmission Unit (MTU).
• If the total size of data packets exceeds that size limit, then those data packets are
fragmented into more smaller packets / fragmented so that they can fit the MTU.
• After fragmentation those packets are being send to the receiver, and at the receiving
end all those fragmented packets are rearranged to create the actual data in order. The
fragmentation is taken care by the routers.
6. Error Handling
• Network Layer also check for errors and handles them. Network Layer uses various
error detection techniques like Cylic Redundancy Check (CRC) , Checksums etc.
• It also re-transmit the packets which are either erroneous or didn’t reach the receiver. It
uses the ACK messages to determine whether a packet has been successfully reached
the receiver or not, if there is a Negative ACK, then it means that there is some error
with the packet, and the receiver will ask the sender to resend that packet.
7. Network Address Translation (NAT)
Network Layer also takes care of the Network Address Translation (NAT), means
that it converts any private IP address into a public IP address which is required
to communicate between the sender and the receiver.
8. Congestion Control
• Just like MTU, if there is an excessive load on the network which it can’t
handle, the network become congested.
• Due to which the entire process of sending and receiving data comes to a
pause.
• Congestion can be dealt with using different algorithms like Leaky Bucket
Algorithm and Token Bucket Algorithm.
NetworkAddressing/Logical
Addressing/IP Addressing
Hexadecimal Notation
IPv4 Datagram Header
Initially in 1980’s IP address was divided into two fixed part i.e., NID(Network ID) =
8bit, and HID(Host ID) = 24bit.
So there are 28 that is 256 total network are created and 224 that is 16M Host per
network.
There are one 256 Networks and even a small organization must buy 16M
computer(Host) to purchase one network. That’s why we need classful addressing.
No. of Networks are very less and No. of IP addresses are very large.
Note:
•IP addresses are globally managed by Internet Assigned Numbers Authority(IANA)
and Regional Internet Registries(RIR).
•While finding the total number of host IP addresses, 2 IP addresses are not counted
and are therefore, decreased from the total count because the first IP address of any
network is the network number and whereas the last IP address is reserved for
broadcast IP.
Classful Addressing:
Classful IP addressing is a way of organizing
and managing IP addresses, which are used
to identify devices on a network
Class E
In Class E, an IP address is used for the future use or for the research and
development purposes. It does not possess any subnetting. The higher
order bits of the first octet is always set to 1111, and the remaining bits
determines the host ID in any network.
Classful Network Architecture
Rules for assigning Host ID:
The Host ID is used to determine the host within any network. The Host ID is assigned
based on the following rules:
If the hosts are located within the same local network, then they are assigned with the
same network ID. The following are the rules for assigning Network ID:
Problem-01:
Identify the Class, Network IP Address, Direct •IP Address belongs to class A
broadcast address and Limited broadcast address of •Network IP Address = 1.0.0.0
each IP Address. •Direct Broadcast Address = 1.255.255.255
•Limited Broadcast Address =
255.255.255.255
Problem-02:
Suppose that instead of using 16 bits for network part of a class B Address, 20
bits have been used. How many class B networks would have been possible?
Solution-
Solution-
Uses of Subnetting
Note: The process of borrowing bit from HID to generate SID is also called
Subnetting.
How Does Subnetting Work?
The working of subnets starts in such a way that firstly it divides the subnets into
smaller subnets. For communicating between subnets, routers are used. Each
subnet allows its linked devices to communicate with each other. Subnetting for a
network should be done in such a way that it does not affect the network bits.
Finally, after using the subnetting the total number of usable hosts is
reduced from 254 to 252.
Note:
1.To divide a network into four (22) parts you need to choose two bits from
the host id part for each subnet i.e, (00, 01, 10, 11).
2.To divide a network into eight (23) parts you need to choose three bits
from the host id part for each subnet i.e, (000, 001, 010, 011, 100, 101, 110,
111) and so on.
3.We can say that if the total number of subnets in a network increases the
total number of usable hosts decreases.
Advantages of Subnetting Disadvantages of Subnetting
• Subnetting improves Point-01:
security because the Subnetting leads to the loss of IP Addresses. Two
administration and IP Addresses are always wasted for every sub-
maintenance of sub- network (subnet).In subnetting, One IP Address is
networks is easy. wasted for its network address and another for its
• In simple words, the direct broadcasting address.
management and Point-02:
maintenance of the Subnetting leads to a more complicated
entire university is tough communication process than communication
as compared to its without subnetting.
different departments. After subnetting, the communication is done
• To reduce wastage of IP through the following 4 steps
addresses. •First, Identifying the network
•Second, Identifying the sub-network
•Third, Identifying the host
•And in the last, Identifying the process
A subnet mask is a 32-bit number which is used to identify the subnet of an IP
address. The subnet mask is combination of 1’s and 0’s. 1’s represents network and
subnet ID while 0’s represents the host ID. For this case, subnet mask is,
Routing table
If the network id doesn’t matches with any then the packet will be sent to default
entry.
Default entry has network id as 0.0.0.0.
Supernetting in Network Layer
More specifically,
•When multiple networks are combined to form a bigger network, it is termed
super-netting
•Super netting is used in route aggregation to reduce the size of routing
tables and routing table updates
Supernet Mask is a 32-bit number where all the fixed bits of the network are
represented by 1 and the variable part is represented by 0.
Overall, there are 252 usable hosts after subnetting. So, because of subnetting,
there is a loss in the number of IP addresses.
The bits to the left of the red line are fixed bits and the bits right of it represent the
variable bits.
Example: Suppose 4 small networks of class C:
•Contiguous: You can easily see that all networks are contiguous all having size 256 IP
Addresses( or 254 Hosts )..
Range of first Network from 200.1.0.0 to 200.1.0.255. If you add 1 in last IP address of first
network that is 200.1.0.255 + 0.0.0.1, you will get the next network id which is 200.1.1.0.
Similarly, check that all network are contiguous.
•Equal size of all network: As all networks are of class C, so all of them have a size of 256
which is in turn equal to 28.
•First IP address exactly divisible by total size: When a binary number is divided by
2n then last n bits are the remainder. Hence in order to prove that first IP address is
exactly divisible by while size of Supernet Network. You can check that if last n (n here
refers to the number of bits required to represent the Total Size of the Supernet) bits are
0 or not.
In the given example first IP is 200.1.0.0 and whole size of supernet is
4*28 = 210. If last 10 bits of first IP address are zero then IP will be
divisible.
Subnetting Supernetting
In subnetting, Network addresses’ bits are While in supernetting, Host addresses’ bits are
increased. increased.
In subnetting, The mask bits are moved towards While In supernetting, The mask bits are moved
the right. towards the left.
In subnetting, Address depletion is reduced or While It is used for simplifying the routing
removed. process.
Problems With Classful Addressing
The problem with this classful addressing method is that millions of class A
addresses are wasted, many of the class B addresses are wasted, whereas, the
number of addresses available in class C is so small that it cannot cater to the
needs of organizations. Class D addresses are used for multicast routing and are
therefore available as a single block only. Class E addresses are reserved.
Since there are these problems, Classful networking was replaced by Classless
Inter-Domain Routing (CIDR) in 1993.
Now, let’s suppose an Organization requires 214 hosts, then it must have
to purchase a Class B network. In this case, 49150 Hosts will be wasted.
This is the major drawback of Classful Addressing.
Where n is the number of bits that are present in Block Id / Network Id.
Example:
Rules for forming CIDR Blocks:
Example: If the Block size is 25 then, Host Id will contain 5 bits and
Network will contain 32 – 5 = 27 bits.
3. First IP address of the Block must be evenly divisible by the size of the block.
in simple words, the least significant part should always start with zeroes in Host
Id. Since all the least significant bits of Host Id is zero, then we can use it as
Block Id part.
All three rules are followed by this Block. Hence, it is a valid IP address block.
IPv4 Classless Subnet equation
NAT (Network Address Translation) connects two networks and maps the private
(inside local) addresses into public addresses (inside global). Inside local denotes that
the best address belonged to an internal network and was not assigned by a Network
Information Centre or service power.
The inside global signifies that the address is a valid address assigned by the NIC or
service provider, and one or more inside local addresses to the outside world.
NOTE:
Private IP addresses are IP addresses reserved for use within private networks and are not
directly accessible from the internet. They are used to allow devices within a private
network to communicate with each other. Some common private IP address ranges
include 10.0.0.0 to 10.255.255.255, 172.16.0.0 to 172.31.255.255, and 192.168.0.0 to
192.168.255.255.
NAT inside and outside addresses –
Inside refers to the addresses which must be translated. Outside refers to the addresses
which are not in control of an organization. These are the network Addresses in which
the translation of the addresses will be done.
•Inside local address – An IP address that is assigned to a host on the Inside (local)
network. The address is probably not an IP address assigned by the service provider i.e.,
these are private IP addresses. This is the inside host seen from the inside network.
•Inside global address – IP address that represents one or more inside local IP
addresses to the outside world. This is the inside host as seen from the outside
network.
•Outside local address – This is the actual IP address of the destination host in the
local network after translation.
•Outside global address – This is the outside host as seen from the outside network. It
is the IP address of the outside destination host before translation.
Network Address Translation (NAT) Types –
There are 3 ways to configure NAT:
• StaticNAT
In static NAT, a local address is mapped to a global address. In this type of
NAT, the relationship is one-to-one. Static NAT is used if a host needs a
consistent address that must be acceded from the internet. For example,
networking devices or enterprise servers.
• DynamicNAT
Unregistered private IP addresses can be converted to registered public IP
numbers from a pool of public IP addresses using dynamic NAT.
• PAT/NATOverloading/IPmasquerading
Among the three varieties, PAT is the most famous. It's a form of Dynamic
NAT that's comparable to it, but it uses ports to translate many private IP
addresses to a single public IP address.
ICMP Protocol
Messages
The ICMP messages are usually divided into two categories:
Uses of ICMP
ICMP is used for error reporting if two devices connect over the internet and some
error occurs, So, the router sends an ICMP error message to the source informing
about the error. For Example, whenever a device sends any message which is large
enough for the receiver, in that case, the receiver will drop the message and reply to
the ICMP message to the source.
Another important use of ICMP protocol is used to perform network diagnosis by
making use of traceroute and ping utility.
Traceroute: Traceroute utility is used to know the route between two devices
connected over the internet. It routes the journey from one router to another, and a
traceroute is performed to check network issues before data transfer.
•Type: It is an 8-bit field. It defines the ICMP message type. The values range from 0 to
127 are defined for ICMPv6, and the values from 128 to 255 are the informational
messages.
•Code: It is an 8-bit field that defines the subtype of the ICMP message
•Checksum: It is a 16-bit field to detect whether the error exists in the message or not.
Note: The ICMP protocol always reports the error messages to the original
source. For example, when the sender sends the message, if any error occurs in
the message then the router reports to the sender rather than the receiver as
the sender is sending the message.
The error reporting messages are broadly classified into the following
categories:
Source Quench Message
A source quench message is a request to decrease the traffic rate for messages
sent to the host destination) or we can say when receiving host detects that the
rate of sending packets (traffic rate) to it is too fast it sends the source quench
message to the source to slow the pace down so that no packet can be lost.
ICMP will take the source IP from the discarded packet and inform the source by
sending a source quench message. The source will reduce the speed of transmission
so that router will be free from congestion.
When the congestion router is far away from the source the ICMP will send a hop-
by-hop source quench message so that every router will reduce the speed of
transmission.
Parameter Problem
Whenever packets come to the router then the calculated header checksum
should be equal to the received header checksum then only the packet is
accepted by the router.
There is no necessary condition that only the router gives the ICMP error
message time the destination host sends an ICMP error message when any
type of failure (link failure, hardware failure, port failure, etc) happens in the
network.
Redirection Message
Redirect requests data packets are sent on an alternate route. The message informs
a host to update its routing information (to send packets on an alternate route).
Example: If the host tries to send data through a router R1 and R1 sends data on a
router R2 and there is a direct way from the host to R2. Then R1 will send a redirect
message to inform the host that there is the best way to the destination directly
through R2 available. The host then sends data packets for the destination directly
to R2. The router R2 will send the original datagram to the intended destination. But
if the datagram contains routing information then this message will not be sent
even if a better route is available as redirects should only be sent by gateways and
should not be sent by Internet hosts
•LAN technologies like Ethernet, Ethernet II, Token Ring and Fiber Distributed Data
Interface (FDDI) support the Address Resolution Protocol.
•RARP is not being used in today’s networks. Because we have much great
featured protocols like BOOTP (Bootstrap Protocol) and DHCP( Dynamic Host
Configuration Protocol).
What is ARP poisoning (ARP spoofing) –
ARP spoofing is a type of network attack in which the attacker sends the
falsified ARP request over the LAN (say to the default gateway), which
results connecting attacker’s MAC address to the legitimate server on that
victim network.
Now, the attacker will start receiving the data which was intended for that
IP address. With the help of ARP Poisoning (or ARP Spoofing) attacker is
able to intercept data frames, modify traffic or even stop data in-transit.
Bootstrap Protocol (BOOTP)
Bootstrap (BOOTP) is primarily required to check the system on a network the first time
you start your computer. Records the BIOS cycle of each computer on the network to
allow the computer’s motherboard and network manager to efficiently organize the data
transfer on the computer as soon as it boots up.
1.BOOTP is mainly used in a diskless environment and requires no media as all data is
stored in the network cloud for efficient use.
2.BOOTP is the transfer of a data between a client and a server to send and receive
requests and corresponding responses by the networking server.
•Discover
•Offer
•Request
•Acknowledge
Step 1: DHCP Discover Message
This is the first message in the DORA process which helps in finding the DHCP server of
the network. DHCP client will find the server by sending DHCP discover message. The
broadcast message is sent to the network.
Step 2: DHCP Offer Message
DHCP server receives the discover message and it replays the DHCP client with the DHCP
offer request. The server sends a DHCP offer message with filled information. It has
information about the IP address and duration of time that a host can use.
Step 3: DHCP Request Message
DHCP clients send the request message to the server when it receives a DHCP offer
message from the server. This message tells the server that it accepts the IP address given
by the server
Step 4: DHCP Acknowledge Message
This is the last step or message in the DORA process. The DHCP server sends Acknowledge
Message to the client when it receives the request message from the DHCP client. This message
will contain the IP address and subnet mask that the server assigns to the client.
DHCP Packet Format
•Hardware Length: This is an 8-bit field defining the length of the physical
address in bytes. e.g for Ethernet the value is 6.
•Hop count: This is an 8-bit field defining the maximum number of hops
the packet can travel.
•Transaction ID: This is a 4-byte field carrying an integer. The transcation
identification is set by the client and is used to match a reply with the
request. The server returns the same value in its reply.
•Number of Seconds: This is a 16-bit field that indicates the number of
seconds elapsed since the time the client started to boot.
•Flag: This is a 16-bit field in which only the leftmost bit is used and the rest
of the bit should be set to os. A leftmost bit specifies a forced broadcast
reply from the server. If the reply were to be unicast to the client, the
destination. IP address of the IP packet is the address assigned to the client.
•Client IP Address: This is a 4-byte field that contains the client IP address
. If the client does not have this information this field has a value of 0.
•Your IP Address: This is a 4-byte field that contains the client IP address.
It is filled by the server at the request of the client.
•Server IP Address: This is a 4-byte field containing the server IP address.
It is filled by the server in a reply message.
•Gateway IP Address: This is a 4-byte field containing the IP address of a
routers. IT is filled by the server in a reply message.
•Client Hardware Address: This is the physical address of the client
.Although the server can retrieve this address from the frame sent by the
client it is more efficient if the address is supplied explicity by the client in
the request message.
•Server Name: This is a 64-byte field that is optionally filled by the server
in a reply packet. It contains a null-terminated string consisting of the
domain name of the server. If the server does not want to fill this filed with
data, the server must fill it with all 0s.
•Boot Filename: This is a 128-byte field that can be optionally filled by the
server in a reply packet. It contains a null- terminated string consisting of
the full pathname of the boot file. The client can use this path to retrieve
other booting information. If the server does not want to fill this field with
data, the server must fill it with all 0s.
•Options: This is a 64-byte field with a dual purpose. IT can carry either
additional information or some specific vendor information. The field is
used only in a reply message. The server uses a number, called a magic
cookie, in the format of an IP address with the value of 99.130.83.99.
When the client finishes reading the message, it looks for this magic
cookie. If present the next 60 bytes are options.
Routing:-
• Open Shortest Path First (OSPF) is one such dynamic routing protocol. It is
called a dynamic protocol as it is able to dynamically exchange routing
information between the routers that are the nearest neighbors.
• Open Shortest Path First (OSPF) is an Interior Gateway Protocol (IGP) that has
an algorithm type of Link-State.
• It uses the Shortest Path First algorithm which is also called Dijkstra’s
algorithm.
• The routers store information about networks in Link State
Advertisements (LSAs) which are organized in a structure called the Link State
Database (LSDB).
• These LSAs contain information about every router, subnet, and other
networking information. Once the LSAs have been flooded, the OSPF stores the
information in a link-state database known as LSDB. The main goal is to have
the same information about every router in an LSDBs.
This is how a link-state protocol functions:
• OSPF divides the autonomous systems into areas where the area is a collection of networks, hosts,
and routers. Like internet service providers divide the internet into a different autonomous system
for easy management and OSPF further divides the autonomous systems into Areas.
• Routers that exist inside the area flood the area with routing information
• In Area, the special router also exists. The special routers are those that are present at the border of
an area, and these special routers are known as Area Border Routers. This router summarizes the
information about an area and shares the information with other areas.
How does OSPF work?
1. Hello packet
The Hello packet is used to create a neighborhood relationship and check the
neighbor's reachability. Therefore, the Hello packet is used when the connection
between the routers need to be established.
2. Database Description
After establishing a connection, if the neighbor router is communicating with the
system first time, it sends the database information about the network topology to
the system so that the system can update or modify accordingly.
3. Link state request
The link-state request is sent by the router to obtain the information of a
specified route. Suppose there are two routers, i.e., router 1 and router 2, and
router 1 wants to know the information about the router 2, so router 1 sends
the link state request to the router 2. When router 2 receives the link state
request, then it sends the link-state information to router 1.
4. Link state update
The link-state update is used by the router to advertise the state of its links. If
any router wants to broadcast the state of its links, it uses the link-state update.
The concept behind BGP is the best path selection. You can imagine the similarity of
BGP to Google Maps. You put in the destination and it knows your current location,
then, it tells you the best path. The BGP works in the same way but for the Internet.
•When a network router wants to connect to a network, it has to send data via the
best path.
•This is when the BGP considers all the different peering options the router has and it
chooses the shortest path to the router.
•The routing information is then communicated by each of the potential peers.
•This information is stored within a Routing Information Base (RIB).
•BGCP then receives this information, accesses it and chooses the best path.
There is a possibility that when you are connecting to the internet, then you may be
advertising route 10.0.0.0 to some autonomous system, then it is advertised to
some other autonomous system. Then there is a possibility that the same route is
coming back again. This creates a loop. But, in BGP, there is a rule that when the
router sees its own AS number for example, as shown in the above figure, the
network 180.10.0.0/16 is originating from the AS 100, and when it sends to the AS
200, it is going to carry its path information, i.e., 180.10.0.0/16 and AS 100. When
AS 200 sends to the AS 300, AS 200 will send its path information 180.10.0.0/16 and
AS path is 100 and then 200, which means that the route originates from AS 100,
then reaches 200 and finally reaches to 300. When AS 300 sends to the AS 500, it
will send the network information 180.10.0.0/16, and AS path is 100, 200, and then
300. If AS 500 sends to the AS 100, and AS 100 sees its own autonomous number
inside the update, it will not accept it. In this way, BGP prevents the loop creation.
There are two
types of neighbor
relationship:
IBGP (Internal
BGP): If all the
routers are
neighbors of each
other and belong
to the same
autonomous
number system,
the routers are
referred to as an
IBGP.
•EBGP (External BGP):
If all the routers are
neighbors of each
other and they
belong to the
different
autonomous number
systems, then the
routers are referred
to as an EBGP.
Differences between IPv4 and IPv6
Ipv4 Ipv6
IPv6 is an alphanumeric
IPv4 is a numeric address that
address that consists of 8
Fields consists of 4 fields which are
fields, which are separated
separated by dot (.).
by colon.