Transcript networking
Network Principles
FdSc Computing Technologies
TCP-IP – Addressing & Sub-Netting
Carl Smith – 2004 (Revised 2013)
1
The format of an IP address
IP addresses are 32 bits long
They consist of two parts :–
The Network number and Host number
The 4 byte value or IP number displays each
byte as a decimal number (0-255) and
separates each byte with a period
e.g. 192.100.75.123
Each part is also called an octet of 8 bits
The first octet defines the Address “Class”
2
IP Classes
Class A network - NETWORK.HOST.HOST.HOST
1.0.0.0 through to 126.0.0.0 (16.7 million possible hosts)
Class B network - NETWORK.NETWORK.HOST.HOST
128.0.0.0 through to 191.255.0.0 (65,536 possible hosts)
Class C network - NETWORK.NETWORK.NETWORK.HOST
192.0.0.0 through to 223.255.255.0 (256 possible hosts)
Class D – start at 224.0.0.0 are used for multicasting purposes
Class E – start at 240.0.0.0 are used for research purposes
NOTE : 127.0.0.1 address is reserved for loopback testing
3
IP Address examples
Valid Class A addresses:
7.21.43.200
101.16.11.44
43.43.121.15
126.121.15.166
10.15.1.120 (Private)
Valid Class B addresses:
147.119.66.12
144.98.120.234
Valid Class C addresses:
192.2.101.99
221.190.45.1
195.195.160.10
4
Private Address Ranges
Defined by RFC (request for comment) 1918
10.0.0.0 to 10.255.255.255 – Class A
172.16.0.0 to 172.31.255.255 – Class B
192.168.0.0 to 192.168.255.255 – Class C
These address ranges are NOT routed by any
routers on the Internet
5
Addressing
Each device on a LAN must have a unique IP
address.
The address can be manually entered which
can be difficult to manage in a large network
Or the address can be obtained from a DHCP
(Dynamic Host Configuration Protocol) server
on the network
6
Addressing
In Multi-Site networks
(e.g. WAN’s or the
Internet) there must be
some way to define a
unique Network address
so that routers can find
their way to the
destination.
7
Simplified Addressing Scheme
A3
Network A
A2
A1
Network C
D1
Network D
C2
B2
D2
E1
Network B
B3
B1
Network E
E2
C1
C3
8
Addressing
In this simplified addressing Scheme
A, B, C, D and E define the NETWORK.
The numbers 1, 2, 3 etc define the HOST.
All routed protocols such as IP or IPX need to
define in some way the Network and the Host
part of an address
9
Addressing – An Analogy
NETWORK ADDRESS
HOST
Victoria Street
GRIMSBY
NE Lincolnshire
123
DN34 4AA
10
“IP” Addressing
IP addresses contain a network portion and a
host portion
The NETWORK portion of the address (which
depends on the Class) defines the “POST
CODE” area – 195.98.20.123
The HOST portion defines the actual “House”
NUMBER – 195.98.20.123
11
IP Addressing Scheme – Class C Sub-Networks
Network
195.98.30.0
195.98.30.3
195.98.30.2
195.98.30.1
195.98.2.1
Network
195.98.2.0
195.98.20.3
195.98.10.2
195.98.2.2
195.98.1.1
Network
195.98.20.0
195.98.20.2
195.98.20.1
195.98.1.2
195.98.10.1
Network
195.98.1.0
Network
195.98.10.0
195.98.10.3
12
Routers and IP
Routers calculate the network portion of the
IP address by using a default subnet “mask”
They do not care about the host address
The mask is a 32 bit binary number but is
written as 4 decimal octets like the IP
address
13
The Subnet Mask
Each class has its own default subnet mask
CLASS A – 255.0.0.0
11111111.00000000.00000000.00000000
CLASS B – 255.255.0.0
11111111.11111111.00000000.00000000
CLASS C – 255.255.255.0
11111111.11111111.11111111.00000000
14
How does it use the mask?
The router performs a logical AND of the IP address
and the subnet mask to produce the network
address i.e.
IP Address 192.168.1.100
Default Mask 255.255.255.0
Now convert the IP address and mask to Binary
15
Binary ANDing
192
168
1
100
1 1 0 0 0 0 0 0 . 1 0 1 0 1 0 0 0
0 0 0 0 0 0 0 1 . 0 1 1 0 0 1 0 0
1 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
1 1 0 0 0 0 0 0 . 1 0 1 0 1 0 0 0
0 0 0 0 0 0 0 1 . 0 0 0 0 0 0 0 0
The router now knows the Class C
Network address is 192.168.1.0
Once the packet is delivered it is left up to the
LAN to find the host MAC address using ARP
16
Network and Host Bits
With a default subnet mask, an address using all
zero bits is used to specify the actual network, whilst
an address of all ones (255) is a broadcast address
destined for every user on the network.
NB – The number of usable hosts is two less than
the total number possible because all zeros or all
ones cannot be used.
17
Addressing – TASK 1
What are the network and broadcast addresses for
the following, assume the default mask:-
201.123.99.201
10.15.1.120
195.195.16.232
101.17.21.200
148.17.22.220
201.123.99.0 / 201.123.99.255
10.0.0.0 / 10.255.255.255
195.195.16.0 / 195.195.16.255
101.0.0.0 / 101.255.255.255
148.17.0.0 / 148.17.255.255
18
Addressing
QUESTIONS?
19
Addressing Problems
With the advent of the Internet IPv4
addresses are running out globally.
The original designers did not allow for such
an “explosion” of address need
IPv6 is being designed and tested which will
be an 128 bit number
BUT, at the present time we are left with the
problem of insufficient addresses
20
Getting more from IP addresses
We can go beyond using the default subnet
mask to create additional separate but
smaller (in terms of hosts) networks from a
single IP address.
This is often exactly what we need within a
business.
It is called “Sub-Netting” your network.
21
How does it work?
Creating subnets segments a network into
smaller sub-networks
It works by manipulating the HOST portion of
the address:-
22
Subnet Class C example
You are given the following single class C
Internet address with 254 hosts:195.195.100.0/24 or 255.255.255.0
(note the /24 means 24 bits are used for the
network portion of the address)
You have several offices which each need an
address range for themselves connected via
WAN links and routers
23
Five Subnets are
Required from
195.195.100.0
Network 1
195.195.100.0
195.195.100.0
195.195.100.0
Network 4
Network 2
Network 5
Network 3
24
SUBNET Class C example
We need to “borrow” some bits from the host
portion of the address
How many networks do we need? = 5
Convert that number to binary – uses 3 bits
That is the number of bits we need to borrow
from the host portion i.e.
nnnnnnnn.nnnnnnnn.nnnnnnnn.ssshhhhh
25
SUBNET Class C example
Work from the end of the default mask for
class C which is 255.255.255 for 3 bits
nnnnnnnn.nnnnnnnn.nnnnnnnn.ssshhhhh
Work out the value of the binary mask
11100000 in decimal, 11100000 = 224
Your subnet mask is now
255.255.255.224
for ALL hosts on your network
26
SUBNET Class C example
2^8
2^7
2^6
2^5
2^4
2^3
2^2
2^1
2^0
256
128
64
32
16
8
4
2
1
This will give you 2^3-2 (6) networks with 2^5-2 (30)
hosts on each network
It is minus two because of the network and
broadcast addresses for each sub-network
27
Working out the network and broadcast
addresses for subnets
Subtract the new mask from 256 (256-224 =
32)
32 is our FIRST network address
Count in blocks of 32 to get each subnetworks network address i.e. 32, 64,
96,128,160,192
The broadcast address is one less than the
following network addresses i.e. 63, 95, 127, 159, 191, 223
28
Subnetting
Network
Number
Net Addr
B’cast Addr
0
0
31
1
32
63
2
64
95
3
96
127
4
128
159
5
160
191
6
192
223
7
224
255
Traditionally you cannot use network 0 or 224 (in this example) so you
lose the first and last network address ranges
Sub-netting is very wasteful of addresses
29
Network
195.195.100.32
Broadcast
195.195.100.63
195.195.100.33
NOTE - Not all host
addresses have been
included in this
diagram
Network
195.195.100.128
Broadcast
195.195.100.159
195.195.100.65
Network
195.195.100.64
Broadcast
195.195.100.95
Network
195.195.100.160
Broadcast
195.195.100.191
195.195.100.97
Network
195.195.100.96
Broadcast
195.195.100.127
30
SUBNETS
Within Sub-Networks routers still use the same
binary ANDing algorithm to calculate the network
address of each network e.g.
195.195.100.33/27 255.255.255.224
11000011.11000011.01100100.00100001
11111111.11111111.11111111.11100000
11000011.11000011.01100100.00100000
= 195.195.100.32 = Network Address
11000011.11000011.01100100.00111111
= 195.195.100.63 = Broadcast Address
AND
Zero’s
One’s
31
SUB-NETS
QUESTIONS?
32
IP Addressing Summary
We have covered:
IP address 32bit (4xOctet) format
CLASS A,B and C Addresses
IP Addressing
Network and broadcast addresses
Private address ranges
Default Subnet Masks
Sub-Netting Basics
33
YOUR TURN..!
1.
2.
3.
Default masks for a range of IP addresses
VALID IP Addresses and which Class
Working out network and hosts portion when
sub-netting
* SEE HANDOUTS *
34