IP Addresss
IP Addresss
IP Addresss
IP Addresses
Tasniya Ahmed
Lecturer
IIT,NSTU
1
IP Addresses
IP address formats.
2
Class A (24 bits for hosts) 224 - 2* = 16,777,214 maximum hosts
Class B (16 bits for hosts) 216 - 2* = 65,534 maximum hosts
Class C (8 bits for hosts) 28 - 2* = 254 maximum hosts
•Subtracting the network and broadcast reserved address
•Within a given network, two host addresses are reserved for special purpose. The "0" address is assigned a
network address and "255" is assigned to a broadcast address, and they cannot be assigned to a host.3
Subnets
A big network usually spitted into several small parts for internal use but still act like
a single network to the outside world.
A typical campus network might look like fig below, with a main router connected to
an ISP or regional network and numerous Ethernets spread around campus in
different departments. Each of the Ethernets has its own router connected to the main
router (via backbone LAN). In the internet literature, the part of the network (in this
case, Ethermets) are called subnets.
4
A campus network consisting of LANs for various departments .
Subnets (2)
✔An IP address has two components, the network address and the host
address. A subnet mask separates the IP address into the network and
host addresses (<network> <host>). Subnetting further divides the
host part of an IP address into a subnet and host address (<network>
<subnet> <host>).
5
✔A Subnet mask is a 32-bit number that masks an IP address, and
divides the IP address into network address and host address. Subnet
Mask is made by setting network bits to all "1"s and setting host bits
to all "0"s.
6
The default subnet mask used for class A, B, C and D are:
8
Example-1
19 19 19
2 2 2.
19
2
19
19 19 2.
2. 2.
19
2
9
Performing the AND Function
Example-2: A host wants to send packet to a host 192.108.2.2. First
the sender has to find the net ID of the receiver.
in decimal 192.108.2.0
10
Subnet Mask
• Follow these steps to determine the subnet mask:
✔ Replace the network and subnet portion of the address with all 1s.
✔ Replace the host portion of the address with all 0s.
✔ Convert the binary expression back to dotted-decimal notation.
11
255.255.255.0
Default Subnet mask
13
Examples
14
Example-1: Put default class C IP address to each node
192.168.2.1 192.168.4.2
192.168.4.1
192.168.5.2
Net-C
192.168.4.0
192.168.2.2
192.168.3.1 192.168.4.5 HUB
Net-A
192.168.2.0 192.168.4.3 192.168.5.4
192.168.4.4
Subnet-D
HUB
Router-2 Router-3
Router-1
Subnet-A
Subnet-B Subnet-C
We have four subnets.
a)The subnet–A has four hosts (3 PCs and 1 router interface)
b) subnet-B has 6 hosts (4 PCs and 2 router interfaces)
c) subnet-C has 4 hosts (3 PCs and 1 router interface)
d) the network has another two hosts correspond to subnet-D i.e between router-1
16
and router-2 which are directly connected. Here we have 4 subnets.
Subnet-D
HUB
Subnet-A
Subnet-B Subnet-C
If we keep 3 bits for the subnet ID (we can also take 2 bits for subnet
for above network) of then we have 23 = 8 subnets which is greater
than 4 subnets of above figure. We can also use 2 bits for 4 subnets.
Considering class B IP address. Our custom subnet mask will be ,
19
191.1.64.1 191.1.64.2 191.1.96.1
191.1.32.1
191.1.64.3 191.1.64.4
191.1.32.3
Subnet-A 191.1.96.3
Subnet-B Subnet-C
Binary
Decimal
10111111.00000001.00100000.00000001
191.1.32.1
191.1.32.2 10111111.00000001. 00100000.00000010
10111111.00000001. 00100000.00000011
191.1.32.3
…………. …………………………………………..
…………………………………………..
………….
10111111.00000001. 00111111.11111110
191.1.63.254
Binary
Decimal
191.1.64.1 10111111.00000001.01000000.00000001
191.1.64.2 10111111.00000001.01000000.00000010
191.1.64.3 10111111.00000001.01000000.00000011
…………. …………………………………………..
…………. …………………………………………..
191.1.95.254 10111111.00000001.01011111.11111110
191.1.96.1 10111111.00000001.01100000.00000001
191.1.96.2 10111111.00000001.01100000.00000010
191.1.96.3 10111111.00000001.01100000.00000011
…………. …………………………………………..
…………. …………………………………………..
191.1.127.254 10111111.00000001.01111111.11111110
191.1.128.1 10111111.00000001.10000000.00000001
191.1.128.2 10111111.00000001. 10000000.00000010
191.1.128.3 10111111.00000001. 10000000.00000011
…………. …………………………………………..
…………. …………………………………………..
191.1.159.254 10111111.00000001. 10011111.11111110
24
The possible hosts for the subnet 191.1.160.0 ( we may chose
for the for the point to point link of Router-1 and Router-2 of
previous figure) will be,
191.1.160.1 10111111.00000001.10100000.00000001
191.1.160.2 10111111.00000001.10100000.00000010
191.1.160.3 10111111.00000001.10100000.00000011
…………. …………………………………………..
…………. …………………………………………..
191.1.191.254 10111111.00000001.10111111.11111110
25
The possible hosts for the subnet 191.1.192.0 ( we may chose
for the for the point to point link of Router-1 and Router-2 of
previous figure) will be,
191.1.192.1 10111111.00000001.11000000.00000001
191.1.192.2 10111111.00000001.11000000.00000010
191.1.192.3 10111111.00000001.11000000.00000011
…………. …………………………………………..
…………. …………………………………………..
191.1.223.254 10111111.00000001.11011111.11111110
26
The subnets and possible host IDs are shown below.
27
Example-3
Host H1 in Figure below is configured with an address of 128.96.34.15 and a subnet
mask of 255.255.255.128. The bitwise AND of these two numbers defines the
subnet number of the host and of all other hosts on the same subnet. In this case,
128.96.34.15 AND 255.255.255.128 equals 128.96.34.0, so this is the subnet
number for the topmost subnet in the figure.
28
For example, if H1 is sending to H2, then H1 ANDs its subnet mask
(255.255.255.128) with the address for H2 (128.96.34.139) and the result is found as:
128.96.34.128. This does not match the subnet number for H1 (128.96.34.0) so H1
knows that H2 is on a different subnet. Since H1 cannot deliver the packet to H2
directly over the subnet, it sends the packet to its default router R1.
29
R1 would AND H2’s address (128.96.34.139) with the subnet mask of the first
entry (255.255.255.128) and compare the result (128.96.34.128) with the network
number for that entry (128.96.34.0). Since this is not a match, it proceeds to the
next entry. This time a match does occur, so R1 delivers the datagram to H2 using
interface 1, which is the interface connected to the same network as H2.
30
Example-4
A class B IP address is 150.100.14.163 and the corresponding
subnet mask is 255.255.255.128 Determine the maximum number
of hosts per subnet.
Ans. The subnet mask in both binary and decimal is like:
11111111. 11111111. 11111111.
10000000
255.255.255.128
31
Example-5
A router is connected to network has two subnets 190.155.16.0 and
190.155.15.0 where the net_ID is 190.155.0.0 i.e. class B IP.
Assume 8 bits for subnet ID. How the router will deal with a
datagram destined to 190.155.16.16.
Subnet ID
Subnet ID 190.155.16.0
190.155.15.0
Router-1 Subnet-1
Subnet-2
Ans. Since 8 bits for subnet ID and 16 bits for net ID (class B
address) therefore the custom subnet mask will be 255.255.255.0 for
both the subnets. Now making ‘and’ operation of 190.155.16.16 and
255.255.255.0 gives 190.155.16.0. Therefore the router will route
the datagram to its subnet 190.155.16.0.
32
Example-6
If the subnet mask 255.255.240.0 is used for a class B IP address
then find the number of subnets and number of hosts/subnet.
Example-7
If the subnet mask 255.255.255.192 is used for a class C IP address
then fined the number of subnets and number of hosts/subnet.
34
We can now describe the datagram forwarding algorithm in the following way:
D = destination IP address
for each forwarding table entry SubnetNumber, SubnetMask, NextHop
D1 = SubnetMask & D
if D1 = SubnetNumber
if NextHop is an interface
deliver datagram directly to destination
else
deliver datagram to NextHop (a router)
35
IP Routing Table
✔Typically a routing table contains pair (N, R) where N is the net ID of the destination
network and R is the IP address of the next router along the path to network N.
✔Fig below will help to explain routing tables. Let us concentrate on router R which is
directly connected to network 20.0.0.0 and 30.0.0.0 (class A net_ID) can use direct
delivery to send to host on either of these networks.
✔A datagram destined for a host on network 40.0.0.0, R routes it to address of router
S, 30.0.0.7. R can reach on 30.0.0.7 directly and S can reach on network 40.0.0.0
directly.
Network
Network
20.0.0.0
Q
10.0.0.0 20.0.0.5
10.0.0.5 20.0.0.6
R
30.0.0.6
Network
30.0.0.0
40.0.0.0 S
30.0.0.7 36
40.0.0.7 Network
Example-4 Show the routing table of router R
20.0.0.0
Q
10.0.0.0 20.0.0.5
10.0.0.5 20.0.0.6
R
30.0.0.6
30.0.0.0
40.0.0.0 S
30.0.0.7
40.0.0.7
Routing table of R
To Reach Hosts on Route to this address
Network
20.0.0.0 Deliver Directly
30.0.0.0 Deliver Directly
10.0.0.0 20.0.0.5
40.0.0.0 30.0.0.7 37
38
Classless Interdomain Routing (CIDR)
or Supernetting
39
✔Supernetting, also called Classless Inter-Domain Routing (CIDR), is
a way to aggregate multiple Internet addresses of the same class.
Supernetting is the idea of combining two or more blocks of IP
addresses that together compose a continuous range of addresses (no
missing addresses in the middle). You create a supernet when you
have a need to place more hosts on a single network than currently
will work in a classful configuration.
40
✔Using supernetting, the network address 192.168.2.0/24 and an
adjacent address 192.168.3.0/24 can be merged into 192.168.2.0/23.
The "23" at the end of the address says that the first 23 bits are the
network part of the address, leaving the remaining nine bits for
specific host addresses.
✔Supernetting is most often used to combine Class C network
addresses and is the basis for most routing protocols currently used
on the Internet.
✔The Border Gateway Protocol (BGP), the prevailing exterior
(interdomain) gateway protocol and the Open Shortest Path First
(OSPF) router protocol both support supernetting, but the older
exterior or interdomain protocols, the Exterior Gateway Protocol
(EGP) and the Routing Information Protocol (RIP) do not support it.
41
✔For any class C IP address 192.168.1.0 and default subnet mask
255.255.255.0 we have 28-2 = 254 hosts. Let us now see how
class C address an produce more than 254 hosts.
✔The basic principle is to take one or more bits from the net ID
part as the host ID part. For example if we use subnet mask of
23 bits instead of 24 bits of default subnet mask then we get 9
bits for host ID the the number of hosts will be 29-2.
✔In this case net ID does not fall in any category hence called
classless IP. Such mask is called CIDR mask.
42
Let the available IP addresses are 192.168.20.0 through 192.168.31.0 i.e. 12
continuous class C addresses. Listing the third byte in binary value provides the
flowing results. The four leftmost bites of third byte are the same. Thus we can
implement a 20-bits subnet mask which allows 12 bits for the host addresses.
The total number of hosts will be 212-2 = 4094.
44
Example-9
Suppose you got three consecutive IP addresses: 203.100.200.0,
203.100.201.0 and 203.100.202.0 of class C.
IP address
203.100.200.0 11001011 01100100 11001 000 00000000
203.100.201.0 11001011 01100100 11001 001 00000000
203.100.202.0 11001011 01100100 11001 010 00000000
Default 11111111 11111111 11111111 00000000
subnet mask
Supernet mask 11111111 11111111 11111 000 00000000
45
IPv6
IPv6 uses 128 bit and expressed in 32 hexadecimal numbers like:
Ans. 2128
47
Try Running
48
49
50
Displays protocol statistics and current TCP/IP network connections.
51
52