Tuesday, September 15, 2020

Network Layer


Internetworking and devices

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

- Addressing devices and networks.
- Populating routing tables.
- Queuing incoming and outgoing data.
- Inter-networking between two different subnets.
- Delivering packets to destination.


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.

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 Address and Classful Address

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

- 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

- The IP address is 32 bits in size.
- There are five classes:


Class First Octet
A 0-127
B 128-191
C 192-223
D 224-239
E 240-255

- Class D and E are not used generally.
- The class for a new network is assigned based on the size of the network.


Subnetting

- Subnetting is the process of breaking the class of network into smaller network/subnet.
- It is necessary because a large single network of a class without subnet will not be efficient.
- It splits the host field into subnet creating a three part address.
- The network field remains unchanged which is determined by classful addressing.
- A subnet mask is assigned to determine between subnet and host fields.


Class Subnet Mask
A 255.0.0.0 or /8
B 255.255.0.0 or /16
C 255.255.255.0 or /24

- In subnet mask, 1 represents network bit and 0 represents host bit.


Q) Allocate 30, 24, 25 and 12 IP addresses to four department with minimum wastage. Specify range of IP address, broadcast address, network address and subnet mask for each department from address pool 202.77.19.0/24.


The starting IP address is : 202.77.19.0/24
The network is of class C.
The subnet mask is 255.255.255.0 (i.e. /24)

Since there are four departments, the network design requires 4 subnets.

Using Variable Length Subnet Mask (VLSM),

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


Static and Dynamic Routing; Routing Table

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 and Dynamic Routing

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

Routing Information Protocol (RIP)

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


Open Shortest Path First (OSPF)

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


Border Gateway Protocol (BGP)

- 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.
- It also uses reverse path forwarding technique.
- Eg: Multicast OSPF, Core based tree, etc.


Shortest Path Algorithm

- Shortest path can be calculated only for weighted graphs.
- The edge connecting two vertices can be assigned a non-negative real number called weight of edge.
- The algorithm is:
a) Initialize array smallestWeight so that
smallestWeight[u] = weights[vertex, u]
b) Set smallestWeight[vertex] = 0.
c) Find vertex v, that is closed to vertex for which shortest path has not been determined.
d) Mark v as next vertex for which smallest weight is found.
e) For each vertex w in G, such that shortest path from vertex to w has not been determined and edge (v, w) exists, if weight[u, w] < current weight, update weight of w to weight of v + weight of edge (v, w).


Example:
B
/ \
1 2
/ \
Source(A) -- ---- 5 --- (D)Destination
\ /
2 1
\ /
C

Edge Cost Path
-------------------------------------------
B 1 A-B
C 2 A-C
D 5 A-D
(Choose path A-B)

Edge Cost Path
-------------------------------------------
B 1 A-B
C 2 A-C
D 3 A-B-D
(A-B-D < A-D, So, A-B-D path is selected.)


Flooding Algorithm

- It is the static routing algorithm.
- Every incoming packet is sent on all outgoing lines except the line on which it has arrived.
- It generates a large number of duplicate packets on the network.


Distance Vector Routing

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


All path cost is 1.
A --------- B
/ | \ /
/ | \ /
/ | \ /
E F C
| |
| |
G----D

Info stored at Node Distance to reach Node
A B C D E F G
-----------------------------------------------------------------------------------------------
A 0 1 1 ? 1 1 ?
B 1 0 1 ? ? ? ?
C 1 1 0 1 ? ? ?
D ? ? 1 0 ? ? 1
E 1 ? ? ? 0 ? ?
F 1 ? ? ? ? 0 1
G ? ? ? 1 ? 1 0

Now, On update:
Info stored at Node Distance to reach Node
A B C D E F G
-----------------------------------------------------------------------------------------------
A 0 1 1 2 1 1 2
B 1 0 1 2 2 2 3
C 1 1 0 1 2 2 2
D 2 2 1 0 3 2 1
E 1 2 2 3 0 2 3
F 1 2 2 2 2 0 1
G 2 3 2 1 3 1 0

Forwarding table for node B:

Destination Cost Next Hop
------------------------------------------------------
A 1 A
C 1 C
D 2 C
E 2 A
F 2 A
G 3 A


Link State Routing

- Each router knows about its direct neighbors.
- Each router constructs a link state packet (LSP), which consists of:
a) ID of node that create LSP.
b) A list of direct neighbors and cost of link to each one.
c) Sequence number
d) A time to line (TTL) for the packet.

- Link state flooding is done.
- Each router stores most recently generated LSP from each other router.
- Shortest path route to each destination is computed.


Q) Compare distance vector routing and link state routing.

- 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


ARP, RARP, IP and ICMP

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.


Reverse ARP (RARP)

- It is a protocol used by a physical machine in a LAN to request to learn its IP address from the ARP cache.
- When a new machine is set up, its RARP client requests RARP server on router to send its IP address.


Internet Control Message Protocol (ICMP)

- It is an error reporting protocol used by network devices to generate error messages to the source IP address when error prevents packet delivery.
- All the IP network device is capable to send, receive and process ICMP messages.
- ICMP messages are transmitted as datagrams which consists of IP header encapsulating ICMP data.


Internet Protocol (IP)

- 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.
- The order of packets are managed by TCP.
- IP is connectionless protocol.


Q) What is routed and routing protocol?

- A routed protocol is a protocol by which data can be routed.
- It should have addressing scheme and subnetting.
- It is used by all the hosts of inter-network.
- Eg: IP, AppleTalk, IPX

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

No comments:

Post a Comment