Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

IP Addresss

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

Lecture -7

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.

✔It is called a subnet mask because it is used to identify network


address of an IP address by performing bitwise AND operation on
the subnet mask.

6
The default subnet mask used for class A, B, C and D are:

Class A: 11111111.00000000. 00000000. 00000000


255.0.0.0

Class B: 11111111. 11111111. 00000000. 00000000


255.255.0.0

Class C: 11111111. 11111111. 11111111. 00000000


255.255.255.0

For example we have a class C IP address of a host: 192.168.23.4


Anding the IP address with default subnet mask 255.255.255.0 give
the result of 192.168.23.0 which is the net ID part of the IP address.
7
The possible hosts will be:
192.168.23.1
192.168.23.2
192.168.23.3
192.168.23.4
…………….
192.168.23.254

192.168.23.0 and 192.168.23.255 are excluded as mentioned


before. Therefore the number of hosts is 28-2 = 254

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

Costumed Subnet mask


The example of a customed subnet mask for class B is like:

A class B network subnetted into 64 subnets.

Example: Determine the number of subnet and host per subnet


Ans. The number of subnet = 26 = 64
The number of hosts = 210-2= 1022

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

192.168.3.2 192.168.4.6 192.168.5.1


192.168.2.4
Net-B
192.168.3.0
192.168.5.3
192.168.2.3
Net-D
192.168.5.0

Net-A
192.168.2.0 192.168.4.3 192.168.5.4
192.168.4.4

The drawback of the network is that it needs 4 IP address from ISP


for 4 networks.
Example-2 Design the network with proper subnetting using class B IP.

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

Router-1 Router-2 Router-3

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 ,

11111111 11111111 11100000 00000000

255 255 224 0


17
Let we have class B IP address 191.1.0.0 where net ID is 191.1
then possible 8 subnets will be:

191 1 00100000 00000000


191.1.32.0
191 1 01000000 00000000
191.1.64.0
191 1 01100000 00000000
191.1.96.0
191 1 10000000 00000000
191.1.128.0
191 1 10100000 00000000
191.1.160.0
191 1 11000000 00000000
18
191.1.192.0
191 1 00000000 00000000
191.1.0.0

191 1 11100000 00000000


191.1.224.0

19
191.1.64.1 191.1.64.2 191.1.96.1
191.1.32.1

191.1.32.4 191.1.128.2 191.1.96.4


191.1.64.1

191.1.32.2 191.1.128.1 191.1.64.5


Router-2 Router-3
Router-1
191.1.96.2

191.1.64.3 191.1.64.4
191.1.32.3
Subnet-A 191.1.96.3
Subnet-B Subnet-C

The advantage of the network is that it needs only one IP address


from ISP.
20
The possible hosts for the subnet 191.1.32.0 ( we may chose
for the subnet-A of previous figure) will be,

191 1 001xxxxx xxxxxxxx

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

Total number of hosts will be 213-2


21
The possible hosts for the subnet 191.1.64.0 ( we may chose
for the subnet-B of previous figure) will be,

191 1 010xxxxx xxxxxxxx

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

Total number of hosts will be 213-2


22
The possible hosts for the subnet 191.1.96.0 ( we may chose
for the subnet-C of previous figure) will be,

191 1 011xxxxx xxxxxxxx

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

Total number of hosts will be 213-2


23
The possible hosts for the subnet 191.1.128.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 100xxxxx xxxxxxxx

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

Total number of hosts will be 213-2

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 101xxxxx xxxxxxxx

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

Total number of hosts will be 213-2

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 110xxxxx xxxxxxxx

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

Total number of hosts will be 213-2

26
The subnets and possible host IDs are shown below.

Subnet 1st host ID Last host ID


191.1.32.0 191.1.32.1 191.1.63.254
191.1.64.0 191.1.64.1 191.1.95.254
191.1.96.0 191.1.96.1 191.1.127.254
191.1.128.0 191.1.128.1 191.1.159.254
191.1.160.0 191.1.160.1 191.1.191.254
191.1.192.0 191.1.192.1 191.1.223.254

From above table we get two formulas:


The 1st host ID = subnet ID + 1
The last host ID of a range = next subnet ID - 2

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

Here 9 bits are for subnets and 7 bits for hosts.


Therefore the number of hosts per subnet 27-2 = 126
The number of subnets = 29 = 512

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.

Binary: 11111111 . 11111111 . 11110000 . 00000000


Decimal: 255.255.240.0
The number of hosts/subnet = 212 – 2 = 4094
The number of subnets = 24 = 16

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.

The number of hosts/subnet = 25 – 2 = 30


The number of subnets = 23 = 8
33
Exercise-1
Using class C subnet mask 255.255.255.0 for a class B IP, you can
divide class B network 172.16.0.0 into 256 possible subnets. Justify
with numerical example.

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

Classless interdomain routing (CIDR, pronounced “cider”) is a


technique that addresses two scaling concerns in the Internet:
i)the growth of backbone routing tables as more and more network
numbers need to be stored in them
ii)ii) the potential for the 32-bit IP address space to be exhausted well
before the 4 billionth host is attached to the Internet.

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.

✔The original Internet Protocol (IP) defines IP addresses in four major


classes of address structure, Classes A through D. Each class
allocates one portion of the 32-bit Internet address format to a
netwok address and the remaining portion to the specific host
machines within the network.

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.

Decimal Binary of third byte


192.168.20.0 00010100
192.168.21.0 00010101
192.168.22.0 00010110
192.168.23.0 00010111
192.168.24.0 00011000
192.168.25.0 00011001
192.168.26.0 00011010
192.168.27.0 00011011
192.168.28.0 00011100
192.168.29.0 00011101
192.168.30.0 00011110
192.168.31.0 00011111

The entire IP addresses acts as a single IP hence reduce the size of


43
table of a router.
Example-8
For the CIDR address of 192.168.10.0/20 determine the range
of class C IP address.
Ans.

Decimal Binary of third byte


192.168.10.0 00001010
192.168.11.0 00001011
192.168.12.0 00001100
192.168.13.0 00001101
192.168.14.0 00001110
192.168.15.0 00001111

The range of class C IP address is 192.168.10.0 to 192.168.15.0

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

Therefore 8 subnet can be converted to a supernet using supernet


mask of 255.255.248.0.

45
IPv6
IPv6 uses 128 bit and expressed in 32 hexadecimal numbers like:

EFAC: BA89: 7529:AFDC: 92AF:8654:1293 :29A2

After every 4 digits a colon ‘:’ is used therefore 32 digits + 7


colons = 39 characters hence called addressing system of 39
characters.
In some addresses huge number of zeros exits like:
DFAC: 0000: 0000:0000: 0009:03AC1:5923 :FEA2
can be expressed as:

DFAC: 0: 0:0: 9:3AC1:5923 :FEA2


or
DFAC: : 9:3AC1:5923 :FEA2
46
Double colon can be used only once in a IPv6 address.
How many subscriber is possible in IPv6?

Ans. 2128

47
Try Running

48
49
50
Displays protocol statistics and current TCP/IP network connections.

51
52

You might also like