Sie sind auf Seite 1von 144

DCN

Instructor
Adeel Shabbir
Inroduction to IP Address
Adeel Shabbir CASE 1

2 Adeel Shabbir CASE

3 Adeel Shabbir CASE
4 Adeel Shabbir CASE
Adeel Shabbir CASE 5
Adeel Shabbir CASE 6
DECIMAL
AND
BINARY
3.1
7 Adeel Shabbir CASE
Figure 3-1
Decimal system
8 Adeel Shabbir CASE
Figure 3-2
Binary system
9 Adeel Shabbir CASE
CONVERSION
3.2
10 Adeel Shabbir CASE
Figure 3-3
Binary to decimal conversion
11 Adeel Shabbir CASE
Example 1
Convert the binary number 10011 to decimal.
Solution
Write out the bits and their weights. Multiply the bit by
its corresponding weight and record the result. At the
end, add the results to get the decimal number.
Binary 1 0 0 1 1
Weights 16 8 4 2 1
-------------------------------------
16 + 0 + 0 + 2 + 1
Decimal 19
12 Adeel Shabbir CASE
Example 2
Convert the decimal number 35 to binary.
Solution
Write out the number at the right corner. Divide the
number continuously by 2 and write the quotient and
the remainder. The quotients move to the left, and the
remainder is recorded under each quotient. Stop when
the quotient is zero.
0 1 2 4 8 17 35 Dec.
Binary 1 0 0 0 1 1

13 Adeel Shabbir CASE
Figure 3-4
Decimal to binary conversion
14 Adeel Shabbir CASE
Decimal to Binary Conversion

97 2 quotient = 48, remainder = 1 (LSB)
48 2 quotient = 24, remainder = 0.
24 2 quotient = 12, remainder = 0.
12 2 quotient = 6, remainder = 0.
6 2 quotient = 3, remainder = 0.
3 2 quotient = 1, remainder = 1.
1 2 quotient = 0 (Stop) remainder = 1 (MSB)

Result = 1 1 0 0 0 0 1
2


Adeel Shabbir CASE 15
Binary to Decimal Conversion


10110101
2
12
7
+ 02
6
+ 12
5
+ 12
4
+ 02
3
+ 12
2
+ 02
1
+ 12
0

= 128 + 32 + 16 + 4 + 1
= 181
10

Adeel Shabbir CASE 16
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
17 Adeel Shabbir CASE
Consider MSB as Batch Number and other 2
Bits as Roll
18 Adeel Shabbir CASE
If we have 2 bits how many combinations are
possible?

19 Adeel Shabbir CASE
Combinations

Two Bits
2
2
=4 range 0-3

Three Bits
2
3
=8 range 0-7

Four Bits
2
4
=16 range 0-15

20 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
MSB LSBs LSB Dec.
0 000
0
00 0
1 001
0
01 1
2 010
0
10 2
3 011
0
11 3
4 100
1
00 0
5 101
1
01 1
6 110
1
10 2
7 111
1
11 3
21 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
MSB LSBs LSB
Dec.
0 000
0
00 0
1 001
0
01 1
2 010
0
10 2
3 011
0
11 3
4 100
1
00 0
5 101
1
01 1
6 110
1
10 2
7 111
1
11 3
How many Groups???

22 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
MSB LSBs LSB
Dec.
0 000
0
00 0
1 001
0
01 1
2 010
0
10 2
3 011
0
11 3
4 100
1
00 0
5 101
1
01 1
6 110
1
10 2
7 111
1
11 3
How many Groups???
2

23 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
MSB LSBs LSB
Dec.
0 000
0
00 0
1 001
0
01 1
2 010
0
10 2
3 011
0
11 3
4 100
1
00 0
5 101
1
01 1
6 110
1
10 2
7 111
1
11 3
How many Groups???
2
How many Persons in each
Group???



24 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
MSB LSBs LSB
Dec.
0 000
0
00 0
1 001
0
01 1
2 010
0
10 2
3 011
0
11 3
4 100
1
00 0
5 101
1
01 1
6 110
1
10 2
7 111
1
11 3

How many Groups???
2


How many Persons in each
Group???
4


Total students are still 8




25 Adeel Shabbir CASE
Now lets have a 4 Bit Number
0000
2 MSB for Batch and 2 LSB for Roll #
26 Adeel Shabbir CASE
2 MSB for
Batch id so 4
Batch Possible

2 LSB for Roll
So 4 Roll in
Each Batch

Total students
are still 16
MSB LSBs LSB Dec. MSB Dec.
0 0000
00
00 0
0
1 0001
00
01 1
0
2 0010
00
10 2
0
3 0011
00
11 3
0
4 0100
01
00 0
1
5 0101
01
01 1
1
6 0110
01
10 2
1
7 0111
01
11 3
1
8 1000
10
00 0
2
9 1001
10
01 1
2
10 1010
10
10 2
2
11 1011
10
11 3
2
12 1100
11
00 0
3
13 1101
11
01 1
3
14 1110
11
10 2
3
15 1111
11
11 3
3
27 Adeel Shabbir CASE
No of Bits Bits for
Batch
No of Batch
Roll
BRRRRRRR
1 2 128
BBRRRRRR

2 4 64
BBBRRRRR

3 8 32
BBBBRRRR

4 16 16
BBBBBRRR

5 32 8
BBBBBBRR

6 64 4
BBBBBBBR

7 128 2
BBBBBBBB

8 256 0
28 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
111 7
29 Adeel Shabbir CASE

Bitwise & AND

A B A&B
0 0 0
0 1 0
1 0 0
1 1 1
30 Adeel Shabbir CASE

Bitwise | OR

A B A|B
0 0 0
0 1 1
1 0 1
1 1 1
31 Adeel Shabbir CASE

Bitwise | XOR

A B AXORB
0 0 0
0 1 1
1 0 1
1 1 0
32 Adeel Shabbir CASE
101
111 &
Ans 101
33 Adeel Shabbir CASE
110
111 &
Ans 110
34 Adeel Shabbir CASE
Conclusion
If we AND any thing with 1, result is same
35 Adeel Shabbir CASE
110
000 &
Ans 000
36 Adeel Shabbir CASE
111
000 &
Ans 000
37 Adeel Shabbir CASE
011
000 &
Ans 000
38 Adeel Shabbir CASE
110
011 &
Ans 010
39 Adeel Shabbir CASE
110
101 &
Ans 100
40 Adeel Shabbir CASE
Conclusion
If we AND & any thing with 0, result is always 0
If we AND & any thing with 1, result is same
41 Adeel Shabbir CASE
Use of Bitwise AND
So if we Want to off some bit we can simply
AND this bit with 0.
42 Adeel Shabbir CASE
Off the Third bit
1010110

43 Adeel Shabbir CASE
1010110
1111011 &
Ans 1010010
44 Adeel Shabbir CASE
Off the second bit
1010110

45 Adeel Shabbir CASE
1010110
1111101 &
Ans 1010100
46 Adeel Shabbir CASE
Off the first 3 bits
1010110

47 Adeel Shabbir CASE
1010110
1111000 &
Ans 1010000
48 Adeel Shabbir CASE
Off the first 4 bits
1010110

49 Adeel Shabbir CASE
1010110 86
1110000 & 112
Ans 1010000 80
50 Adeel Shabbir CASE
Off the last 3 bits
1010110

51 Adeel Shabbir CASE
1010110 86
0001111 & 15
Ans 0000110 6
52 Adeel Shabbir CASE
MASK for 3 Bit BATCH number
11100000(remaning Bits are Zero)
53 Adeel Shabbir CASE
MASK for 4 Bit BATCH number
11110000( remaning Bits are Zero)
54 Adeel Shabbir CASE
MASK
If ID Is 4 Bit long(1010)
Batch ID is 1 Bit
Roll # is of 3 Bit
To get Batch ID we need to bitwise &, ID with
1000 MASK
ID 1010
MASK 1000
ANS 1000
55 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
NUM
MASK Result
0 000
100 000
0
1 001
100 000
0
2 010
100 000
0
3 011
100 000
0
4 100
100 100
4
5 101
100 100
4
6 110
100 100
4
7 111
100 100
4



BATCH ID is 1 Bit
56 Adeel Shabbir CASE
Lets Consider Batch ID composed of 2 Bits
57 Adeel Shabbir CASE
421
000 0
001 1
010 2
011 3
100 4
101 5
110 6
11 7
NUM
MASK Result
DEC.
0 000
110 000
0
1 001
110 000
0
2 010
110 010
2
3 011
110 010
2
4 100
110 100
4
5 101
110 100
4
6 110
110 110
6
7 111
110 110
6







BATCH ID is 2 Bit
58 Adeel Shabbir CASE
2 MSB for
Batch id so 4
Batch Possible

2 LSB for Roll
So 4 Roll in
Each Batch

Total students
are still 16
MASK MSB
0 0000
1100 0000
0
1 0001
1100 0000
0
2 0010
1100 0000
0
3 0011
1100 0000
0
4 0100
1100
0100
4
5 0101
1100
0100
4
6 0110
1100
0100
4
7 0111
1100
0100
4
8 1000
1100
1000
8
9 1001
1100
1000
8
10 1010
1100
1000
8
11 1011
1100
1000
8
12 1100
1100
1100
12
13 1101
1100
1100
12
14 1110
1100
1100
12
15 1111
1100
1100
12
59 Adeel Shabbir CASE



CONCLUSION
60 Adeel Shabbir CASE
No of Bits Bits for
Batch
MASK
MASK Dec.
Result
BRRRRRRR
1 10000000 128
B0000000
BBRRRRRR

2 11000000 192
BB000000
BBBRRRRR

3 11100000 224
BBB00000
BBBBRRRR

4 11110000 240
BBBB0000
BBBBBRRR

5 11111000 248
BBBBB000
BBBBBBRR

6 11111100 252
BBBBBB00
BBBBBBBR

7 11111110 254
BBBBBBB0
BBBBBBBB

8 11111111 255
BBBBBBBB
61 Adeel Shabbir CASE
Now consider we have ID of 4 bytes
4 Bytes=32 Bits
Total Combinations??


62 Adeel Shabbir CASE
Now consider we have ID of 4 bytes
4 Bytes=32 Bits
Total Combinations??
2^32= 4294967296



63 Adeel Shabbir CASE
Lets Consider we Need two Batch ID
How many students are Possible in Each Batch
2^31= 2147483648
64 Adeel Shabbir CASE
Lets Consider we Need 4 Batch ID
How many students are Possible in Each Batch
2^30= 1073741824
65 Adeel Shabbir CASE
total Bits Bits for Batch No of Batch Bits for Roll total Roll
32 1 2 31 2147483648
32 2 4 30 1073741824
32 3 8 29 536870912
32 4 16 28 268435456
32 5 32 27 134217728
32 6 64 26 67108864
32 7 128 25 33554432
32 8 256 24 16777216
32 9 512 23 8388608
32 10 1024 22 4194304
32 11 2048 21 2097152
32 12 4096 20 1048576
32 13 8192 19 524288
32 14 16384 18 262144
32 15 32768 17 131072
66 Adeel Shabbir CASE
total Bits Bits for Batch No of Batch Bits for Roll total Roll
32 1 2 31 2147483648
32 2 4 30 1073741824
32 3 8 29 536870912
32 4 16 28 268435456
32 5 32 27 134217728
32 6 64 26 67108864
32 7 128 25 33554432
32 8 256 24 16777216
32 9 512 23 8388608
32 10 1024 22 4194304
32 11 2048 21 2097152
32 12 4096 20 1048576
32 13 8192 19 524288
32 14 16384 18 262144
32 15 32768 17 131072
32 16 65536 16 65536
32 17 131072 15 32768
32 18 262144 14 16384
32 19 524288 13 8192
32 20 1048576 12 4096
32 21 2097152 11 2048
32 22 4194304 10 1024
32 23 8388608 9 512
32 24 16777216 8 256
32 25 33554432 7 128
32 26 67108864 6 64
32 27 134217728 5 32
32 28 268435456 4 16
32 29 536870912 3 8
32 30 1073741824 2 4
32 31 2147483648 1 2
32 32 4294967296 0 1
67 Adeel Shabbir CASE
total Bits Bits for Batch No of Batch Bits for Roll total Roll
32 1 2 31 2147483648
32 2 4 30 1073741824
32 3 8 29 536870912
32 4 16 28 268435456
32 5 32 27 134217728
32 6 64 26 67108864
32 7 128 25 33554432
32 8 256 24 16777216
32 9 512 23 8388608
32 10 1024 22 4194304
32 11 2048 21 2097152
32 12 4096 20 1048576
32 13 8192 19 524288
32 14 16384 18 262144
32 15 32768 17 131072
32 16 65536 16 65536
32 17 131072 15 32768
32 18 262144 14 16384
32 19 524288 13 8192
32 20 1048576 12 4096
32 21 2097152 11 2048
32 22 4194304 10 1024
32 23 8388608 9 512
32 24 16777216 8 256
32 25 33554432 7 128
32 26 67108864 6 64
32 27 134217728 5 32
32 28 268435456 4 16
32 29 536870912 3 8
32 30 1073741824 2 4
32 31 2147483648 1 2
32 32 4294967296 0 1
68 Adeel Shabbir CASE
MASK

BBBBBBBB.RRRRRRRR. RRRRRRRR. RRRRRRRR
11111111. 00000000. 00000000.00000000
255. 0. 0. 0
69 Adeel Shabbir CASE
Lets Consider ID as 4 Byte Long
Batch ID is 1 Byte Long
Roll # is 3 Bytes Long
BBBBBBBB.RRRRRRRR. RRRRRRRR. RRRRRRRR

MASK???
70 Adeel Shabbir CASE
MASK

BBBBBBBB.RRRRRRRR. RRRRRRRR. RRRRRRRR
11111111. 00000000. 00000000.00000000
255. 0. 0. 0
71 Adeel Shabbir CASE
Lets Consider ID as 4 Byte Long
Batch ID is 2 Bytes Long
Roll # is 2 Bytes Long
MASK???
72 Adeel Shabbir CASE
MASK

BBBBBBBB. BBBBBBBB. RRRRRRRR.RRRRRRRR
11111111. 11111111. 00000000.00000000
255. 255. 0. 0
73 Adeel Shabbir CASE
Lets Consider ID as 4 Byte Long
Batch ID is 3 Bytes Long
Roll # is 1 Byte Long
MASK???
74 Adeel Shabbir CASE
MASK

BBBBBBBB. BBBBBBBB. BBBBBBBB.RRRRRRRR
11111111. 11111111. 11111111.00000000
255. 255. 255. 0
75 Adeel Shabbir CASE
How many Bits for Network ID
Adeel Shabbir CASE 76
MASK

BBBBBBBB. RRRRRRRR. RRRRRRRR. RRRRRRRR
11111111. 00000000. 00000000. 00000000
255. 0. 0. 0

8
77 Adeel Shabbir CASE
MASK

BBBBBBBB.BBRRRRRR.RRRRRRRR.RRRRRRRR
11111111. 110000000. 00000000. 00000000
255. 192. 0. 0
78 Adeel Shabbir CASE
MASK

BBBBBBBB.BBRRRRRR.RRRRRRRR.RRRRRRRR
11111111. 110000000. 00000000. 00000000
255. 192. 0. 0

10
79 Adeel Shabbir CASE
MASK


11111111. 111000000. 00000000. 00000000
255 .224 . 0. 0

11
80 Adeel Shabbir CASE
MASK


255 .255 . 192. 0

18
81 Adeel Shabbir CASE
MASK


255 .255 . 224. 0

19
82 Adeel Shabbir CASE
Conclusion
Now You Know what is ID
Now You Know what is Batch ID
Now You Know what is Roll
Now You Know what is MASK
Now you Know How to calculate MASK
Now You Know how to Get the Batch ID
Now you Know How to get roll Number from
an ID.

83 Adeel Shabbir CASE
IP addressing: introduction
84 Adeel Shabbir CASE
IP addressing: introduction
A
Q
K
I
D
B
r
85 Adeel Shabbir CASE
IP addressing: introduction
A
B
C
D
E
F
G
86 Adeel Shabbir CASE
IP addressing: introduction
1.1
1.2
1.3
2.1 2.2
3.2
3.1
2.3 2.4
3.3
3.4
1.4
87 Adeel Shabbir CASE
3 networks
Each has 4 Nodes
So we need at least 2
bits to represent
Network ID and 3 Bits
to represent nodes

88 Adeel Shabbir CASE
what is Possible Range
00XX
89 Adeel Shabbir CASE


0000 0
0001 1
0010 2
0011 3
90 Adeel Shabbir CASE
what is Possible Range
01XX
91 Adeel Shabbir CASE
0100 4
0101 5
0110 6
0111 7
92 Adeel Shabbir CASE
what is Possible Range
10XX
93 Adeel Shabbir CASE
1000 8
1001 9
1010 10
1011 11
94 Adeel Shabbir CASE
what is Possible Range
11XX
95 Adeel Shabbir CASE
1100 12
1101 13
1110 14
1111 15
96 Adeel Shabbir CASE
Class Leftmost bits Start address Finish address
A 0xxx 0.0.0.0 127.255.255.255
B 10xx 128.0.0.0 191.255.255.255
C 110x 192.0.0.0 223.255.255.255
D 1110 224.0.0.0 239.255.255.255
E 1111 240.0.0.0 255.255.255.255

97 Adeel Shabbir CASE
Class A
0. 0. 0. 0 = 00000000.00000000.00000000.00000000
127.255.255.255 = 01111111.11111111.11111111.11111111
0nnnnnnn.HHHHHHHH.HHHHHHHH.HHHHHHHH
Class B
128. 0. 0. 0 = 10000000.00000000.00000000.00000000
191.255.255.255 = 10111111.11111111.11111111.11111111
10nnnnnn.nnnnnnnn.HHHHHHHH.HHHHHHHH
Class C
192. 0. 0. 0 = 11000000.00000000.00000000.00000000
223.255.255.255 = 11011111.11111111.11111111.11111111
110nnnnn.nnnnnnnn.nnnnnnnn.HHHHHHHH
Class D
224. 0. 0. 0 = 11100000.00000000.00000000.00000000
239.255.255.255 = 11101111.11111111.11111111.11111111
1110XXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX
Class E
240. 0. 0. 0 = 11110000.00000000.00000000.00000000
255.255.255.255 = 11111111.11111111.11111111.11111111
1111XXXX.XXXXXXXX.XXXXXXXX.XXXXXXXX
98 Adeel Shabbir CASE
Class A Network
In a Class A Network binary address start
with 0, therefore the decimal number can
be anywhere from 1 to 126. The first 8 bits
(the first octet) identify the network and
the remaining 24 bits indicate the host
within the network. An example of a Class
A IP address is 102.168.212.226, where
"102" identifies the network and
"168.212.226" identifies the host on that
network.


99 Adeel Shabbir CASE
Class B Network
In a Class B Network, binary addresses start with
10, therefore the decimal number can be
anywhere from 128 to 191. The number 127 is
reserved for loopback and is used for internal
testing on the local machine. The first 16 bits (the
first two octets) identify the network and the
remaining 16 bits indicate the host within the
network. An example of a Class B IP address is
168.212.226.204 where "168.212" identifies the
network and "226.204" identifies the host on that
network.

100 Adeel Shabbir CASE
Class C Network
Binary addresses start with 110, therefore the
decimal number can be anywhere from 192 to
223. The first 24 bits (the first three octets)
identify the network and the remaining 8 bits
indicate the host within the network. An
example of a Class C IP address is
200.168.212.226 where "200.168.212"
identifies the network and "226" identifies the
host on that network.

101 Adeel Shabbir CASE
Class D Network
In a Class D Network, binary addresses start
with 1110, therefore the decimal number can
be anywhere from 224 to 239. Class D
networks are used to support multicasting.

102 Adeel Shabbir CASE
Class E Network
In a Class E Network, binary addresses start
with 1111, therefore the decimal number can
be anywhere from 240 to 255. Class E
networks are used for experimentation. They
have never been documented or utilized in a
standard way.

103 Adeel Shabbir CASE
10.12.12.12
What is class of this IP address
104 Adeel Shabbir CASE
Class A
105 Adeel Shabbir CASE
110.12.12.12
What is class of this IP address
106 Adeel Shabbir CASE
Class A
107 Adeel Shabbir CASE
130.12.12.12
What is class of this IP address
108 Adeel Shabbir CASE
Class B
109 Adeel Shabbir CASE
199.12.12.12
What is class of this IP address
110 Adeel Shabbir CASE
Class C
111 Adeel Shabbir CASE
127.12.12.12
What is class of this IP address
112 Adeel Shabbir CASE
Class A
113 Adeel Shabbir CASE
128.12.12.12
What is class of this IP address
114 Adeel Shabbir CASE
Class B
115 Adeel Shabbir CASE
191.12.12.12
What is class of this IP address
116 Adeel Shabbir CASE
Class B
117 Adeel Shabbir CASE
192.12.12.12
What is class of this IP address
118 Adeel Shabbir CASE
Class A
Class C is the true answer
119 Adeel Shabbir CASE
223.12.12.12
What is class of this IP address
120 Adeel Shabbir CASE
Class c
121 Adeel Shabbir CASE
224.12.12.12
What is class of this IP address
122 Adeel Shabbir CASE
Class D
123 Adeel Shabbir CASE
239.12.12.12
What is class of this IP address
124 Adeel Shabbir CASE
Class D
125 Adeel Shabbir CASE
240.12.12.12
What is class of this IP address
126 Adeel Shabbir CASE
Class E
127 Adeel Shabbir CASE
10.12.12.12
What is MASK of this IP address
128 Adeel Shabbir CASE
Class A
So MASk
255.0.0.0
11111111.00000000.00000000.00000000
129 Adeel Shabbir CASE
135.12.12.12
What is MASK of this IP address
130 Adeel Shabbir CASE
Class B
So MASk
255.255.0.0
11111111.11111111.00000000.00000000
131 Adeel Shabbir CASE
193.12.12.12
What is MASK of this IP address
132 Adeel Shabbir CASE
Class C
So MASk
255.255.255.0
11111111.11111111.11111111.00000000
133 Adeel Shabbir CASE
11111111.11111111.00000000.0000000
THIS MASK IS FOR WHICH CLASS
134 Adeel Shabbir CASE
CLASS B
135 Adeel Shabbir CASE
11111111. 00000000.00000000.0000000
THIS MASK IS FOR WHICH CLASS
136 Adeel Shabbir CASE
CLASS A
137 Adeel Shabbir CASE
11111111. 00000000.00000000.0000000
THIS MASK IS FOR WHICH CLASS
138 Adeel Shabbir CASE

Adeel Shabbir CASE 139
Subneting
140 Adeel Shabbir CASE
4 2 1
0 0 0 0
0 0 1 1
0 1 0 2
0 1 1 3
1 0 0 4
1 0 1 5
1 1 0 6
1 1 1 7
141 Adeel Shabbir CASE
8 4 2
0 0 0 0
0 0 1 2
0 1 0 4
0 1 1 6
1 0 0 8
1 0 1 10
1 1 0 12
1 1 1 14 142 Adeel Shabbir CASE
16 8 4
0 0 0 0
0 0 1 4
0 1 0 8
0 1 1 12
1 0 0 16
1 0 1 20
1 1 0 24
1 1 1 28 143 Adeel Shabbir CASE
16 8 4 2 1
0 0 0 0 0 0
0 0 1 0 0 4
0 1 0 0 0 8
0 1 1 0 0 12
1 0 0 0 0 16
1 0 1 0 0 20
1 1 0 0 0 24
1 1 1 0 0 28 144 Adeel Shabbir CASE

Das könnte Ihnen auch gefallen