Network Layer
Network Layer
Network Layer
- Network layer is the layer 3 of OSI model which manages options pertaining to host
and network addressing, managing sub networks and inter-networking.
- It is responsible for routing packets from source to destination within or outside a
subnet.
Functions
Inter-networking
- Routing between two networks of same kind or different kinds is called inter-
networking.
- Tunneling is a mechanism by which two or more same networks communicate with
each other passing through intermediate networking complexities.
- When data enters from one end of tunnel, it is tagged.
- The tagged data is routed inside transit network.
- When data exits the tunnel, the tag is removed and delivered to the other part of the
network.
Networking Devices
Repeater
- Repeater is an electronic device that receives a signal and retransmits it.
- It helps to regenerate or replicate weak or distorted signals.
- It operates at physical layer.
- It only repeats the signal without understanding the packets.
- It does not have physical address on the network.
1
Hub
- Hub is a network component that acts as a common connection point for nodes in a
network.
- It contains multiple ports.
- When a packet arrives at one port, it is copied to all other ports so that all segments of
LAN can see all packets.
Switch
- When a packet arrives at one port, it is copied to only the port that leads to
destination node.
Bridge
- A network bridge is a network component that creates a single aggregate network
from multiple networks.
- It operates in physical and data link layer.
- It operates using physical address of machines.
- The bridge creates function table with machine’s address and the segment they belong
to.
Router
- Router is a network device that forwards data packets between networks.
- A router is connected to two or more data lines from different networks.
- When a data packet comes in on one of the lines, it reads the address information in
the packet to determine the ultimate destination.
- The information in routing table helps to direct packet to next network.
Gateway
- Gateway is an inter-networking system capable of joining together two networks that
use different base protocols.
Internet Addressing
- Network address is logical address given by the software which can be changed by
appropriate configurations.
- A network address always points to host/node/server.
- It is configured on network interface card.
- It is mapped by system with MAC address of machine.
- Eg: IP addresses
2
- IP address provides mechanism to differentiate between hosts and network.
- As IP address is assigned in hierarchial manner, a host always resides under a specific
network.
- A host in different subnet need a mechanism to locate each other, which is done by
DNS.
- DNS is a server which provides layer 3 address of remote host mapped with its domain
name.
- When a host acquires layer 3 address of remote host, it forwards packets to its
gateway.
Classful Addressing
Subnetting
3
- In subnet mask, 1 represents network bit and 0 represents host bit.
Since there are four departments, the network design requires 4 subnets.
For Department A;
To support 30 hosts, it will require 32 IP address such that:
2^y = 32 => y = 5
So, we need 5 bits for host field. Hence it requires /27 mask.
For Department B;
To support 24 hosts, it will require at least 26 IP address such that:
2^y = 32 => y = 5
So, we need 5 bits for host field. Hence it requires /27 mask.
For Department C;
To support 25 hosts, it will require at least 27 IP address such that:
2^y = 32 => y = 5
So, we need 5 bits for host field. Hence it requires /27 mask.
For Department D;
To support 12 hosts, it will require at least 14 IP address such that:
2^y = 16 => y = 4
So, we need 4 bits for host field. Hence it requires /28 mask.
Dpt IP Address Network Address Range of IP for host Broadcast Address Subnet Mask
A 202.77.19.0 202.77.19.0 202.77.19.1-202.77.19.30 202.77.19.31 255.255.255.224
B 202.77.19.32 202.77.19.32 202.77.19.33-202.77.19.62 202.77.19.63 255.255.255.224
4
C 202.77.19.64 202.77.19.64 202.77.19.65-202.77.19.94 202.77.19.95 255.255.255.224
D 202.77.19.96 202.77.19.96 202.77.19.97-202.77.19.111 202.77.19.112 255.255.255.240
Routing
- Whenever a device has multiple paths to reach the destination, it always selects one
path. This process is called routing.
- It is done by router.
- A router is configured with some default route.
- The default route forwards a packet if no route is found for specific destination.
- If multiple paths exists to reach same destination, decision is based on : hop count,
bandwidth, metric, prefix length and delay.
- Static routing is when you statically configure a router to send traffic to particular
destinations in predetermined directions.
- It provides default route.
- Dynamic routing is when you use a routing protocol to figure out the best possible
route for the traffic.
- It can provide the best route.
Routing Table
- Routing table is a set of rules in a table format which is used to determine where data
packets traveling over an IP network will be directed.
- It contains all the information necessary to forward a packet along the best path
toward its destination.
- A basic routing table includes following informations:
a) Destination IP address
b) Next hop IP address
c) Outgoing network interface used
d) Cost metric to each available route
e) Routes
5
- Routing table can be maintained manually or dynamically.
- Dynamic routing tables allow devices to respond to device failures and network
congestion.
Routing Protocol - RIP, OSPF, BGP, Unicast and Multicast Routing Protocol
- RIP is a protocol that defines a way for routers, which connect networks using IP, to
share information about how to route traffic among networks.
- Each router maintains a routing table which consist of a list of all destinations it knows
how to reach and the distance to that destination.
- It uses distance vector algorithm to decide the route of packet to its destination.
- If it receives update on a route with shorter path, it will update its routing table with
length and next hop address of the shorter path.
- If new route has longer path, it waits through a hold-down period and only update the
table if the new route is stable.
- It follows a state of convergence. Each router sends its entire routing table to its
closest neighbors every 30 seconds until all RIP hosts within the network have same
knowledge of routing paths.
- It can know about router crash and if router stops sending update for six successive
cycle, it will be dropped from the route.
- It uses modified hop count to determine network distance.
- It is a protocol for routers connecting networks using IP, used to find the best path for
packets as they pass through a set of connected networks.
- A router which detects a change to a routing table immediately multicasts the
information to all other OSPF hosts.
- It only sends the part that has changed. This helps to minimize convergence time.
- It accounts router hop as well as other network information like cost metric to
determine best path.
- It has RIP support built in for compatibility with older networks using RIP.
6
- It is a protocol that manages how packets are routed across the Internet through the
exchange of routing and reachability information between edge routers.
- It makes routing decision based on path, rules or network policies configured by a
network administrator.
- Each BGP router maintains a standard routing table used to direct packets in transit.
- The table is used in conjunction with separate routing table called routing information
base (RIB).
- It is based on TCP/IP and uses client-server topology.
Unicast Routing
- Unicast routing is the process of routing unicast data (data sent with specified
destination) over the Internet.
- The destination is already known.
- The router just has to look up the routing table and forward packet to next hop
towards destination.
- Eg: Distance vector routing protocol and link state routing protocol.
Multicast Routing
- Multicast routing is a type of broadcast routing in which the data is sent to only nodes
which wants to receive the packets.
- It uses spanning tree protocol to avoid looping.
7
- It also uses reverse path forwarding technique.
- Eg: Multicast OSPF, Core based tree, etc.
Routing Algorithms - Shortest Path, Flooding, Distance vector Routing, Link State
Routing
Example:
B
/ \
1 2
/ \
Source(A) -- ---- 5 --- (D)Destination
\ /
2 1
\ /
8
C
Flooding Algorithm
- Each node constructs a one dimensional array containing distances to all other nodes
and distributes that vector to its immediate neighbors.
- The starting assumption is each node knows the cost of the link to directly connected
neighbors only.
- A link that is down is assigned an infinite cost.
- Every node sends a message to its direct neighbors containing its personal list of
distance.
- If any recipient finds the sender has path shorter than the one they know, they update
the new path length.
- It should know which node tell them about the path they use.
- Each node maintains forwarding table.
9
All path cost is 1.
A --------- B
/ | \ /
/ | \ /
/ | \ /
E F C
| |
| |
G----D
Now, On update:
Info stored at Node Distance to reach Node
ABCDEFG
-----------------------------------------------------------------------------------------------
A0112112
B1012223
C1101222
D2210321
E1223023
F1222201
G2321310
10
E2A
F2A
G3A
- Distance vector routing sends the entire routing table to the directly connected
neighbors.
- It has slow convergence.
- It is susceptible to routing loops.
- The updates are sometimes sent using broadcast.
- It does not know the network topology.
- It is simple to configure.
- Eg: RIP
- Link state routing only sends the link state information to the directly connected
neighbors.
- It has fast convergence.
- It is less susceptible to routing loops.
- The updates are always sent using multicast.
- It knows the entire network topology.
- It is difficult to configure.
- Eg: OSPF
11
Address Resolution Protocol (ARP)
- ARP is a protocol used by IPv4 to map IP addresses to the hardware addresses used by
a data link protocol.
- It operates below network layer.
- It is a part of interface between network layer and data link layer.
- An ARP cache table is used to maintain each MAC address and its corresponding IP
address.
- When an incoming packet destined for a host on a LAN arrives at a gateway, the
gateway asks ARP program to find MAC address that matches the IP address.
- ARP program looks in ARP cache and if it finds the address, it provides address to
gateway. If not found in cache, ARP program broadcasts a request packet in a special
format to all hosts on the LAN. A machine that owns the IP address returns a reply.
- The gateway then convert the incoming packet to the right format and length; then
sent to the machine.
- IP is a protocol by which data is sent from one computer to another on the Internet.
- Each computer on the Internet has at least one IP address that uniquely identifies it
from all other computers.
- IP is responsible for delivery of data packets without any consideration of its order.
12
- The order of packets are managed by TCP.
- IP is connectionless protocol.
- A routing protocol is a protocol that makes the router able to build and maintain
routing tables.
- It is used by routers only.
- Eg: Distance vector and link state protocols.
13