Logical Addreessing CN

Download as pdf or txt
Download as pdf or txt
You are on page 1of 100

Logical Addressing

• The network layer is the third layer (from bottom) in the OSI Model.
• The network layer is concerned with the delivery of a packet across
multiple networks (responsible for host-to-host delivery).
• The network layer is considered the backbone of the OSI Model.
• It selects and manages the best logical path for data transfer between
nodes. This layer contains hardware devices such as routers, bridges,
firewalls, and switches, but it actually creates a logical image of the
most efficient communication route and implements it with a physical
medium.
• Network layer protocols exist in every host or router. The router
examines the header fields of all the IP packets that pass through it.
• In the OSI model, the network layer responds to requests from the
layer above it (transport layer) and issues requests to the layer below it
(data link layer).
• Responsibilities of Network Layer:
• Packet forwarding/Routing of packets: Relaying of data packets from one
network segment to another by nodes in a computer network
• Connectionless communication(IP): A data transmission method used in
packet-switched networks in which each data unit is separately addressed and
routed based on information carried by it
• Fragmentation of data packets: Splitting of data packets that are too large to
be transmitted on the network
Datagram
• Packets in IP layer are called datagrams.
• A datagram has two parts namely the header and data. The length of
datagram is not fixed it varies from 20 bytes to 65535 bytes .
• The length of header is 20 to 60 bytes. The information necessary for
the routing and delivery of the datagram has been stored in the header.
• The other part of the datagram is the data field which is of variable
length.
IPv4
• IPv4 is a connectionless protocol used for packet-switched networks. It operates on a best effort
delivery model, in which neither delivery is guaranteed, nor proper sequencing or avoidance of
duplicate delivery is assured.
• Internet Protocol Version 4 (IPv4) is the fourth revision of the Internet Protocol and a widely used
protocol in data communication over different kinds of networks. IPv4 is a connectionless protocol
used in packet-switched layer networks, such as Ethernet.
• It provides a logical connection between network devices by providing identification for each
device. There are many ways to configure IPv4 with all kinds of devices – including manual and
automatic configurations – depending on the network type.
• IPv4 uses 32-bit addresses for Ethernet communication in five classes: A, B, C, D and E. Classes
A, B and C have a different bit length for addressing the network host. Class D addresses are
reserved for military purposes, while class E addresses are reserved for future use.
• IPv4 uses 32-bit (4 byte) addressing, which gives 232 addresses. IPv4 addresses are written in the
dot-decimal notation, which comprises of four octets of the address expressed individually in
decimal and separated by periods, for instance, 192.168.1.5.
IPv4 HEADER
• Version Number. The 4-bit version number (VER) field defines the version of the IPv4 protocol,
which, obviously, has the value of 4.
• Header Length.
• Header length is a 4 bit field that contains the length of the IP header.
• It helps in knowing from where the actual data begins.
Minimum And Maximum Header Length-
• The initial 5 rows of the IP header are always used.
• So, minimum length of IP header = 5 x 4 bytes = 20 bytes.
• The size of Options field can go up to 40 bytes.
• So, maximum length of IP header = 20 bytes + 40 bytes = 60 bytes.
Concept of Scaling Factor-
• Header length is a 4 bit field.
• So, the range of decimal values that can be represented is [0, 15].
• But the range of header length is [20, 60].
• So, to represent the header length, we use a scaling factor of 4.
In general,
Header length = Header length field value x 4 bytes
Examples-
• If header length field contains decimal value 5 (represented as 0101), then-
Header length = 5 x 4 = 20 bytes
• If header length field contains decimal value 10 (represented as 1010), then-
Header length = 10 x 4 = 40 bytes
• If header length field contains decimal value 15 (represented as 1111), then-
Header length = 15 x 4 = 60 bytes

Question-
In an IPv4 packet, the value of HLEN is 1000 in binary. How many
bytes of options are being carried by this packet?
• Service Type. Differentiated services (DiffServ) is 8-bit field its job is to define the class of the
datagram for quality of service (QoS).
• Total Length. This 16-bit field defines the total length (header plus data) of the IP datagram in
bytes. A 16-bit number can define a total length of up to 65,535 (when all bits are 1s). However,
the size of the datagram is normally much less than this. This field helps the receiving device to
know when the packet has completely arrived. To find the length of the data coming from the
upper layer, subtract the header length from the total length. The header length can be found by
multiplying the value in the HLEN field by 4.
Length of data = total length - (HLEN) * 4
• Identification, Flags, and Fragmentation Offset. These three fields are related to the
fragmentation of the IP datagram when the size of the datagram is larger than the underlying
network can carry.
• Time-to-live. Due to some malfunctioning of routing protocols a datagram may be circulating in
the Internet, visiting some networks over and over without reaching the destination. This may
create extra traffic in the Internet. The time-to-live (TTL) field is used to control the maximum
number of hops (routers) visited by the datagram. When a source host sends the datagram, it stores
a number in this field. This value is approximately two times the maximum number of routers
between any two hosts. Each router that processes the datagram decrements this number by one. If
this value, after being decremented, is zero, the router discards the datagram.
• Protocol. In TCP/IP, the data section of a packet, called the payload, carries the whole packet from another
protocol. A datagram, for example, can carry a packet belonging to any transport-layer protocol such as UDP
or TCP. A datagram can also carry a packet from other protocols that directly use the service of the IP, such as
some routing protocols or some auxiliary protocols. The Internet authority has given any protocol that uses
the service of IP a unique 8-bit number which is inserted in the protocol field. When the payload is
encapsulated in a datagram at the source IP, the corresponding protocol number is inserted in this field; when
the datagram arrives at the destination, the value of this field helps to define to which protocol the payload
should be delivered. In other words, this field provides multiplexing at the source and demultiplexing at the
destination.
• Header checksum. IP is not a reliable protocol; it does not check whether the payload carried by a datagram
is corrupted during the transmission. IP puts the burden of error checking of the payload on the protocol that
owns the payload, such as UDP or TCP. The datagram header, however, is added by IP, and its error-checking
is the responsibility of IP. Errors in the IP header can be a disaster. For example, if the destination IP address
is corrupted, the packet can be delivered to the wrong host. If the protocol field is corrupted, the payload may
be delivered to the wrong protocol. If the fields related to the fragmentation are corrupted, the datagram
cannot be reassembled correctly at the destination, and so on. For these reasons, IP adds a header checksum
field to check the header, but not the payload. We need to remember that, since the value of some fields, such
as TTL, which are related to fragmentation and options, may change from router to router, the checksum
needs to be recalculated at each router.
• Source and Destination Addresses. These 32-bit source and destination address fields define the IP address of
the source and destination respectively. The source host should know its IP address. The destination IP
address is either known by the protocol that uses the service of IP or is provided by the DNS.
• Options. A datagram header can have up to 40 bytes of options. Options can be used for network
testing and debugging. Although options are not a required part of the IP header, option processing
is required of the IP software. This means that all implementations must be able to handle options
if they are present in the header. The existence of options in a header creates some burden on the
datagram handling; some options can be changed by routers, which forces each router to
recalculate the header checksum.

• Payload. Payload, or data, is the main reason for creating a datagram. Payload is the packet coming
from other protocols that use the service of IP. Comparing a datagram to a postal package, payload
is the content of the package; the header is only the information written on the package.
Question1
An IPv4 packet has arrived with the first 8 bits as shown: 01000010 The receiver discards the packet. Why?
Question2
In an IPv4 packet, the value of HLEN is 5, and the value of the total length field is Ox0028. How many bytes of data
are being carried by this packet?
Question3
An IPv4 packet has arrived with the first few hexadecimal digits as shown. Ox45000028000100000102 ...
How many hops can this packet travel before being dropped? The data belong to what upper-layer protocol?
Sol. To find the time-to-live field, we skip 8 bytes (16 hexadecimal digits). The time-to-live field is the ninth byte,
which is 01. This means the packet can travel only one hop. The protocol field is the next byte (02), which means that
the upper-layer protocol is IGMP.
Protocol values
Value Protocol
1 ICMP
2 IGMP
6 TCP
17 UDP
89 OSPF
IP Header Checksum Example
let IP header from an IP packet received at destination :
4500 003c 1c46 4000 4006 b1e6 ac10 0a63 ac10 0a0c
• 45’ corresponds to the first two fields in the header ie ‘4’ corresponds to the IP version and ‘5’ corresponds to
the header length. Since header length is described in 4 byte words so actual header length comes out to be
5×4=20 bytes.
• ’00’ corresponds to TOS or the type of service. This value of TOS indicated normal operation.
• ‘003c’ corresponds to total length field of IP header. So in this case the total length of IP packet is 60.
• ‘1c46’ corresponds to the identification field.
• ‘4000’ can be divided into two bytes. These two bytes (divided into 3 bits and 13 bits respectively) correspond
to the flags and fragment offset of IP header fields.
• ‘4006’ can be divided into ’40’ and ’06’. The first byte ’40’ corresponds to the TTL field and the byte ’06’
corresponds to the protocol field of the IP header. ’06’ indicates that the protocol is TCP.
• ‘b1e6’ corresponds to the checksum which is set at the source end (which sent the packet). Please note
that as already discussed this field will be set to zero while computing the checksum at destination end.
• The next set of bytes ‘ac10’ to ‘0a0c’ correspond to the source IP address and the destination IP address in the
IP header.
Maximum Transmission Unit
• Maximum size of IP datagram is 65535, but the data link layer protocol generally
imposes a limit that is much smaller
• Example:
• Ethernet frames have a maximum payload of 1500 bytes
→ IP datagrams encapsulated in Ethernet frame cannot be longer than 1500
bytes

• The limit on the maximum IP datagram size, imposed by the data link protocol is
called maximum transmission unit (MTU)

• MTUs for various data link protocols:


Ethernet: 1500 FDDI: 4352
802.3: 1492 ATM AAL5: 9180
802.5: 4464 PPP: negotiated

14
IP Fragmentation
• What if the size of an IP datagram exceeds the MTU?
IP datagram is fragmented into smaller units.

• What if the route contains networks with different MTUs?

Ethernet
FDDI
Ring
Host A Router Host B
MTUs: FDDI: 4352 Ethernet: 1500

• Fragmentation:
• IP router splits the datagram into several datagram
• Fragments are reassembled at receiver

15
Where is Fragmentation done?
• Fragmentation can be done at the sender or at intermediate routers
• The same datagram can be fragmented several times.
• Reassembly of original datagram is only done at destination hosts !!

IP datagram H Fragment 2 H2 Fragment 1 H1

Router

16
Fields of the IP Header Fragmentation
• Identification (16 bits): Unique identification of a datagram from a
host. Incremented whenever a datagram is transmitted

• Flags (3 bits):
• First bit is always set to 0
• DF bit (Do not fragment)
• MF bit (More fragments)

17
What’s involved in Fragmentation?
• The following fields in the IP header are involved:

header
version
length
DS ECN total length (in bytes)
DM
Identification 0 Fragment offset
F F
time-to-live (TTL) protocol header checksum

Identification When a datagram is fragmented, the identification is the same in


all fragments
Flags
DF bit is set: 1 Datagram cannot be fragmented and must be discarded if MTU is
too small
MF bit set: 1 This datagram is part of a fragment, and an additional fragment
follows this one 18
What’s involved in Fragmentation?
• The following fields in the IP header are involved:
header
version
length
DS ECN total length (in bytes)
DM
Identification 0 Fragment offset
F F
time-to-live (TTL) protocol header checksum

Fragment offset Offset of the payload of the current fragment in the original
datagram (number of bytes a head from current fragment)

Total length Total length of the current fragment

19
Question: A datagram of 3000 byte (20 byte of IP header + 2980 bytes of IP payload)
reached at the router and must be forwarded to link with MTU of 500 bytes how many
fragments will generate and also write MF , offset, total length value for all.

Total fragment = Total payload to transfer/ Payload in each fragment


Total fragment = 2980 / 480 = 7
Total length of payload = 480+480+480+480+480+480+100 = 2980.
More Fragments (MF)
MF value may be 0 or 1.
When MF bit value is 0 then It tells the receiver that the current
datagram-fragment is the last fragment, and no more segment will
appear of same datagram.
When MF bit value is 1 then it tells more fragments are still to come
after this fragment.
Fragment Offset
It uses a scaling factor of 8. Fragment offset can be calculated by using
the following formula
Fragment offset for a given fragmented IP datagram = Number of
data (payload) bytes ahead of it / 8
Example of Fragmentation
A datagram with size 2400 bytes must be fragmented according to an MTU limit of 1000 bytes

Header length: 20 Header length: 20 Header length: 20 Header length: 20


Total length: 2400 Total length: 448 Total length: 996 Total length: 996
Identification: 0xa428 Identification: 0xa428 Identification: 0xa428 Identification: 0xa428
DF flag: 0 DF flag: 0 DF flag: 0 DF flag: 0
MF flag: 0 MF flag: 0 MF flag: 1 MF flag: 1
Fragment offset: 0 Fragment offset: 244 Fragment offset: 122 fragment offset: 0

IP datagram Fragment 3 Fragment 2 Fragment 1

MTU: 4000 MTU: 1000


Router

22
Determining the length of fragments
• To determine the size of the fragments we recall that, since there are only 13
bits available for the fragment offset, the offset is given as a multiple of
eight bytes. As a result, the first and second fragment have a size of 996
bytes (and not 1000 bytes). This number is chosen since 976 is the largest
number smaller than 1000–20= 980 that is divisible by eight. The payload
for the first and second fragments is 976 bytes long, with bytes 0 through
975 of the original IP payload in the first fragment, and bytes 976 through
1951 in the second fragment. The payload of the third fragment has the
remaining 428 bytes, from byte 1952 through 2379. With these
considerations, we can determine the values of the fragment offset, which
are 0, 976 / 8 = 122, and 1952 / 8 = 244, respectively, for the first, second
and third fragment.
23
Q. Draw IPv4 datagram. An IPv4 datagram has arrived with
the following information in the header (in hexadecimal):
Ox45 00 00 54 00 03 58 50 20 06 00 00 7C 4E 03 02 B4 OE OF
02
a. Is the packet corrupted?
b. Are there any options?
c. Is the packet fragmented?
d. What is the size of the data?
e. How many more routers can the packet travel to?
f. What is the identification number of the packet?
g. What is the type of service?
19-2 IPv6 ADDRESSES

Despite all short-term solutions, address depletion is


still a long-term problem for the Internet. This and other
problems in the IP protocol itself have been the
motivation for IPv6.

Topics discussed in this section:


Structure
Address Space
Note

An IPv6 address is 128 bits long.


Figure 19.14 IPv6 address in binary and hexadecimal colon notation
Figure 19.15 Abbreviated IPv6 addresses
Example 19.11

Expand the address 0:15::1:12:1213 to its original.

Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find
how many 0s we need to replace the double colon.

This means that the original address is.


Table 19.5 Type prefixes for IPv6 addresses
Table 19.5 Type prefixes for IPv6 addresses (continued)
Figure 19.16 Prefixes for provider-based unicast address
Figure 19.17 Multicast address in IPv6
Figure 19.18 Reserved addresses in IPv6
Figure 19.19 Local addresses in IPv6
IPv6 HEADER
Each packet is composed of a base header followed by the payload. The base header occupies 40
bytes, whereas payload can be up to 65,535 bytes of information. The description of fields follows.
• Version. The 4-bit version field defines the version number of the IP. For IPv6, the value is 6.
• Traffic class. The 8-bit traffic class field is used to distinguish different payloads with different
delivery requirements. It replaces the type-of-service field in IPv4.
• Flow label. The flow label is a 20-bit field that is designed to provide special handling for a
particular flow of data.
• Payload length. The 2-byte payload length field defines the length of the IP datagram excluding
the header. Note that IPv4 defines two fields related to the length: header length and total length. In
IPv6, the length of the base header is fixed (40 bytes); only the length of the payload needs to be
defined.
• Next header. The next header is an 8-bit field defining the type of the first extension header (if
present) or the type of the data that follows the base header in the datagram. This field is similar to
the protocol field in IPv4.
• Hop limit. The 8-bit hop limit field serves the same purpose as the TTL field in IPv4.
• Source and destination addresses. The source address field is a 16-byte (128-bit) Internet address
that identifies the original source of the datagram. The destination address field is a 16-byte (128-
bit) Internet address that identifies the destination of the datagram.
• Payload. Compared to IPv4, the payload field in IPv6 has a different format and meaning.
• The payload in IPv6 means a combination of zero or more extension headers (options) followed by
the data from other protocols (UDP, TCP, and so on). In IPv6, options, which are part of the header
in IPv4, are designed as extension headers. The payload can have as many extension headers as
required by the situation.
• Each extension header has two mandatory fields, next header and the length, followed by
information related to the particular option. Note that each next header field value (code) defines
the type of the next header (hop-by-hop option, source routing option, . . .); the last next header
field defines the protocol (UDP, TCP, . . .) that is carried by the datagram.
IPv4 IPv6

IPv4 addresses are 32 bit length. IPv6 addresses are 128 bit length.

IPv4 addresses are binary numbers represented in decimals. IPv6 addresses are binary numbers represented in hexadecimals.

IPSec support is only optional. Inbuilt IPSec support.

Fragmentation is done by sender and forwarding routers. Fragmentation is done only by sender.

Packet flow identification is available within the IPv6


No packet flow identification.
header using the Flow Label field.
Checksum field is available in IPv4 header No checksum field in IPv6 header.
Options fields are available in IPv4 header. No option fields, but IPv6 Extension headers are available.
Address Resolution Protocol (ARP) is available to map IPv4 Address Resolution Protocol (ARP) is replaced with a function
addresses to MAC addresses. of Neighbor Discovery Protocol (NDP).
Internet Group Management Protocol (IGMP) is used to manage IGMP is replaced with Multicast Listener Discovery (MLD)
multicast group membership. messages.
Broadcast messages are not available. Instead a link-local scope
Broadcast messages are available. "All nodes" multicast IPv6 address (FF02::1) is used for
broadcast similar functionality.

Manual configuration (Static) of IPv4 addresses or DHCP


Auto-configuration of addresses is available.
(Dynamic configuration) is required to configure IPv4 addresses.
• IPv4 Advantages • IPv6 Advantages:
• Connectionless Protocol and Best effort based. • No more NAT (Network Address Translation)
• Addresses are easier to remember. • Auto-configuration
• Existing networks are already using it. • No more private address collisions
• Classful and classless addressing. • Better multicast routing
• Millions of addresses are wasted. • Simpler header format
• Planning for excessive growth was not foreseen, • Simplified, more efficient routing
addresses are running out
• Built-in authentication and privacy support
• Flexible options and extensions
• Easier administration (say good-bye to DHCP)
• Large address space.
• Enhanced QoS (Quality of service).
• Efficient routing
• Built in security.
• Larger addresses harder to remember.
• Transition takes time and is not always smooth.
• Not always usable some machines have to be replaced.
Why IPv6? IPv4 IPv6
IPv6 has more 4.3 billion addresses 340 trillion trillion trillion addresses
addresses
Networks must be configured manually or with IPv6 networks provide autoconfiguration
IPv6 networks are
DHCP. IPv4 has had many overlays to handle capabilities. They are simpler, flatter and more
easier and cheaper to
Internet growth, which demand increasing manageable for large installations.
manage
maintenance efforts.
Widespread use of NAT devices means that a Direct addressing is possible due to vast address
IPv6 restores end-to- single NAT address can mask thousands of non- space – the need for network address translation
end transparency routable addresses, making end-to-end integrity devices is effectively eliminated.
unachievable.
Security is dependent on applications – IPv4 was IPSEC is built into the IPv6 protocol, usable with
IPv6 has improved
not designed with security in mind. a suitable key infrastructure.
security features
Relatively constrained network topologies restrict IPv6 provides interoperability and mobility
IPv6 has improved mobility and interoperability capabilities in the capabilities which are already widely embedded
mobility capabilities IPv4 Internet. in network devices.
IPv4 was designed as a transport and Given the numbers of addresses, scalability and
IPv6 encourages communications medium, and increasingly any flexibility of IPv6, its potential for triggering
innovation work on IPv4 is to find ways around the innovation and assisting collaboration is
constraints. unbounded.
IPv4 ADDRESSES

An IPv4 address is a 32-bit address that uniquely and


universally defines the connection of a device (for
example, a computer or a router) to the Internet.
Note

An IPv4 address is 32 bits long.


Note

The IPv4 addresses are unique


and universal.

Note: The IP address is the address of connection not the host or


the router
Note

The address space of IPv4 is


232 or 4,294,967,296.
Three different notations in IPv4 addressing

Note: Each hexadecimal digit is equivalent to 4 bits


Hierarchy in addressing
• A 32-bit IPv4 address is also hierarchical but divided only 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 node (connection of a device to the Internet).
• The prefix length is n bits and the suffix length is (32 - n) bits. A prefix can be fixed length or
variable length. The network identifier in the IPv4 was first designed as a fixed-length prefix. This
scheme, which is now obsolete, is referred to as classful addressing. The new scheme, which is
referred to as classless addressing, uses a variable-length network prefix.
Change the following IPv4 addresses from binary
notation to dotted-decimal notation.
Change the following IPv4 addresses from binary
notation to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent
decimal number and add dots for separation.
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.

Solution
We replace each decimal number with its binary
equivalent.
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 numbers.
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.
Note
In classful addressing, the address
space is divided into five classes:
A, B, C, D, and E.

To accommodate both small and large networks, three fixed length prefixes were
designed instead of one (n=8,n=16 and n=24)

Address Space : 4,294,967,296


class A – 50% class B – 25% class C – 12.5% Class D 6.25% class E – 6.25%
Finding the classes in binary and dotted-decimal notation
Example 19.4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

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.
Table 19.1 Number of blocks and block size in classful IPv4 addressing

Note

In classful addressing, a large part of the


available addresses were wasted.
Default Mask
An address mask determines which portion of an IP address identifies
the network and which portion identifies the host. Like IP address the
mask is represented by four octets. If the given bit of the mask is 1, the
corresponding bit of the IP address is in the network portion of the
address and if a given bit of the mask is 0 the corresponding bit of the IP
address is in the host portion.
Classless Inter-Domain Routing
Table 19.2 Default masks for classful addressing
Note

Classful addressing, which is almost


obsolete, is replaced with classless
addressing.
Restriction
To simplify the handling of addresses, the Internet authorities impose three
restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one after another.
2. The number of addresses in a block must be a power of 2 (1, 2, 4, 8, ... ).
3. The first address must be evenly divisible by the number of addresses.
Example 19.5

Figure 19.3 shows a block of addresses, in both binary and dotted-


decimal notation, granted to a small business that needs 16
addresses.

We can see that the restrictions are applied to this block. The
addresses are contiguous. The number of addresses is a power of
2 (16 = 24), and the first address is divisible by 16. The first
address, when converted to a decimal number, is 3,440,387,360,
which when divided by 16 results in 215,024,210.
Figure 19.3 A block of 16 addresses granted to a small organization
Note

In IPv4 addressing, a block of


addresses can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.
Note

The first address in the block can be


found by setting the rightmost
32 − n bits to 0s.
Example 19.6

A block of addresses is granted to a small organization. We know that


one of the addresses is 205.16.37.39/28. What is the first address in
the block?

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.
This is actually the block shown in Figure 19.3.
Note

The last address in the block can be


found by setting the rightmost
32 − n bits to 1s.
Example 19.7

Find the last address for the block in Example 19.6.

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.16.37.47
This is actually the block shown in Figure 19.3.
Note

The number of addresses in the block


can be found by using the formula
232−n.
Example 19.8

Find the number of addresses in Example 19.6.

Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
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 (or
8-digit hexadecimal) number. This is particularly useful when we
are writing a program to find these pieces of information. In
Example 19.5 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
c. The number of addresses.
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.
Example 19.9 (continued)

b. The last address can be found by ORing the given


addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; the result is 1 otherwise. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.

c. The number of addresses in the block N = NOT(Mask) +1


Note

The first address in a block is


normally not assigned to any device;
it is used as the network address that
represents the organization
to the rest of the world.
Subnetting in IP
• All the hosts in a network must have the same network number but
this property of IP addressing can be problematic as the network size
increases.
• The solution of this problem is that the network is split into several
smaller networks internally but acts like a single network to the
outside world.
• The smaller parts of the network are called subnets.
Question: Why do we use subnet mask? Perform the subnetting of the
following IP address 160.111.x.x original subnet mask 255.255.0.0
amount of subnets 6.
Lan can be split the 16 bit host number into a 6 bit subnet number and
10 bit host number

6 bits 10 bits

10 Network Subnet Host


1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0
32bits

Due to this split it is possible to connect 62 LANs (0 and 1 are reserved)


and each one can contain up to 1022 hosts.
Number of Subnets
• The number of 1’s in the subnet mask is more than the
number of 1’s in the corresponding default mask.
• In Subnet mask we change some of the leftmost 0s in the
default mask to make the subnet mask.
• The number of subnets is determined by the number of
extra 1s .for 3 extra 1s the number of subnets will be 23 =8
for n extra 1s the number of subnets is 2n.
Exercise1:
A router inside an organisation receives the same packet
with the destination address 190.240.34.95. if the subnet
mask is /19 find the subnet address.
Sol.
Subnet Mask : 11111111.11111111.11100000.00000000
Address : 11000010.11110000.00100010.01011111
After ANDing
Subnet Address: 11000000.11110000.00100000.00000000
190.240.32.0
Exercise2: If a class B network on the Internet has a subnet
mask of 255.255.248.0, what is the maximum number of
hosts per subnet?
• The binary representation of subnet mask is
11111111.11111111.11111000.00000000. There are 21 bits set
in subnet. So 11 (32-21) bits are left for host ids. Total
possible values of host ids is 2^11 = 2048. Out of these 2048
values, 2 addresses are reserved. The address with all bits as
1 is reserved as broadcast address and address with all host id
bits as 0 is used as network address of subnet.
• In general, the number of addresses usable for addressing
specific hosts in each network is always 2^N – 2 where N is
the number of bits for host id.
Designing Subnetting
Assume the total number of addresses granted to the organization is N
the prefix length is n , the assigned number of addresses to each sub
network is Nsub and the prefix length of each subnetwork is nsub
Following steps need to be carefully followed :
❑ The number of addresses in each subnetwork should be a power of 2.
❑ The prefix length for each subnetwork should be found using the
following formula:
nsub = 32 − log2Nsub
❑The starting address in each subnetwork should be divisible by the
number of addresses in that subnetwork. This can be achieved if we first
assign addresses to larger subnetworks
first address = (prefix in decimal) × 232 − n = (prefix in decimal) × N.
Example: An organization is granted a block of addresses with the beginning address
14.24.74.0/24. The organization needs to have 3 subblocks of addresses to use in its
three subnets: one subblock of 10 addresses, one subblock of 60 addresses, and one
subblock of 120 addresses. Design the subblocks.
Exercise: Consider an address block 121.37.10.64 /26. Find the first and
last addresses for each subnet, if the number of equal sized subnets
required is as given in the input. Number of subnets required = 4
Sol.
Subnet-1:
First Address: 121.37.10.64 /28
Last Address: 121.37.10.79 /28
Subnet-2:
First Address: 121.37.10.80 /28
Last Address: 121.37.10.95 /28
Subnet-3:
First Address: 121.37.10.96 /28
Last Address: 121.37.10.111 /28
Subnet-4:
First Address: 121.37.10.112 /28
Last Address: 121.37.10.127 /28
Exercise: The IP network 200.198.160.50/27. Design the subnets and find
network address, broadcast address, first and last host address, number of
hosts in this subnet.
• The given IP network is 200.198.160.50/27.

• To design the subnets, we need to determine the subnet mask from the given
prefix length of 27. The subnet mask can be obtained by setting the first 27
bits to 1 and the remaining bits to 0. In binary, this is:

• 11111111.11111111.11111111.11100000

• Converting this binary subnet mask to decimal gives us 255.255.255.224.

• The next step is to divide the network into subnets. Since we have a /27
prefix length, we can borrow 3 bits from the host portion to create subnets.
This gives us 2^3 = 8 subnets.
• To find the network address of each subnet, we can increment the host portion of the
original network address by the number of hosts per subnet (which is 2^(32-27)-2 =
30).
• Subnet 1: Network address = 200.198.160.0, Broadcast address = 200.198.160.31,
First host = 200.198.160.1, Last host = 200.198.160.30, Number of hosts = 30
• Subnet 2: Network address = 200.198.160.32, Broadcast address = 200.198.160.63,
First host = 200.198.160.33, Last host = 200.198.160.62, Number of hosts = 30
• Subnet 3: Network address = 200.198.160.64, Broadcast address = 200.198.160.95,
First host = 200.198.160.65, Last host = 200.198.160.94, Number of hosts = 30
• Subnet 4: Network address = 200.198.160.96, Broadcast address = 200.198.160.127,
First host = 200.198.160.97, Last host = 200.198.160.126, Number of hosts = 30
• Subnet 5: Network address = 200.198.160.128, Broadcast address = 200.198.160.159,
First host = 200.198.160.129, Last host = 200.198.160.158, Number of hosts = 30
• Subnet 6: Network address = 200.198.160.160, Broadcast address = 200.198.160.191,
First host = 200.198.160.161, Last host = 200.198.160.190, Number of hosts = 30
• Subnet 7: Network address = 200.198.160.192, Broadcast address = 200.198.160.223,
First host = 200.198.160.193, Last host = 200.198.160.222, Number of hosts = 30
• Subnet 8: Network address = 200.198.160.224, Broadcast address = 200.198.160.255,
First host = 200.198.160.225, Last host = 200.198.160.254, Number of hosts = 30
As an example, suppose an organization is given the block 17.12.14.0/26, which
contains 64 addresses. The organization has three offices and needs to divide
the addresses into three subblocks of 32, 16, and 16 addresses. We can find the
new masks by using the following arguments:

We can find the new masks by using the following arguments:


1. Suppose the mask for the first subnet is n1, then 232- n1 must be 32, which
means that n1 =27.
2. Suppose the mask for the second subnet is n2, then 232- n2 must be 16, which
means that n2 = 28.
3. Suppose the mask for the third subnet is n3, then 232- n3 must be 16, which
means that n3 =28.
This means that we have masks 27, 28, 28 with the organization mask being
26. Figure 19.7 shows one configuration for the above scenario.
Figure 19.7 Configuration and addresses in a subnetted network
Figure 19.8 Three-level hierarchy in an IPv4 address
Example 19.10

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.
Example 19.10 (continued)

Solution
Figure 19.9 shows the situation.
Group 1
For this group, each customer needs 256 addresses. This
means that 8 (log2 256) bits are needed to define each host.
The prefix length is then 32 − 8 = 24. The addresses are
Example 19.10 (continued)

Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each
host. The prefix length is then 32 − 7 = 25. The addresses
are
Example 19.10 (continued)
Group 3
For this group, each customer needs 64 addresses. This
means that 6 (log264) 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
Number of available addresses: 24,576
Figure 19.9 An example of address allocation and distribution by an ISP
Supernetting
• 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 a
Supernetwork or Supernet.
• Why supernetting ?
The routing table contains the entry of a subnet mask for every network.
If there are lots of small networks then the size of the routing table
increases. When the router has a big routing table then it takes a lot of
time for the router to process the routing table. Supernetting is used to
reduce the size of the IP routing table to improve network routing
efficiency.
How does supernetting work?
All the networks are not suitable for aggregation. There are some rules
according to which the network can be aggregated. For any network to
be aggregated it should follow three rules.
1.Contiguous : All the networks should be contiguous.
2.Same size: All the networks should be of the same size and also a
power of 2 i.e. 2^n.
3.Divisibility: The first network ID should be divisible by the size of
the block.
Example: Suppose we have four small networks with network ID
as 201.1.0.0, 201.1.1.0, 201.1.2.0, 201.1.3.0.
Supernet Mask is a 32-bit number where all the fixed bits of the network
are represented by 1 and the variable part is represented by 0.
The routing table at the router 2 is now reduced and contains only one
entry for all four networks. But, the router 1 needs a routing table which
should contain all the four entries because it should know where to
forward the packet next.

The routing table at router 2:


Private IP addresses are the ip address which are used on only local
networks. Private IP ranges cannot be used on Internet. They are local ip
addresses which can be used millions of times in different local networks.
These addresses do not need to be unique in the world.

Prefix First Address Last Address Number of


Addresses
24
10.0.0.0/8 10.0.0.0 10.255.255.255 16,777,216 (2 )

20
172.16.0.0/12 172.16.0.0 172.31.255.255 1,048,576 (2 )
16
192.168.0.0/16 192.168.0.0 192.168.255.255 65,536 (2 )
Network Address Translation (NAT)
• 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.
• NAT generally operates on router or firewall.
Figure 19.11 Addresses in a NAT

Table 19.4 Five-column translation table

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy