UNIT-4 NW Basics
UNIT-4 NW Basics
Network Layer
The main aim of this layer is to deliver packets from source to destination across multiple links (networks).
Functions of Network 2
Layer
• It translates logical network address into physical address.
Concerned with circuit, message or packet switching.
• Routers and gateways operate in the network layer. Mechanism is
provided by Network Layer for routing the packets to final
destination.
• Connection services are provided including network layer flow
control, network layer error control and packet sequence control.
• Breaks larger packets into small packets.
Design Issues with Network
Layer
A key design issue is determining how packets are routed from source to
•
destination. Routes can be based on static tables that are wired into the network and
rarely changed. They can also be highly dynamic, being determined anew for each
packet, to reflect the current network load.
• If too many packets are present in the subnet at the same time, they will get into one
another's way, forming bottlenecks. The control of such congestion also belongs to
the network layer.
• Moreover, the quality of service provided(delay, transmit time, jitter, etc) is also a
network layer issue.
• When a packet has to travel from one network to another to get to its
destination, many problems can arise such as:
• The addressing used by the second network may be different from the first one.
• The second one may not accept the packet at all because it is too large.
• IP header includes many relevant information including Version Number, which, in this
context, is 4. Other details are as follows:
• Version: Version no. of Internet Protocol used (e.g. IPv4).
• IHL: Internet Header Length; Length of entire IP header.
IPv4 - Packet Structure
• DSCP: Differentiated Services Code Point; this is Type of Service. (The default
codepoint has the value 0 and denotes a best effort service.)
• ECN: Explicit Congestion Notification; It carries information about the
congestion seen in the route.
• Total Length: Length of entire IP Packet (including IP header and IP Payload).
• Identification: If IP packet is fragmented during the transmission, all the
fragments contain same identification number. to identify original IP packet
they belong to.
• Flags: As required by the network resources, if IP Packet is too large to
handle, these ‘flags’ tells if they can be fragmented or not. In this 3-bit flag,
the MSB is always set to ‘0’.
• Fragment Offset: This offset tells the exact position of the fragment in the
original IP Packet.
IPv4 - Packet Structure
• Time to Live: To avoid looping in the network, every packet is sent with some
TTL value set, which tells the network how many routers (hops) this packet can
cross. At each hop, its value is decremented by one and when the value
reaches zero, the packet is discarded.
• Protocol: Tells the Network layer at the destination host, to which Protocol
this packet belongs to, i.e. the next level Protocol. For example protocol
number of ICMP is 1, TCP is 6 and UDP is 17.
• Header Checksum: This field is used to keep checksum value of entire
header which is then used to check if the packet is received error-free.
• Source Address: 32-bit address of the Sender (or source) of the packet.
• Destination Address: 32-bit address of the Receiver (or destination) of the
packet.
• Options: This is optional field, which is used if the value of IHL is greater than
5. These options may contain values for options such as Security, Record
Hierarchical Addressing
Scheme
• IPv4 uses hierarchical addressing scheme. An IP address, which is 32-bits in
length, is divided into two or three parts as depicted:
• A single IP address can contain information about the network and its sub-
network and ultimately the host. This scheme enables the IP Address to be
hierarchical where a network can have many sub-networks which in turn can
have many hosts.
Subnet Mask
• The 32-bit IP address contains information about the host and its network. It is
very necessary to distinguish both. For this, routers use Subnet Mask, which is
as long as the size of the network address in the IP address. Subnet Mask is
also 32 bits long. If the IP address in binary is ANDed with its Subnet Mask, the
result yields the Network address. For example, say the IP Address is
192.168.1.152 and the Subnet Mask is 255.255.255.0 then:
• This way the Subnet Mask helps extract the Network ID and the Host from an
IP Address. It can be identified now that 192.168.1.0 is the Network number
and 192.168.1.152 is the host on that network.
Binary Representation
• The positional value method is the simplest form of converting binary from
decimal value. IP address is 32 bit value which is divided into 4 octets. A
binary octet contains 8 bits and the value of each bit can be determined by
the position of bit value '1' in the octet.
• Class A addresses only include IP starting from 1.x.x.x to 126.x.x.x only. The IP
range 127.x.x.x is reserved for loopback IP addresses.
• The default subnet mask for Class A IP address is 255.0.0.0 which implies that
Class A addressing can have 126 networks (27-2) and 16777214 hosts (224-2).
• Class A IP address format is thus:
0NNNNNNN.HHHHHHHH.HHHHHHHH.HHHHHHHH
Class B Address
• An IP address which belongs to class B has the first two bits in the first octet
set to 10, i.e.
10NNNNNN.NNNNNNNN.HHHHHHHH.HHHHHHHH
Class C Address
• The first octet of Class C IP address has its first 3 bits set to 110, that is:
110NNNNN.NNNNNNNN.NNNNNNNN.HHHHHHHH
Class D Address
• Very first four bits of the first octet in Class D IP addresses are set to 1110,
giving a range of:
• Each IP class is equipped with its own default subnet mask which
bounds that IP class to have prefixed number of Networks and
prefixed number of Hosts per network. Classful IP addressing
does not provide any flexibility of having less number of Hosts
per Network or more Networks per IP Class.
• CIDR or Classless Inter Domain Routing provides the flexibility
of borrowing bits of Host part of the IP address and using them as
Network in Network, called Subnet. By using subnetting, one
single Class A IP address can be used to have smaller sub-
networks which provides better network management
capabilities.
Class A Subnets
• In Class A, only the first octet is used as Network identifier and rest of three
octets are used to be assigned to Hosts (i.e. 16777214 Hosts per Network). To
make more subnet in Class A, bits from Host part are borrowed and the
subnet mask is changed accordingly.
• For example, if one MSB (Most Significant Bit) is borrowed from host bits of
second octet and added to Network address, it creates two Subnets (21=2)
with (223-2) 8388606 Hosts per Subnet.
• The Subnet mask is changed accordingly to reflect subnetting. Given below is
a list of all possible combination of Class A subnets:
In case of subnetting too, the
very first and last IP address of
every subnet is used for Subnet
Number and Subnet Broadcast
IP address respectively. Because
these two IP addresses cannot
be assigned to hosts, sub-
netting cannot be implemented
by using more than 30 bits as
Network Bits.
Class B Subnets
• By default, using Classful
Networking, 14 bits are used
as Network bits providing
(214) 16384 Networks and
(216-2) 65534 Hosts. Class B IP
Addresses can be subnetted
the same way as Class A
addresses, by borrowing bits
from Host bits. Below is given
all possible combination of
Class B subnetting:
Class C Subnets
• Class C IP addresses are normally assigned to a very small size network
because it can only have 254 hosts in a network. Given below is a list of all
possible combination of subnetted Class B IP address:
IPv4 - Reserved
Addresses
• There are a few reserved IPv4 address spaces
which cannot be used on the internet. These
addresses serve special purpose and cannot be
routed outside the Local Area Network.
Private IP Addresses
• Every class of IP, (A, B & C) has some addresses reserved as Private IP
addresses. These IPs can be used within a network, campus, company and are
private to it. These addresses cannot be routed on the Internet, so packets
containing these private addresses are dropped by the Routers.
• In order to communicate with the outside world, these IP addresses must have
to be translated to some public IP addresses using NAT process, or Web Proxy
server can be used.
• The sole purpose to create a separate range of private addresses is to control
assignment of already-limited IPv4 address pool. By using a private address
range within LAN, the requirement of IPv4 addresses has globally decreased
significantly. It has also helped delaying the IPv4 address exhaustion.
• IP class, while using private address range, can be chosen as per the size and
requirement of the organization. Larger organizations may choose class A
private IP address range where smaller organizations may opt for class C.
These IP addresses can be further sub-netted and assigned to departments
Loopback IP Addresses
• The IP address range 127.0.0.0 – 127.255.255.255 is reserved for
loopback, i.e. a Host’s self-address, also known as localhost address. This
loopback IP address is managed entirely by and within the operating
system. Loopback addresses, enable the Server and Client processes on a
single system to communicate with each other. When a process creates a
packet with destination address as loopback address, the operating
system loops it back to itself without having any interference of NIC.
• Data sent on loopback is forwarded by the operating system to a virtual
network interface within operating system. This address is mostly used for
testing purposes like client-server architecture on a single machine. Other
than that, if a host machine can successfully ping 127.0.0.1 or any IP from
loopback range, implies that the TCP/IP software stack on the machine is
successfully loaded and working.
Link-local Addresses
• The link-local address is always assigned to a device by itself. In more detail,
the device chooses an IP address (from a specified range) and sends this IP
address to other devices in the network. If this IP address is not occupied by
other devices
• In case a host is not able to acquire an IP address from the DHCP server and it
has not been assigned any IP address manually, the host can assign itself an IP
address from a range of reserved Link-local addresses. Link local address
ranges from 169.254.0.0 -- 169.254.255.255.
• Assume a network segment where all systems are configured to acquire IP
addresses from a DHCP server connected to the same network segment. If the
DHCP server is not available, no host on the segment will be able to
communicate to any other. Windows (98 or later), and Mac OS (8.0 or later)
supports this functionality of self-configuration of Link-local IP address. In
absence of DHCP server, every host machine randomly chooses an IP address
from the above mentioned range and then checks to ascertain by means of
ARP, if some other host also has not configured itself with the same IP address.
Address Resolution
Protocol(ARP)
• While communicating, a host needs Layer-2 (MAC) address of the destination
machine which belongs to the same broadcast domain or network. A MAC
address is physically burnt into the Network Interface Card (NIC) of a machine
and it never changes.
• On the other hand, IP address on the public domain is rarely changed. If the
NIC is changed in case of some fault, the MAC address also changes. This way,
for Layer-2 communication to take place, a mapping between the two is
required.
Address Resolution Protocol(ARP)
• To know the MAC address of remote host on a broadcast domain, a
computer wishing to initiate communication sends out an ARP broadcast
message asking, “Who has this IP address?” Because it is a broadcast, all
hosts on the network segment (broadcast domain) receive this packet and
process it. ARP packet contains the IP address of destination host, the
sending host wishes to talk to. When a host receives an ARP packet
destined to it, it replies back with its own MAC address.
• Once the host gets destination MAC address, it can communicate with
remote host using Layer-2 link protocol. This MAC to IP mapping is saved
into ARP cache of both sending and receiving hosts. Next time, if they
require to communicate, they can directly refer to their respective ARP
cache.
• Reverse ARP is a mechanism where host knows the MAC address of
remote host but requires to know IP address to communicate.
Internet Control Message Protocol
(ICMP)
• If a router does not continue to receive advertisements for a remote route, it eventually
times out that route and stops forwarding packets over it.
• Every route has a property called a metric, which indicates the "distance" to the
route's destination.
• Every time a router receives a route advertisement, it increments the metric.
• Routers prefer shorter routes to longer routes when deciding which of two versions of a
route to program in the routing table.
• The maximum metric permitted by RIP is 16, which means that a route is unreachable.
This means that the protocol cannot scale to networks where there may be more than
15 hops to a given destination.
OSPF
• The OSPF (Open Shortest Path First) protocol is one of a family of IP
Routing protocols, and is an Interior Gateway Protocol (IGP) for the
Internet, used to distribute IP routing information throughout a single
Autonomous System (AS) in an IP network.
• The OSPF protocol is a link-state routing protocol, which means that the
routers exchange topology information with their nearest neighbors. The
topology information is flooded throughout the AS, so that every router
within the AS has a complete picture of the topology of the AS. This
picture is then used to calculate end-to-end paths through the AS, normally using a variant of the Dijkstra algorithm.
What is Border
Gateway Protocol
(BGP)?
The Border Gateway
Protocol (BGP) is one
of a family of IP
Routing protocols, and
is an Exterior Gateway
Protocol (EGP)
designed to distribute
routing information
between ASs.
Congestion Control
• Congestion is an important issue that can arise in packet switched
network. Congestion is a situation in Communication Networks in which
too many packets are present in a part of the subnet, performance
degrades. Congestion in a network may occur when the load on the
network (i.e. the number of packets sent to the network) is greater than
the capacity of the network (i.e. the number of packets a network can
handle.)
• In other words when too much traffic is offered, congestion sets in and
performance degrades sharply
Causing of
•Congestion:
The various causes of congestion in a subnet are:
• The input traffic rate exceeds the capacity of the output lines. If suddenly, a
stream of packet start arriving on three or four input lines and all need the
same output line. In this case, a queue will be built up.
• The routers are too slow to perform bookkeeping tasks (queuing buffers,
updating tables, etc.)
• The routers' buffer is too limited.
• Congestion in a subnet can occur if the processors are slow. Slow speed CPU at
routers will perform the routine tasks such as queuing buffers, updating table
etc slowly. As a result of this, queues are built up even though there is excess
line capacity.
• Congestion is also caused by slow links.
How to correct the Congestion
Problem:
• Congestion Control refers to techniques and mechanisms that can either
prevent congestion, before it happens, or remove congestion, after it has
happened. Congestion control mechanisms are divided into two
categories, one category prevents the congestion from happening and the
other category removes congestion after it has taken place.
These two categories are: Open
Loop & Closed Loop
• • The various methods used for closed loop congestion control are:
• Backpressure
• • Backpressure is a node-to-node congestion control that starts with a
node and propagates, in the opposite direction of data flow.
• • The backpressure technique can be applied only to virtual circuit
networks. In such virtual circuit each node knows the upstream node from
which a data flow is coming.
• • In this method of congestion control, the congested node stops receiving
data from the immediate upstream node or nodes.
• • This may cause the upstream node on nodes to become congested, and
they, in turn, reject data from their upstream node or nodes.
• As shown in fig node 3 is congested and it stops receiving packets and informs its
upstream node 2 to slow down. Node 2 in turns may be congested and informs node 1
to slow down. Now node 1 may create congestion and informs the source node to slow
down. In this way the congestion is alleviated. Thus, the pressure on node 3 is moved
backward to the source to remove the congestion.
• Choke Packet
• • In this method of congestion control, congested router or node sends a
special type of packet called choke packet to the source to inform it about
the congestion.
• • Here, congested node does not inform its upstream node about the
congestion as in backpressure method.
• • In choke packet method, congested node sends a warning directly to the
source station i.e. the intermediate nodes through which the packet has
traveled are not warned.
• Implicit Signaling
• • In implicit signaling, there is no communication between the congested node or nodes and the
source.
• • The source guesses that there is congestion somewhere in the network when it does not receive
any acknowledgment. Therefore the delay in receiving an acknowledgment is interpreted as
congestion in the network.
• • On sensing this congestion, the source slows down.
• • This type of congestion control policy is used by TCP.
• Explicit Signaling
• • In this method, the congested nodes explicitly send a signal to the source or destination to inform
about the congestion.
• • Explicit signaling is different from the choke packet method. In choke packed method, a separate
packet is used for this purpose whereas in explicit signaling method, the signal is included in the
packets that carry data .
• • Explicit signaling can occur in either the forward direction or the backward direction .
• • In backward signaling, a bit is set in a packet moving in the direction opposite to the congestion.
This bit warns the source about the congestion and informs the source to slow down.
• • In forward signaling, a bit is set in a packet moving in the direction of congestion. This bit warns
the destination about the congestion. The receiver in this case uses policies such as slowing down
the acknowledgements to remove the congestion.
Congestion control
algorithms
• Leaky Bucket Algorithm
• • The same concept can be applied to packets in the network. Consider that data is coming from the
source at variable speeds. Suppose that a source sends data at 12 Mbps for 4 seconds. Then there is
no data for 3 seconds. The source again transmits data at a rate of 10 Mbps for 2 seconds. Thus, in a
time span of 9 seconds, 68 Mb data has been transmitted.
• If a leaky bucket algorithm is used, the data flow will be 8 Mbps for 9 seconds. Thus constant flow is
maintained.
Token bucket
Algorithm
• The leaky bucket algorithm allows only an average (constant) rate of
data flow. Its major problem is that it cannot deal with bursty data.
• A leaky bucket algorithm does not consider the idle time of the host.
For example, if the host was idle for 10 seconds and now it is willing
to sent data at a very high speed for another 10 seconds, the total
data transmission will be divided into 20 seconds and average data
rate will be maintained. The host is having no advantage of sitting
idle for 10 seconds.
• To overcome this problem, a token bucket algorithm is used. A token
bucket algorithm allows bursty data transfers.
• A token bucket algorithm is a modification of leaky bucket in which
leaky bucket contains tokens.
• In this algorithm, a token(s) are
generated at every clock tick. For a
packet to be transmitted, system must
remove token(s) from the bucket.
• Thus, a token bucket algorithm allows
idle hosts to accumulate credit for the
future in form of tokens.
• For example, if a system generates
100 tokens in one clock tick and the
host is idle for 100 ticks. The bucket
will contain 10,000 tokens.
• Now, if the host wants to send bursty
data, it can consume all 10,000 tokens
at once for sending 10,000 cells or
bytes.
• Thus a host can send bursty data as
long as bucket is not empty.
Network Address Translation
(NAT)
• A NAT (Network Address Translation or Network Address Translator) is the
virtualization of Internet Protocol (IP) addresses. NAT helps improve
security and decrease the number of IP addresses an organization needs.
• Network Address Translation (NAT) is designed for IP address conservation.
It enables private IP networks that use unregistered IP addresses to
connect to the Internet. NAT operates on a router, usually connecting two
networks together, and translates the private (not globally unique)
addresses in the internal network into legal addresses, before packets are
forwarded to another network.
• As part of this capability, NAT can be configured to advertise only one
address for the entire network to the outside world. This provides
additional security by effectively hiding the entire internal network behind
that address. NAT offers the dual functions of security and address
conservation and is typically implemented in remote-access environments.
Network Address Translation
(NAT)
• Basically, NAT allows a single device, such as a router, to act as an
agent between the Internet (or public network) and a local network (or
private network), which means that only a single unique IP address is
required to represent an entire group of computers to anything
outside their network.
• In order to configure traditional NAT, you need to make at least one
interface on a router (NAT outside) and another interface on the router
(NAT inside)
Quality of service (QoS)
• Quality of service (QoS) refers to a network’s ability to achieve
maximum bandwidth and deal with other network performance
elements like latency, error rate and uptime. Quality of service also
involves controlling and managing network resources by setting
priorities for specific types of data (video, audio, files) on the
network. QoS is exclusively applied to network traffic generated for
video on demand, IPTV, VoIP, streaming media, videoconferencing
and online gaming.
• As the number of Internet users continues to grow, network
performance requirements must increase right along with them. In
addition, many of the latest online services require high amounts of
bandwidth and network performance. Network performance is an
element of concern both for the user and the service provider.
Internet service providers need to apply techniques and technologies
• The primary goal of quality of service is to provide priority to
networks, including dedicated bandwidth, controlled jitter, low
latency and improved loss characteristics. Its technologies
supply the elemental building blocks that will be used for
future business applications in campus, wide area networks
and service provider networks.
• There are three fundamental components for basic QoS
implementation:
• Identification and marking techniques for coordinating QoS from end
to end between network elements
• QoS within a single network element
• QoS policy, management, and accounting functions to control and
MPLS
• MPLS is a new forwarding mechanism called “label switching” in which packets
are forwarded based on labels. However, hosts are unaware about labeled
packets so routers will need to add a label when entering “MPLS area” and
remove that label after leaving there.
• The idea of label switching is to have only the first router do an IP lookup and
assign a label, then all future routes in the network can “cheat” by doing exact
match “switching” based on a label. This would reduce load on the core
routers, where high-performance was the most difficult to achieve, and
distribute the routing lookups across lower speed edge routers.
• In a traditional IP network:
* Each router performs an IP lookup (“routing”), determines a next-hop based
on its routing table, and forwards the packet to that next-hop.
* Rinse and repeat for every router, each making its own independent routing
decisions, until the final destination is reached.
MPLS
• MPLS does “label switching” instead:
* The first device does a routing lookup, just like before.
* But instead of finding a next-hop, it finds the final destination router.
* And it finds a pre-determined path from “here” to that final router.
* The router applies a “label” (or “shim”) based on this information.
* Future routers use the label to route the traffic without needing to perform
any additional IP lookups.
* At the final destination router, the label is removed and the packet is
delivered via normal IP routing.
• Therefore in an MPLS network, data packets are assigned labels.
Packet-forwarding decisions are made solely on the contents of this
label, without the need to examine the packet itself.