Chap 1 Network Layer and Protocols
Chap 1 Network Layer and Protocols
Chap 1 Network Layer and Protocols
• An IPv4 address is a 32-bit address used to uniquely identify a host or a router on the Internet.
• IP addresses are globally managed by Internet Assigned Numbers Authority(IANA).
• Address Space:
• An address space is the total number of addresses used by the protocol.
• IPv4 uses 32-bit addresses, which means that the address space is 232 or 4,294,967,296 (more than four
billion)
• Notations:
IPv4 Addressing :Address Space
• Hierarchy in Addressing:
• A 32-bit IPv4 address is divided into two parts.:
• The first part of the address, called the prefix, defines the network;
• the second part of the address, called the suffix, defines the host(node)
• In classful addressing address space is divided into five classes :class A, B, C, D, and E
• In class A, one byte defines the netid (prefix) and three bytes define the hostid (suffix).
• In class B, two bytes define the netid and two bytes define the hostid.
• In class C, three bytes define the netid and one byte defines the hostid.
IPv4 Addressing:Classful Addressing
• The IPv4 address is divided into two parts:
• Network ID
• Host ID
• Classful Addressing
• In classful addressing address space is divided into five classes :class A, B, C, D and E
• Classes A, B, and C are used by the majority of devices on the Internet
• Classes D and E are reserved for multicast and experimental purposes respectively.
• Each of these classes has a valid range of IP addresses.
IPv4 Addressing:Classful Addressing
• Class A :
• IP addresses belonging to class A are assigned to the networks that contain a large number of hosts.
• The network ID is 8 bits long.
• The host ID is 24 bits long.
• The first bit of the first octet in class A is always set to 0. The remaining 7 bits in the first octet are used to
determine network ID. The 24 bits of host ID are used to determine the host in any network
• IP addresses belonging to class A ranges from 0.0.0.0 – 127.255.255.255.
IPv4 Addressing:Classful Addressing
• Class B
• IP address belonging to class B is assigned to networks that range from medium-sized to large-sized
networks.
• The network ID is 16 bits long.
• The host ID is 16 bits long.
• The higher-order bits of the first octet of IP addresses of class B are always set to 10.
• The remaining 14 bits are used to determine the network ID and the 16 bits of host ID are used to
determine the host in a network.
• IP addresses belonging to class B ranges from 128.0.0.0 – 191.255.255.255.
IPv4 Addressing:Classful Addressing
• Class C
• IP addresses belonging to class C are assigned to small-sized networks.
• The network ID is 24 bits long.
• The host ID is 8 bits long.
• The higher-order bits of the first octet of IP addresses of class C is always set to 110.
• The remaining 21 bits are used to determine the network ID.
• The 8 bits of host ID are used to determine the host in any network.
• IP addresses belonging to class C range from 192.0.0.0 – 223.255.255.255.
IPv4 Addressing:Classful Addressing
• Class D
• IP address belonging to class D is reserved for multi-casting.
• The higher-order bits of the first octet of IP addresses belonging to class D is always set to 1110.
• IP addresses belonging to class D range from 224.0.0.0 – 239.255.255.255.
• Class E
• IP addresses belonging to class E are reserved for experimental and research purposes.
• The higher-order bits of the first octet of class E are always set to 1111.
• IP addresses of class E range from 240.0.0.0 – 255.255.255.255
IPv4 Addressing:Classful Addressing
• In classful addressing each class is divided into a fixed number of blocks with each block having a fixed
size as shown in Table.
Actual
Network No. of Blocks or Range of IP Address in
Leading Network Host Block Size or
Class Identifier Max. Dotted decimal Application
Bits Identifier Identifier Bits Max. number of hosts
Bits number of Networks notations
Bits
0.0.0.0 to Unicast(Large
A 0 8 7 27=128 24 224=1,67,77,216
127.255.255.255 organizations)
128.0.0.0 to Unicast(Midsize
B 10 16 14 214=16,384 16 216=65,536
191.255.255.255 organizations)
192.0.0.0 to Unicast(Small
C 110 24 21 221=20,97,152 8 28=256
223.255.255.255 organizations)
224.0.0.0 to
D 1110 - - - - - Multicasting
239.255.255.255
240.0.0.0 to Reserved for future
E 1111 - - - - -
255.255.255.255 use
IPv4 Addressing:Classful Addressing
• Problems with Classful Addressing
• The problem with this classful addressing method is that millions of class A addresses are wasted,
• Thousands of the class B addresses are wasted, whereas,
• The number of addresses available in class C is so small that it cannot satisfy 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.
• Because of these problems, Classful addressing was replaced by Classless Inter-Domain Routing (CIDR)
in 1993.
IPv4 Addressing:Classful Addressing:
• Subnet Mask:
• The purpose of subnet mask is to identify which part of an IP address is network part and which part is
host part.
• Subnet mask is a 32 bit number created by setting network bits to all 1s and setting host bits to all 0s.
• The last column of Table shows the mask in the form /n where n can be 8, 16, or 24 in classful addressing.
• This notation is also called slash notation or Classless Interdomain Routing (CIDR) notation.
IPv4 Addressing:Classful Addressing:
Example: 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 bytes in IP address.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
19.12
IPv4 Addressing:Classful Addressing:
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.
19.13
IPv4 Addressing:Classful Addressing
• Types of Subnetting:
• Fixed Length Subnetting:
• Fixed length subnetting (classful subnetting) divides network into subnets such that:
o All the subnet are of same size
o All the subnet have equal number of hosts
o All the subnet have same subnet mask
192.128.00100000.0/24
192.128.00100001.0/24
192.128.00100010.0/24
192.128.00100011.0/24
192.128.00100000.0/22
192.128.11000000.0/20
192.128.192.0/20 Super network address
IPv4 Addressing : Classless addressing
• In Classless addressing, the whole address space is divided into variable length blocks.
• The prefix in an address defines the block (network); the suffix defines the node (hosts).
• We can have a block of 1 address, 2 addresses, 4 addresses, 8 addresses, and so on.
• Restrictions on classless address blocks:
1. The addresses in block must contiguous , one after another.
2. The number of addresses in a block needs to be a power of 2.
3. The first address must be evenly divisible by the number of addresses.
IPv4 Addressing : Classless addressing
• Prefix Length: Slash Notation
• In classless addressing prefix length is variable.
• We can have a prefix length that ranges from 0 to 32.
• In classless address, the prefix length, n, is added to the address, separated by a slash.
• The notation is informally referred to as slash notation and formally as classless interdomain routing
or CIDR (pronounced cider) strategy
• An address in classless addressing can be represented as shown in Figure 18.20.
IPv4 Addressing: Classless addressing
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
19.29
IPv4 Addressing: Classless addressing
19.30
IPv4 Addressing: Classless addressing
Solution: The number of addresses in the block can be found by using the
formula 232−n
The value of n is 28, which means that number of addresses are= 2 32−28
=24
= 16
19.31
Example 19.9
Another way to find the first address, the last address, and the number of
addresses is to represent the mask as a 32-bit binary number.
In Example 205.16.37.39/28
the /28 can be represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).
Find
a. The first address
b. The last address
19.32
Example 19.9 (continued)
Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
the result is 0 otherwise.
19.33
Example 19.9 (continued)
19.34
IPv4 Addressing : Classless addressing
• Special Addresses: are not assigned to any host in a network and are used for special purposes:
• This-host Address :The only address in the block 0.0.0.0/32 is called the this-host address.
• It is used when host want to know its own IP address then host use this address as source address in packet and send
packet to Bootstrap server(DHCP server) .
• Limited-broadcast Address :The only address in the block 255.255.255.255/32 is called the limited-broadcast
address.
• It is used when host wants to broadcast packet to all devices in a network then host use this address as destination
address in packet and send packet to all devices in a network .
• Loopback Address :The block 127.0.0.0/8 (127.0.0.0-127.255.255.255) is called the loopback address.
• Its used when host wants to send packet to itself.(i.e. host can test its own connection)
• Loopback address 127.0.0.1 used to test network software on your computer
IPv4 Addressing : Classless addressing
• Special Addresses:
• Private Addresses: are used by organizations to create their own intranet.
• Four blocks are assigned as private addresses:
• 10.0.0.0/8(10.0.0.0 to 10.255.255.255)
• 172.16.0.0/12 (172.16.0.0 to 172.31.255.255)
• 192.168.0.0/16(192.168.0.0. to 192.168.255.255)
• 169.254.0.0/16(169.254.0.1 to 169.254.255.255) (Automatic Private IP addressing)
• With Automatic Private IP addressing computer can assign an IP address to itself, in case of DHCP server not
working or not available on a network .
• Multicast Addresses :The block 224.0.0.0/4 (224.0.0.0 to 239.255.255.255) is reserved for multicast addresses.
• Its used when host wants to send packet to group of devices in a network
IPv4 Addressing
Classful Addressing Classless Addressing
In classful addressing address space is divided into five In classless addressing, the whole address space is
classes :class A, B, C, D, and E, each class is divided into divided into variable length blocks.
a fixed length blocks
it allocates IP addresses according to five major classes Its IP address allocation method designed to
such as Class A,B,C,D,E replace the classful addressing
It uses fixed length prefix it uses variable length prefix
It uses fixed length subnet mask it uses variable length subnet mask
Its less effective method of allocating IP addresses Its more effective method of allocating IP addresses
Its less practical. Its more practical.
It does not support Classless Inter-Domain Routing It supports Classless Inter-Domain Routing
(CIDR). (CIDR).
It requires more bandwidth . As a result, it becomes slower It requires less bandwidth. Thus, fast and less
and more expensive as compared to classless addressing. expensive as compared to classful addressing.
IPv4 Addressing
Network Address Translation (NAT)
• Its process used to translates the private IP address to the public IP address and vice versa.
• Due to NAT, the computers in a private network are able to communicate with the computer in the public
network.
• In a connection less service, the source does not makes any connection with the destination.
• source sent a set of packets to destination without establishing connection with destination.
• In connection-less service, there is a no relationship between packets. Packets are sent on the same path or on
different path
Network Layer Protocols
• Internet Protocol version 4 (IPv4) is responsible for packetizing, forwarding, and delivery of a packet at the
network layer.
• The Internet Control Message Protocol version 4 (ICMPv4) helps IPv4 to handle some errors that may occur in
the network-layer delivery.
• The Internet Group Management Protocol (IGMP) is used to help IPv4 in multicasting.
• The Address Resolution Protocol (ARP) is used mapping network-layer addresses to link-layer addresses. (it find
MAC address of device from its IP address.)
• Figure 19.1 shows the positions of these four protocols in the TCP/IP protocol suite.
Internet Protocol(IP)
• IPv4 is an unreliable datagram protocol—a best-effort delivery service.
• The term best-effort means that IPv4 packets can be corrupted, be lost, arrive out of order, or be delayed, and may
create congestion for the network.
• If reliability is important, IPv4 must be paired with a reliable protocol such as TCP.
• An example of best-effort delivery service is the post office.
• The post office does its best to deliver the letters but does not always succeed.
• IPv4 is also a connectionless protocol that uses the datagram approach.
• Datagram approach means that each datagram is handled independently, and each datagram can follow a different
route to the destination.
Internet Protocol(IP) :Datagram format
• Datagram format: Packets used by IP are called datagram
• A datagram is a variable-length packet consisting of two parts: header and payload (data).
• The size of datagram is 20 to 65535 bytes
• The header is same as envelope of letter
• The Header consists information necessary for routing and delivery of packet.
• The size of header is 20 to 60 bytes
Internet Protocol(IP) :Datagram format
• Datagram format fields:
• Version Number(4 bits):it defines the version of the IPv4 protocol, In this case version of IP protocol is 4.
• Header Length(4 bits): it defines the length of IP datagram header.
• The minimum length of header is 20 bytes and maximum length of header is 60 bytes
• Total Length (16-bit) :it defines the total length of IP datagram including header and data.
Total length 216 =65536
Total length = Header length+ payload(data) length.
payload(data) length = Total length – Header length.
Internet Protocol(IP) :Datagram format
• Datagram format fields:
• Service Type(8-bit) : IETF(Internet Engineering Task Force) has changed the interpretation and name of this field.
This field, previously called service type, is now called differentiated service
• TOS bits: is a 4-bit subfield with each bit having a special meaning.
• Each bit can be either 0 or 1
• Only one of the bits can have the value of 1 in each datagram.
Internet Protocol(IP) :Datagram format
• Datagram format fields:
• Differentiated Services: In this interpretation, the first 6 bits make up the codepoint subfield, and the last 2 bits are
not used.
• The codepoint subfield can be used in two different ways:
• When the 3 rightmost bits are 0’s, then 3 leftmost bits are same as the precedence bits in the service type.
• When the 3 rightmost bits are not all 0’s, then 6 codepoint bits defines 64 services
• The first category contains 32 service types; the second and third category contain 16 service types.
• The first category (numbers 0, 2,4, ... ,62) is assigned by the Internet authorities (IETF).
• The second category (3, 7, 11, 15,…. , 63) can be used by local authorities (organizations).
• The third category (1, 5, 9, ….,61) is temporary and can be used for experimental purposes.
Internet Protocol(IP) :Datagram format
• Datagram format fields:
• Identification(16 Bit ):its unique number that identifies set of fragment of single datagram.
• The combination of Identification and IPv4 address uniquely identifies datagram.
• If datagram divided into multiple fragments then all the fragments must have same Identification number.
• Header checksum (16 bit): It consist checksum value for checking errors in the datagram header.
• Source Addresses (32-bit) : it defines the IP address of the source.
• Destination Addresses (32-bit) : it defines the IP address of the destination.
• Source Quench:
• source quench message informs the sender that the network has encountered congestion and the datagram has been
dropped; the source needs to slow down sending more datagrams.
ICMPv4: Error Reporting Messages
• Redirection Message:
• It’s used when the source uses a wrong router to send out its packet then router forwards packet to appropriate router
and sends redirection message to source ,to informs the source to update its routing table.
• The IP address of the default router is sent in the message.
• Parameter Problem :
• When router detects problem in the header of a datagram or some options of header are missing then router sends the
“Parameter Problem” message to source.
ICMPv4: Error Reporting Messages
• Time exceeded message: Time exceeded message informs the source, datagram is discarded due to the
time to live field value reached zero.
ICMPv4: Query Messages
• Query Messages:
• query messages come in pairs: request and reply.
• The echo request and echo reply pair of messages are used by a host to test another host is alive or not.
• The host sends echo request message to another host ,if the another host is alive ,then it responds with an
echo reply message.
• Checksum Testing:
1. The sum of all words (header and data)is calculated.
2. The sum is complemented.
3. If the result obtained in step 2 is 16 0s, the message is accepted ; otherwise, it is rejected.
ICMPv4 : Checksum
• Example:Figure 19.11 shows an example of checksum calculation for a simple echo-request message. We randomly
chose the identifier to be 1 and the sequence number to be 9. The message is divided into 16-bit (2-byte) words. The
words are added and the sum is complemented. Now the sender can put this value in the checksum field.
MOBILE IP
• Mobile IP is the extension of IP protocol.
• Mobile IP allows mobile host to be connected to the Internet at any location.
• Addressing:Mobile IP provides two addresses for a mobile host:
• The mobile host has its original address, called the home address, and a temporary address, called the care-of
address.
• The home address is permanent; it associates the host with its home network,
• The care-of address is temporary. it is associated with the foreign network, the network to which the host moves.
• When a host moves from one network to another, the care-of address changes.
MOBILE IP
• Agents(Routers):
• Home Agent: is a router attached to the home network of the mobile host. The home agent receives the packet from
mobile host and sends it to the foreign agent.
• Foreign agent: is a router attached to the foreign network. The foreign agent receives the packet from home and
sends it to the mobile host.
• The mobile host can also act as a foreign agent.
• When mobile host act as a foreign agent, the care-of address is called a collocated care-of address.
MOBILE IP
• Three Phases: To communicate with a remote host, a mobile host goes through three phases: agent discovery,
registration, and data transfer, as shown in Figure 19.14.
• Agent Discovery:
• A mobile host must discover a home agent
before it leaves its home network.
• A mobile host must also discover a foreign
agent after it has moved to a foreign
network.
• Registration:
• The mobile host must register itself with the
foreign agent.
• The mobile host must register itself with its
home agent. This is normally done by the
foreign agent on behalf of the mobile host.
• Data Transfer:
• A mobile host can communicate with a
remote host.
MOBILE IP
• Data Transfer:
MOBILE IP
• Data Transfer:
• From Remote Host to Home Agent:
• When a remote host wants to send a packet to the mobile host, it uses its address as the source address and the home
address of the mobile host as the destination
• From Home Agent to Foreign Agent:
• After receiving the packet, the home agent sends the packet to the foreign agent, using the tunneling concept.
• The home agent encapsulates the whole IP packet inside another IP packet using its address as the source address
and the foreign agent’s address as the destination address.
• From Foreign Agent to Mobile Host:
• When the foreign agent receives the packet ,it removes the original packet. However, since the destination address is
the home address of the mobile host, the foreign agent consults a registry table to find the care-of address of the
mobile host and Then packet is then sent to the care-of address.
• From Mobile Host to Remote Host:
• When a mobile host wants to send a packet to a remote host , it sends as it does normally.
• The mobile host prepares a packet with its home address as the source, and the address of the remote host as the
destination.
MOBILE IP
• Inefficiency in Mobile IP:
• Communication involving mobile IP can be inefficient.
• The inefficiency can be severe or moderate.
• The severe case is called double crossing or 2X.
• The moderate case is called triangle routing or dog-leg routing
• Double crossing occurs when a remote host communicates with a mobile host that has moved to the same network
as the remote host.
• When the mobile host sends a packet to the remote host, there is no inefficiency.
• But, when the remote host sends a packet to the mobile host, the packet crosses the Internet twice.
MOBILE IP
• Inefficiency in Mobile IP:
• Triangle routing: occurs when the remote host communicates with a mobile host that is not attached to
the same network as the mobile host.
• When the mobile host sends a packet to the remote host, there is no inefficiency.
• But, when the remote host sends a packet to the mobile host, the packet goes from the remote host to
the home agent and then to the mobile host.
• The packet travels the two sides of a triangle, instead of just one side
Virtual Private Network (VPN)
• VPN is a service that creates a secure connection(i.e. VPN Tunnel) between your device and the internet.
• Tunneling is process of putting data packet inside another packet and sending it over internet
• VPN Tunnel is a encrypted connection between your device and VPN Server.
• How Does a VPN Works:
• 1.Install VPN Client software on your computer or laptop.
• 2. VPN Client software encrypt your data using VPN Protocols.
• 3.VPN Client establish VPN tunnel between your device and the internet.
• 4.VPN Client sends encrypted data to VPN server through VPN tunnel.
• VPN Protocol : is a software that allows securely sending and receiving data among two networks.
• Most popular VPN protocols are:
• OpenVPN
• IPsec(Internet Protocol Security)
• L2TP(Layer 2 Tunneling Protocol)
• PPTP(Point to Point Tunneling Protocol)
• SSL(Secure Socket Layer)
• TLS(Transport Layer Security)
• WireGuard Protocol
Virtual Private Network (VPN)
• Types of VPN:
1. Site to Site VPN: It is used to connect multiple networks together.
2. Remote VPN: It is used by individual users to securely access private network.
• Advantages of VPN:
• It provides Anonymity-hiding your identity.
• It provides Privacy-hiding your internet activity.
• It provides access to restricted internet contents.