0% found this document useful (0 votes)
63 views

CH4 Hellow

The document discusses IP addressing and subnetting. It provides examples of converting between binary and dotted-decimal IP address notation. It defines address classes, and describes how to determine the network address from a given IP address and mask. The document also defines subnetting and classless addressing, and describes calculating values like number of subnets, subnet addresses, and broadcast addresses using subnet masks of varying lengths.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

CH4 Hellow

The document discusses IP addressing and subnetting. It provides examples of converting between binary and dotted-decimal IP address notation. It defines address classes, and describes how to determine the network address from a given IP address and mask. The document also defines subnetting and classless addressing, and describes calculating values like number of subnets, subnet addresses, and broadcast addresses using subnet masks of varying lengths.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 58

Network Layer

Part-ii
Prof. Mohammed Juned
Example 1
Change the following IP addresses from binary notation to dotted-
decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11111001 10011011 11111011 00001111

Solution
We replace each group of 8 bits with its equivalent decimal
number (see Appendix B) and add dots for separation:
a. 129.11.11.239
b. 249.155.251.15
Example 2
Change the following IP addresses from dotted-decimal notation to
binary notation.
a. 111.56.45.78
b. 75.45.34.78

Solution
We replace each decimal number with its binary equivalent
(see Appendix B):

a. 01101111 00111000 00101101 01001110


b. 01001011 00101101 00100010 01001110
Finding the address class
Example 4
Find the class of each address:
a. 227.12.14.87
b. 252.5.15.111
c. 134.11.78.56

Solution
a. The first byte is 227 (between 224 and 239); the class is D.
b. The first byte is 252 (between 240 and 255); the class is E.
c. The first byte is 134 (between 128 and 191); the class is B.
Example

A router outside the organization receives a packet with


destination address 190.240.7.91. Show how it finds the
network address to route the packet.
Solution
The router follows three steps:
1. The router looks at the first byte of the address to find the class. It is class
B.
2. The default mask for class B is 255.255.0.0. The router ANDs this mask
with the address to get 190.240.0.0.
3. The router looks in its routing table to find out how to route the packet to
this destination.
• Classless Addressing
• Classless Inter-Domain Routing (CIDR) is
another name for classless addressing. This
addressing type aids in the more efficient
allocation of IP addresses.
Classless • This technique assigns a block of IP
addresses based on specified conditions
Addressing when the user demands a specific amount of
IP addresses.
• This block is known as a "CIDR block", and
it contains the necessary number of IP
addresses.
• When allocating a block, classless addressing
is concerned with the following three rules.
• Rule 1 − The CIDR block's IP addresses
must all be contiguous.
• Rule 2 − The block size must be a power of
two to be attractive. Furthermore, the block's
size is equal to the number of IP addresses in
the block.
• Rule 3 − The block's first IP address must be
divisible by the block size.
• For example, assume the classless address is 192.168.1.35/27.
• The network component has a bit count of 27, whereas the host
portion has a bit count of 5. (32-27)
• The binary representation of the address is: (00100011 .
11000000 . 10101000 . 00000001).
• (11000000.10101000.00000001.00100000) is the first IP
address (assigns 0 to all host bits), that is, 192.168.1.32
• (11000000.10101000.00000001.00111111) is the most recent IP
address (assigns 1 to all host bits), that is, 192.168.1.63
• The IP address range is 192.168.1.32 to 192.168.1.63.
• Network Address and Mask
• Network address – It identifies a network on internet. Using
this, we can find range of addresses in the network and total
possible number of hosts in the network.
• Mask – It is a 32-bit binary number that gives the network
address in the address block when AND operation is bitwise
applied on the mask and any IP address of the block.
• The default mask in different classes are :
• Class A – 255.0.0.0
• Class B – 255.255.0.0
• Class C – 255.255.255.0
• Example : Given IP address 132.6.17.85 and default
class B mask, find the beginning address (network
address).
• Solution : The default mask is 255.255.0.0, which
means that the only the first 2 bytes are preserved, and
the other 2 bytes are set to 0. Therefore, the network
address is 132.6.0.0.
• Subnetting: Dividing a large block of addresses into several contiguous
sub-blocks and assigning these sub-blocks to different smaller networks is
called subnetting.
• It is a practice that is widely used when classless addressing is done.
• Some values calculated in subnetting :
• 1. Number of subnets : 2^ (Given bits for mask – No. of bits in default
mask)
• 2. Subnet address : AND result of subnet mask and the given IP address
• 3. Broadcast address : By putting the host bits as 1 and retaining the
network bits as in the IP address
• 4. Number of hosts per subnet : 2(32 – Given bits for mask) – 2
• 5. First Host ID : Subnet address + 1 (adding one to the
binary representation of the subnet address)
• 6. Last Host ID : Subnet address + Number of Hosts
• Example : Given IP Address – 172.16.0.0/25, find the
number of subnets and the number of hosts per subnet.
Also, for the first subnet block, find the subnet address,
first host ID, last host ID and broadcast address.
• Solution : This is a class B address. So, no. of subnets =
2(25-16) = 29 = 512.
• No. of hosts per subnet = 2(32-25) – 2 = 27 – 2 = 128 – 2 =
126
• For the first subnet block, we have subnet address =
172.16.0.0,
• first host id = 172.16.0.1, last host id = 172.16.0.126 and
broadcast address = 172.16.0.127
Advantages-

• The two main advantages of subnetting a network are-


• It improves the security.
• The maintenance and administration of subnets is easy.

• Types of Subnetting-
• Subnetting of a network may be carried out in the following
two ways-

1.Fixed Length Subnetting


2.Variable Length Subnetting
• 1. Fixed Length Subnetting-

• Fixed length subnetting also called


as classful subnetting divides the network
into subnets where-
• All the subnets are of same size.
• All the subnets have equal number of hosts.
• All the subnets have same subnet mask.
• 2. Variable Length Subnetting-

• Variable length subnetting also called as classless subnetting divides the


network into subnets where-
• All the subnets are not of same size.
• All the subnets do not have equal number of hosts.
• All the subnets do not have same subnet mask.
• For example, assume the classless address is 192.168.1.35/27.
• The network component has a bit count of 27, whereas the host portion
has a bit count of 5. (32-27)
• The binary representation of the address is: (11000000 . 10101000 .
00000001. 00100011).
• (11000000.10101000.00000001.00100000) is the first IP address
(assigns 0 to all host bits), that is, 192.168.1.32
• (11000000.10101000.00000001.00111111) is the most recent IP address
(assigns 1 to all host bits), that is, 192.168.1.63
• The IP address range is 192.168.1.32 to 192.168.1.63.
• Network Address and Mask
• Network address – It identifies a network on internet. Using this, we can find range of
addresses in the network and total possible number of hosts in the network.
• Mask – It is a 32-bit binary number that gives the network address in the address block
when AND operation is bitwise applied on the mask and any IP address of the block.
• The default mask in different classes are :
• Class A – 255.0.0.0
• Class B – 255.255.0.0
• Class C – 255.255.255.0
• Example : Given IP address 132.6.17.85 and default class B mask, find
the beginning address (network address).
• Solution : The default mask is 255.255.0.0, which means that the only
the first 2 bytes are preserved, and the other 2 bytes are set to 0.
Therefore, the network address is 132.6.0.0.
• Subnetting: Dividing a large block of addresses into several contiguous
sub-blocks and assigning these sub-blocks to different smaller networks
is called subnetting.
• It is a practice that is widely used when classless addressing is done.
• Some values calculated in subnetting :
• 1. Number of subnets : Given bits for mask – No. of bits in default mask
• 2. Subnet address : AND result of subnet mask and the given IP address
• 3. Broadcast address : By putting the host bits as 1 and retaining the
network bits as in the IP address
• 4. Number of hosts per subnet : 2(32 – Given bits for mask) – 2
• 5. First Host ID : Subnet address + 1 (adding one to the binary
representation of the subnet address)
• 6. Last Host ID : Subnet address + Number of Hosts
• Example : Given IP Address – 172.16.0.0/25, find the number of subnets
and the number of hosts per subnet. Also, for the first subnet block, find the
subnet address, first host ID, last host ID and broadcast address.
• Solution : This is a class B address. So, no. of subnets = 2(25-16) = 29 = 512.
• No. of hosts per subnet = 2(32-25) – 2 = 27 – 2 = 128 – 2 = 126
• For the first subnet block, we have subnet address = 172.16.0.0,
• first host id = 172.16.0.1, last host id = 172.16.0.126 and broadcast address
= 172.16.0.127
Advantages-

• The two main advantages of subnetting a network are-


• It improves the security.
• The maintenance and administration of subnets is easy.

• Types of Subnetting-
• Subnetting of a network may be carried out in the following two ways-

1. Fixed Length Subnetting


2. Variable Length Subnetting
• 1. Fixed Length Subnetting-

• Fixed length subnetting also called as classful subnetting divides the


network into subnets where-
• All the subnets are of same size.
• All the subnets have equal number of hosts.
• All the subnets have same subnet mask.
• The number of subnets are power of 2
• 2. Variable Length Subnetting-

• Variable length subnetting also called as classless subnetting divides the


network into subnets where :
• All the subnets are not of same size.
• All the subnets do not have equal number of hosts.
• All the subnets do not have same subnet mask.
• Supernetting is the opposite of Subnetting. In subnetting, a single big
network is divided into multiple smaller subnetworks.
• In Supernetting, multiple networks are combined into a bigger network
termed as a Supernetwork or Supernet.
• Supernetting is mainly used in Route Summarization, where routes to
multiple networks with similar network prefixes are combined into a
single routing entry, with the routing entry pointing to a Super network,
encompassing all the networks.
• 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
• There are some points which should be kept in mind while supernetting:
• All the Networks should be contiguous.
• The block size of every network should be equal and must be in form of
2n.
• First Network id should be exactly divisible by whole size of supernet.
Example 1

An ISP is granted a block of addresses starting with 190.100.0.0/16 (65,536


addresses). The ISP needs to distribute these addresses to three groups of
customers as follows:
a. The first group has 64 customers; each needs 256
addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs 64
addresses.
Design the subblocks and find out how many addresses are still available
after these allocations.

19.27
Solution
Figure shows the situation.

Group 1
For this group, each customer needs 256 addresses. This means
that 8 (2^8) bits are needed to define each host. The prefix
length is then 32 − 8 = 24. The addresses are

19.28
Group 3
For this group, each customer needs 64 addresses. This
means that 6 (2^6) bits are needed to each host. The prefix
length is then 32 − 6 = 26. The addresses are

Number of granted addresses to the ISP: 65,536


Number of allocated addresses by the ISP: 40,960
19.29
Number of available addresses: 24,576
Figure An example of address allocation and distribution by an ISP

19.30
An ISP is granted a block of addresses starting with
188.50.0.0/16. The ISP wants to distribute these blocks to 100
customers as follows.
1.The first group has 30 medium-size businesses; each needs
128 addresses.
2.The second group has 50 small businesses; each needs 64
addresses.
3.The third group has 20 households; each needs 32 addresses
Design the subblocks and give the slash notation for each
subblock. Find out how many addresses are still available after
these allocations.
Note

IPv4 is an unreliable and connectionless


datagram protocol – a best effort
delivery
Best effort means that IPv4 provides no
error control (except for error detection
on the header) or flow control
IPv4 does its best to get a transmission
through to its destination, but with no
guarantees
20.33
IPv4 Datagram Format
• Version (VER): version of the IP protocol. Currently, the
version is 4.
• Header length (HLEN): the total length of the datagram
header in 4-byte words.
• Services: service type or differentiated services (not used
now).
• Total length: total length (header plus data) of the datagram
in bytes.
• Total length of data = total length – header length
IPv4 Datagram
Format
• Checksum: 1’s
compliment checksum
• Source address: is the
IPv4 address of the
source.
• Destination address: is the
IPv4 address of the
source.
20.36
• Table : Protocol values

20.37
Example

An IPv4 packet has arrived with the first 8 bits as shown:


01000010
The receiver discards the packet. Why?

Solution
There is an error in this packet. The 4 leftmost bits (0100)
show the version, which is correct. The next 4 bits (0010) show
an invalid header length (2 × 4 = 8). The minimum number of
bytes in the header must be 20. The packet has been corrupted
in transmission.

20.38
Figure : Maximum transfer unit (MTU)
Table :
MTUs for
some
networks

20.40
Fields Related to Fragmentation
Identification: identifies a datagram originating from the source host. A combination of the
identification and source address must uniquely define a datagram as it leaves the source
node.
• Fragmentation offset is the offset of the data in the original datagram measured in units
of 8 bytes.
• It is use to identify the sequence of fragments in the frame. It generally indicates a
number of data bytes preceding or ahead of the fragment.
Maximum fragment offset possible = (65535 – 20) = 65515
{where 65535 is the maximum size of datagram and 20 is the minimum size of IP
header}
So, we need ceil(log265515) = 16 bits for a fragment offset but the fragment offset field
has only 13 bits. So, to represent efficiently we need to scale down the fragment offset
field by 216/213 = 8 which acts as a scaling factor. Hence, all fragments except the last
fragment should have data in multiples of 8 so that fragment offset ∈ N.
Figure : Flags (3 bits) used in fragmentation

• first bit: reserved (not used)


• second bit: = 1 requires the packet not to be fragmented
drops the packet if it is > MTU

• third bit: =1 more fragmented packets later


=0 the last fragmented packet

20.42
Figure : Fragmentation example
IPv4 Checksum

• IPv4 checksum use the 1’s compliment method (chapter


10)
• Checksum only computes for IP header, not data
• Upper layer has checksum for data portion
• Header always changes in each router
• Header is chunked to 16-bit sections for computing
Figure : Example of checksum calculation in IPv4
IPv6
The network layer protocol in the TCP/IP protocol suite is
currently IPv4. Although IPv4 is well designed, data
communication has evolved since the inception of IPv4 in the
1970s.

IPv4 has some deficiencies that make it unsuitable for the fast-
growing Internet.
IPv6: Advantages
• Larger address space.
• Better header format.
• New options.
• Allowance for extensions.
• Support for resource allocation.
• Support for more security.
Figure : IPv6 datagram header and payload
Figure : Format of an IPv6 datagram

Priority
Protocol
Table : Comparison between IPv4 and IPv6 packet headers
IPv4 IPv6

IPv4 has a 32-bit address length IPv6 has a 128-bit address length

It Supports Manual and DHCP address configuration It supports Auto and renumbering address configuration

In IPv4 end to end, connection integrity is Unachievable In IPv6 end to end, connection integrity is Achievable

Address space of IPv6 is quite large it can produce


It can generate 4.29×109 address space
3.4×1038 address space

The Security feature is dependent on application IPSEC is an inbuilt security feature in the IPv6 protocol

Address representation of IPv4 is in decimal Address Representation of IPv6 is in hexadecimal

Fragmentation performed by Sender and forwarding


In IPv6 fragmentation performed only by the sender
routers

In IPv6 packet flow identification are Available and uses


In IPv4 Packet flow identification is not available
the flow label field in the header

In IPv4 checksum field is available In IPv6 checksum field is not available


• To access the Internet, one public IP address
is needed, but we can use a private IP address
in our private network.
• The idea of NAT is to allow multiple devices
Network to access the Internet through a single public
Address address.
• To achieve this, the translation of a private IP
Translation address to a public IP address is
(NAT) required. Network Address Translation
(NAT) is a process in which one or more
local IP address is translated into one or more
Global IP address and vice versa in order to
provide Internet access to the local hosts.
• Also, it does the translation of port numbers i.e., masks the port
number of the host with another port number, in the packet that will be
routed to the destination.
• It then makes the corresponding entries of IP address and port number
in the NAT table. NAT generally operates on a router or firewall.
• Why mask port numbers ?
• Suppose, in a network, two hosts A and B are connected. Now, both
request for the same destination, on the same port number, say 1000,
on the host side, at the same time.
• If NAT does only translation of IP addresses, then when their packets
will arrive at the NAT, both of their IP addresses would be masked by
the public IP address of the network and sent to the destination.
• Destination will send replies to the public IP address of the router.
• Thus, on receiving a reply, it will be unclear to NAT as to which reply
belongs to which host (because source port numbers for both A and B
are the same). Hence, to avoid such a problem, NAT masks the source
port number as well and makes an entry in the NAT table.
• 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.
• Advantages of NAT –

• NAT conserves legally registered IP addresses.

• It provides privacy as the device’s IP address, sending and receiving the traffic, will be
hidden.

• Eliminates address renumbering when a network evolves.

• Disadvantage of NAT –

• Translation results in switching path delays.

• Certain applications will not function while NAT is enabled.

• Complicates tunnelling protocols such as IPsec.

• Also, the router being a network layer device, should not tamper with port
numbers(transport layer) but it has to do so because of NAT.

You might also like