1 26-aug-15 addressing the network using ipv4 lecture # 2 engr. orland g. basas prepared by: engr....
TRANSCRIPT
19 Apr 2023 1
Addressing the network using IPv4
Lecture # 2Lecture # 2
Prepared by: Engr. Orland G. BasasEngr. Orland G. Basas
IT Lecturer
19 Apr 2023 2
IP addressing – works at
OSI model layer 3 TCP/IP model Internet layer
Application
Presentation
Session
Transport
Network
Data link
Physical
Application
Transport
Internet
Network Access
TCP, UDP
IP
Ethernet, WAN technologies
HTTP, FTP, TFTP, SMTP etc
Segment
Packet
Frame
Bits
Data stream
19 Apr 2023 3
The 32-bit binary addresses used on the Internet are referred to as Internet Protocol (IP) addresses
Commonly written in dotted-decimal format – 192.168.10.1 When IP addresses are assigned to computers, some of the
bits on the left side of the 32-bit IP number represent a network.
The bits left over in the 32-bit IP address identify a particular computer on the network A computer is referred to as the host
The IP address of a computer consists of a network & a host part that represents a particular computer on a particular network
IP addressing
19 Apr 2023 4
In the early days of the Internet, IP addresses were allocated to organizations based on request rather than actual need.
When an organization received an IP network address, that address was associated with a “Class”, A, B, or C.
This is known as Classful IP Addressing The first octet of the address determined what class the
network belonged to and which bits were the network bits and which bits were the host bits.
It was not until 1992 when the IETF introduced CIDR (Classless Interdomain Routing), making the address class meaning less.
This is known as Classless IP Addressing. For now, all you need to know is that today’s networks are
classless, except for those networks that still use Classful routing protocols.
Classful IP Addressing
19 Apr 2023 5
IPv4 Address Classes
19 Apr 2023 6
Class A
Class B
Class C
Network Host Host Host
Network Network Host Host
Network Network Network Host
1st octet 2nd octet 3rd octet 4th octet
N = Network number assigned by Internet registry H = Host number assigned by administrator
Address Classes
19 Apr 2023 7
Class A addresses
Network Host Host Host
First octet is between 0 – 127, begins with 0
Number between 0 - 127
8 bits 8 bits 8 bits
With 24 bits available for hosts, there a 224 possible addresses. That’s 16,777,216 nodes!
There are 126 class A addresses. 0 and 127 have special meaning and are not used.
16,777,214 host addresses, one for network address and one for broadcast address.
Only large organizations such as the military, government agencies, universities, and large corporations have class A addresses.
For example ISPs have 24.0.0.0 and 63.0.0.0
19 Apr 2023 8
Class B addresses
Network Network Host Host
First octet is between 128 – 191, begins with 10
Number between 128 - 191
8 bits 8 bits
With 16 bits available for hosts, there a 216 possible addresses. That’s 65,536 nodes!
There are 16,384 (214) class B networks. 65,534 host addresses, one for network address and one for broadcast
address. Class B addresses are assigned to large organizations including corporations
(such as government agencies, and school districts).
19 Apr 2023 9
Class C addresses
Network Network Network Host
First octet is between 192 – 223, begins with 110
Number between 192 - 223
8 bits
With 8 bits available for hosts, there a 28 possible addresses. That’s 256 nodes!
There are 2,097,152 possible class C networks. 254 host addresses, one for network address and one for broadcast address. Usually assigned for small networks
19 Apr 2023 10
Class D Addresses A Class D address begins with binary 1110 in the first
octet. First octet range 224 to 239. Class D address can be used to represent a group of
hosts called a host group, or multicast group.
Class E Addresses First octet of an IP address begins with 1111 Class E addresses are reserved for experimental
purposes and should not be used for addressing hosts or multicast groups.
IPv4 Address Classes
19 Apr 2023 11
Types of Addresses
19 Apr 2023 12
Subnet Mask
To inform a computer how the 32-bit IP address has been split, a second 32-bit number called a subnetwork mask is used
This mask is a guide that indicates how the IP address should be interpreted by identifying how many of the bits are used to identify the network of the computer
The subnetwork mask sequentially fills in the 1s of the network portion.
19 Apr 2023 13
Class A IP Address Default Subnet Mask: 255.0.0.0 (/8)
Default Subnet Mask
Class B IP Address Default Subnet Mask: 255.255.0.0 (/16)
Class C IP Address Default Subnet Mask: 255.255.255.0 (/24)
19 Apr 2023 14
Network Prefix
How do we know how many bits represent the network portion and how many bits represent the host portion?
We use network prefix. The prefix length is the number of bits in the
address that gives us the network portion Ex: 172.16.4.0 /24, the /24 tells us that the first 24
bits are the network address. This leaves the remaining 8 bits, the last octet, as the host portion.
19 Apr 2023 15
IPv4 address
192. 168. 21. 17
11000000 10101000 00010101 00010001
octetoctet octet octet
network part host part
255. 255. 255. 0
11111111 11111111 11111111 00000000
Prefix /24 Subnet mask:
19 Apr 2023 16
Find the network address
192. 168. 21. 17
11000000 10101000 00010101 00010001
In a network address, all the host bits are 0.
192. 168. 21. 0
11000000 10101000 00010101 00000000
The router needs to do this for every packet.
19 Apr 2023 17
Logical AND
192. 168. 21. 17
11000000 10101000 00010101 00010001
255. 255. 255. 0
11111111 11111111 11111111 00000000
Do a logical AND at each position
192. 168. 21. 0
11000000 10101000 00010101 00000000
19 Apr 2023 18
Find the broadcast address
192. 168. 21. 17
11000000 10101000 00010101 00010001
In a broadcast address, all the host bits are 1.
192. 168. 21. 255
11000000 10101000 00010101 11111111
The broadcast is the last address in the network.
19 Apr 2023 19
Reminder: 3 types of address
Every network has: Network address – the first one Broadcast address – the last one Host addresses – everything in between
19 Apr 2023 20
Recall: Classful addressing
10. 17. 53. 60
network part host part
A
172. 16. 38. 201
network part host part
B
192. 168. 21. 17
network part host part
C
19 Apr 2023 21
Classful addressing
Easy to work out but very wasteful. Routers and hosts still assume default subnet
masks by class Class A /8 255.0.0.0 Class B /16 255.255.0.0 Class C /24 255.255.255.0
19 Apr 2023 22
Classless addressing
Any suitable prefix can be used We (and devices) need to know what the
prefix is. More flexible, less wasteful.
19 Apr 2023 23
Classless addressing /16
172.16.0.0/16 mask 255.255.0.0 Broadcast address 172.16.255.255
Hosts 172.16.0.1 to 172.16.255.254 65534 host addresses
172. 16. 0. 0
10101100 00010000 00000000 00000000
19 Apr 2023 24
Classless addressing /24
172.16.0.0/24 mask 255.255.255.0 Broadcast address 172.16.0.255
Hosts 172.16.0.1 to 172.16.0.254 254 host addresses
172. 16. 0. 0
10101100 00010000 00000000 00000000
19 Apr 2023 25
Classless addressing /22
172.16.0.0/22 mask 255.255.252.0 Broadcast address 172.16.3.255
Hosts 172.16.0.1 to 172.16.3.254 1022 host addresses
172. 16. 0. 0
10101100 00010000 00000000 00000000
19 Apr 2023 26
Classless addressing /26
172.16.0.0/22 mask 255.255.255.192 Broadcast address 172.16.0.63
Hosts 172.16.0.1 to 172.16.0.62 62 host addresses
172. 16. 0. 0
10101100 00010000 00000000 00000000
19 Apr 2023 27
Classless addressing /28
172.16.0.0/28 mask 255.255.255.240 Broadcast address 172.16.0.15
Hosts 172.16.0.1 to 172.16.0.14 14 host addresses
172. 16. 0. 0
10101100 00010000 00000000 00000000
19 Apr 2023 28
Calculating addresses
A host has IP address 192.168.1.70/24 What is the subnet mask? What is the network address? What is the broadcast address? What is the range of host addresses in the
network?
19 Apr 2023 29
192.168.1.70/24 – fill in the table
Last octet binary
Last octet decimal
Full
Host
Subnet mask
Network
Broadcast
First host
Last host
19 Apr 2023 30
192.168.1.70/24
Last octet binary
Last octet decimal
Full
Host 01000110 70 192.168.1.70
Subnet mask 00000000 0 255.255.255.0
Network 00000000 0 192.168.1.0
Broadcast 11111111 255 192.168.1.255
First host 00000001 1 192.168.1.1
Last host 11111110 254 192.168.1.254
19 Apr 2023 31
Calculating addresses
A host has IP address 192.168.1.70/26 What is the subnet mask? What is the network address? What is the broadcast address? What is the range of host addresses in the
network?
19 Apr 2023 32
192.168.1.70/26 fill in the table
Last octet binary
Last octet decimal
Full
Host
Subnet mask
Network
Broadcast
First host
Last host
19 Apr 2023 33
192.168.1.70/26
Last octet binary
Last octet decimal
Full
Host 01000110 70 192.168.1.70
Subnet mask 11000000 192 255.255.255.192
Network 01000000 64 192.168.1.64
Broadcast 01111111 127 192.168.1.127
First host 01000001 65 192.168.1.65
Last host 01111110 126 192.168.1.126
19 Apr 2023 34
Calculating addresses
A host has IP address 192.168.1.70/28 What is the subnet mask? What is the network address? What is the broadcast address? What is the range of host addresses in the
network?
19 Apr 2023 35
192.168.1.70/28 fill in the table
Last octet binary
Last octet decimal
Full
Host
Subnet mask
Network
Broadcast
First host
Last host
19 Apr 2023 36
192.168.1.70/28
Last octet binary
Last octet decimal
Full
Host 01000110 70 192.168.1.70
Subnet mask 11110000 240 255.255.255.240
Network 01000000 64 192.168.1.64
Broadcast 01001111 79 192.168.1.79
First host 01000001 65 192.168.1.65
Last host 01001110 78 192.168.1.78
19 Apr 2023 37
Unicast, Multicast, Broadcast
Unicast – a message addressed to one host Broadcast – a message addressed to all
hosts on a network. Uses network’s broadcast address or 255.255.255.255 locally
Multicast – a message addressed to a group of hosts. Uses an address starting 224 - 239
19 Apr 2023 38
Private IP addresses
Unrestricted use on private networks. Not routed across the Internet.
10.0.0.0 – 10.255.255.255 (10.0.0.0/8) 172.16.0.0 – 172.31.255.255 (172.16.0.0/20) 192.168.0.0 – 192.168.255.255
(192.168.0.0/24)
19 Apr 2023 39
Public IP addresses
Routed over the Internet Master holder is IANA (Internet Assigned
Numbers Authority) Assigned to regional registries and then to
ISPs ISPs allocate them to organisations and
individual users Use is strictly controlled as duplicate
addresses are not allowed
19 Apr 2023 40
Special addresses
0.0.0.0 “all addresses” in default route. Hosts cannot be given addresses starting 0.
127.0.0.1 is loopback. Hosts cannot be given addresses starting 127.
240.0.0.0 and higher – reserved for experimental purposes.
169.254.0.0 - 169.254.255.255 local only 192.0.2.0 to 192.0.2.255 for teaching
19 Apr 2023 41
Network address translation
A large number of hosts on a network use private addresses to communicate with each other.
The ISP allocates one or a few public addresses.
NAT allows the hosts to share the public addresses when they want to use the Internet
19 Apr 2023 42
Addressing hosts
Static addressing – address is configured by an administrator
Servers, printers, routers, switches need static addresses
Dynamic addressing – address is allocated automatically by DHCP by leasing addresses from a pool
Dynamic addressing is best for workstations
19 Apr 2023 43
Subnetting 192.168.1.0/24
Address 192.168.1.0 00000000
Subnet mask 255.255.255.0 00000000
Last octet binary
Borrow 1 bit from host part, give it to network part, /25
Addresses 192.168.1.0192.168.1.128
0000000010000000
Subnet mask 255.255.255.128 10000000
19 Apr 2023 44
Subnetting 192.168.1.0/24
Borrow 2 bits from host part, give to network part, /26
Addresses 192.168.1.0192.168.1.64192.168.1.128192.168.1.192
00000000010000001000000011000000
Subnet mask 255.255.255.192 11000000
19 Apr 2023 45
Subnetting 192.168.1.0/24
Borrow 3 bits from host part, give to network part, /27
Addresses 192.168.1.0192.168.1.32192.168.1.64192.168.1.96192.168.1.128 192.168.1.160 192.168.1.192 192.168.1.224
0000000000100000010000000110000010000000101000001100000011100000
Subnet mask 255.255.255.224 11100000
19 Apr 2023 46
Subnetting 192.168.1.0/24
Borrow 4 bits from host part, give to network part, /28
192.168.1.0192.168.1.16192.168.1.32192.168.1.48192.168.1.64192.168.1.80192.168.1.96192.168.1.112
192.168.1.128192.168.1.144192.168.1.160192.168.1.176 192.168.1.192192.168.1.208192.168.1.224192.168.1.240
0000000000010000001000000011000001000000010100000110000001110000
1000000010010000 1010000010110000 1100000011010000 1110000011110000
Subnet mask 255.255.255.240 11110000
And so on…
19 Apr 2023 47
Subnetting 192.168.1.0/24
Every time you borrow another bit you: Double the number of subnets Halve the size of the subnets
Each subnet has a network address, a broadcast address, and everything in between is a host address.
Here are some ways of visualising the process.
19 Apr 2023 48
Subnetting 192.168.1.0/24
Bits borrowed 1 2 3 4 5 6
No of networks 2 4 8 16 32 64
Prefix /25 /26 /27 /28 /29 /30
Bit value/ network size
128 64 32 16 8 4
No of hosts 126 62 30 14 6 2
Subnet mask 128 192 224 240 248 252
19 Apr 2023 49
Ping and traceroute
Ping sends an ICMP message. If all is well, the destination replies. If not, a router may reply to say the destination is unreachable, or the ping may time out.
Traceroute sends a series of messages so that each router along the path replies. You get a list of addresses of all the routers.
19 Apr 2023 50
IPv6
Development started in 1990s because of concerns about IPv4 addresses running out
A whole new protocol suite – not just layer 3 Uses 128-bit hierarchical addressing, written
using hexadecimal Simpler header Integrated security – authentication, privacy Quality of service mechanisms
19 Apr 2023 51
Why Subnet?
To break the network down into pieces, each of which can be addressed separately. Controls network traffic Reduces broadcasts Can provide low level security with access lists on
the router Organization of IP address space
19 Apr 2023 52
Subnetting a Default Class C Network Address: 200.129.41.0
Default Class C address is divided into network and host portions as follows:
N . N . N . H To subnet we “borrow” bits from the host portion of the
address (8 bits for Class C)
N . N . N . x x x x x x x x Borrowing n bits yields 2n – 2 subnets. Leaving n bits yields 2n – 2 hosts. For a class C, we can borrow from 2 to 6 bits. Why not 1 bit? (How many usable subnets?) Why not 7 bits? (How many usable hosts?)
19 Apr 2023 53
Subnetting a Default Class C Network Address: 200.129.41.0
Suppose we need 14 usable subnets, how many bits do we borrow? Remember, borrowing n bits give us:
2n – 2 subnets Try borrowing 3 bits (n = 3):
23 – 2 = 8 – 2
= 6 usable subnets (not enough) Try borrowing 4 bits
24 – 2 = 16 – 2
= 14 usable subnets (enough)
19 Apr 2023 54
Subnetting a Default Class C Network Address: 200.129.41.0
Write it with the network octet in binary:
200.129.41.0000 0000
Borrowing 4 bits yields 14 usable subnets How many usable hosts per subnet?
Same formula as subnets (2n – 2) 4 host bits (n = 4) 24 – 2 = 16 – 2
= 14 usable hosts per subnet
subnet bits host bits
Break here
19 Apr 2023 55
Subnetting a Default Class C Network Address: 200.129.41.0
Examples: First usable 200.129.41.0001 ^ 0000
subnet address: 200.129.41.16 First usable host 200.129.41.0001 ^ 0001
on the first subnet: 200.129.41.17 Second usable host 200.129.41.0001 ^ 0010
on the first subnet: 200.129.41.18.
.
.
Last usable host 200.129.41.0001 ^ 1110
on the first subnet: 200.129.41.30 Broadcast address 200.129.41.0001 ^ 1111
for the first subnet: 200.129.41.31
19 Apr 2023 56
Subnetting a Default Class C Network Address: 200.129.41.0
Examples: Second usable 200.129.41.0010 ^ 0000
subnet address: 200.129.41.32 Third usable 200.129.41.0011 ^ 0000
subnet address: 200.129.41.48 Fourth usable 200.129.41.0100 ^ 0000
subnet address: 200.129.41.64
.
.
. Last usable 200.129.41.1110 ^ 0000
subnet address: 200.129.41.224
19 Apr 2023 57
The Subnet Mask: How the Router Determines the Subnet
The subnet mask (in binary) has: all ones in the network and subnet portion of the
address all zeros in the host potion of the address The subnet mask for the previous example is:
255.255.255. 240
255.255.255. 1111^ 0000 (128 + 64 + 32 + 16 =240) ANDing this mask with any valid host address on the
network will always yield the subnet address for that host.
19 Apr 2023 58
The Subnet Mask: How the Router Determines the Subnet
Example (our subnet mask is 255.255.255.240)
IP host address: 200.129. 41.23
Last octet to binary: 200.129. 41.0001 0111
AND subnet mask: 255.255.255.1111 0000
200.129. 41.0001 0000
Subnet Address: 200.129. 41.16
So the host address 200.129. 41.23 is on the 200.129.41.16 subnet.
19 Apr 2023 59
Subnetting a Default Class B Network Address: 132.178.0.0
Default Class B address is divided into network and host portions as follows:
N . N . H . H To subnet we “borrow” bits from the host
portion of the address (16 bits for Class B)
N . N . x x x x x x x x . x x x x x x x x For a class B, we can borrow from 2 to 14 bits.
19 Apr 2023 60
Subnetting a Default Class B Network Address: 132.178.0.0
Suppose we need 80 usable subnets, how many bits do we borrow? Remember, borrowing n bits give us:
2n – 2 subnets Try borrowing 6 bits (n = 6):
26 – 2 = 64 – 2
= 62 usable subnets (not enough) Try borrowing 7 bits
27 – 2 = 128 – 2
= 126 usable subnets (enough)
19 Apr 2023 61
Subnetting a Default Class B Network Address: 132.178.0.0
Write it with the network octets in binary:
132.178.0000000 0.00000000
Borrowing 7 bits yields 126 usable subnets How many usable hosts per subnet?
Same formula as subnets (2n – 2) 9 host bits (n = 9) 29 – 2 = 512 – 2
= 510 usable hosts per subnet
subnet bits host bits
19 Apr 2023 62
Subnetting a Default Class B Network Address: 132.178.0.0
Examples: First usable 132.178.0000001 ^ 0.00000000
subnet address: 132.178.2.0 First usable host 132.178.0000001 ^ 0.00000001
on the first subnet: 132.178.2.1 Second usable host 132.178.0000001 ^ 0.00000010
on the first subnet: 132.178.2.2 . . .
Last usable host 132.178.0000001 ^ 1.11111110on the first subnet: 132.178.3.254
Broadcast address 132.178.0000001 ^ 1.11111111 for the first subnet: 132.178.3.255
19 Apr 2023 63
Subnetting a Default Class B Network Address: 132.178.0.0
Examples: Second usable 132.178.0000010 ^ 0.00000000
subnet address: 132.178.4.0 Third usable 132.178.0000011 ^ 0.00000000
subnet address: 132.178.6.0 . . .
Ninety-first usable 132.178.1011011 ^ 0.00000000subnet address: 132.178.182.0
. . .
Last usable 132.178.1111110 ^ 0.00000000subnet address: 132.178.252.0
19 Apr 2023 64
Subnetting a Default Class B Network Address: 132.178.0.0
The subnet mask for this example is:255.255.254.0
255.255.1111111 ^ 0.00000000
ANDing this mask with any valid host address on this network will always yield the subnet address.
19 Apr 2023 65
Subnetting a Default Class B Network Address: 132.178.0.0
Example:IP host address: 132.178.119.112
Last octets to binary: 132.178.0111011 ^ 1.01110000
AND subnet mask: 255.255.1111111 ^ 0.00000000
132.178.0111011 ^ 0.00000000
Subnet Address: 132.178.118.0
Which subnet is this. How can you tell?
19 Apr 2023 66
Additional Info on subnetting
19 Apr 2023 67
The End