MCS 8106 6/12/2025
IPv4 Addressing: introduction
• IP address: 32-bit identifier for 223.1.1.1
host, router interface 223.1.2.1
IPv4 Addressing & Subnetting
• Interface: connection between 223.1.1.2
223.1.1.4 223.1.2.9
host/router and physical link
– routers typically have multiple interfaces 223.1.3.27
223.1.2.2
223.1.1.3
– IP addresses associated with each
interface.
223.1.3.1 223.1.3.2
223.1.1.1 = 11011111 00000001 00000001 00000001
223 1 1 1
1 2
Octets IP Address Classes
• An IP address is made up of 4 bytes • IP addresses are divided into 5 classes, each of which is designated with the
• The 32-bit IP address is broken up into 4 octets, which are arranged into a dotted- alphabetic letters A to E.
decimal notation scheme. • Class D addresses are used for multicasting.
• An octet is a set of 8 bits • Class E addresses are reserved for testing
• Example of an IP version 4: 172.64.126.52
3 4
MCS 8106 6/12/2025
IP Address Classes Are You the Host or the Network?
• The 5 IP classes are split up based on the value in the 1st octet. • The 32 bits of the IP address are divided into Network & Host portions, with the
• Using the ranges, you can determine the class of an address from its 1st octet value. octets assigned as a part of one or the other.
• An address beginning with 120 is a Class A address, 155 is a Class B address & 220 is
a Class C address. Network & Host Representation
By IP Address Class
Class Octet1 Octet2 Octet3 Octet4
Class A Network Host Host Host
Class B Network Network Host Host
Class C Network Network Network Host
5 6
Are You the Host or the Network? Class A Addresses
• Each network is assigned a network address & every device or interface (such as a • Class A IP addresses use the first 8 bits (1st Octet) to designate the Network address.
router port) on the network is assigned a host address. • The 1st bit of the first octet which is always a 0, is used to indicate the address as a
• There are only 2 specific rules that govern the value of the address: Class A address & the remaining 7 bits are used to designate the Network.
– A host address cannot be designated by all zeros or all ones. • The other 3 octets contain the Host address.
– These are special addresses that are reserved for special purposes.
7 8
MCS 8106 6/12/2025
Class A Addresses Class A Addresses
• There are 128 Class A Network Addresses, but because addresses with all zeros • There are 16,777,214 Host addresses available in a Class A address.
aren’t used & address 127 is a special purpose address, 126 Class A Networks are • Rather than remembering this number exactly, you can use the following formula to
available. compute the number of hosts available in any of the class addresses, where “n”
represents the number of bits in the host portion:
(2n – 2) = Number of available hosts
• 2 is subtracted because the first e.g 115.0.0.0 refers to the subnet and
115.255.255.255 refers to a broadcast IP address.
9 10
Class A Addresses Class B IP Addresses
• For a Class A network, there are: • Class B addresses use the 1st 16 bits (two octets) for the Network address.
224 – 2 or 16,777,214 hosts. • The last 2 octets are used for the Host address.
• You can use the same formula to determine the number of Networks in an address • The first two bits, which are always 10, designate the address as a Class B address &
class. 14 bits are used to designate the Network.
• Eg., a Class A address uses 7 bits to designate the network, so (27 – 2) = 126 or there
can be 126 Class A Networks. • This leaves 16 bits (two octets) to designate the Hosts.
11 12
MCS 8106 6/12/2025
Class B IP Addresses Class C IP Addresses
• So how many Class B Networks can there be? • Class C addresses use the 1st 24 bits (three octets) for the Network address & only
• Using our formula, (214 – 2), there can be 16,382 Class B Networks & each Network the last octet for Host addresses.
can have (216 – 2) Hosts, or 65,534 Hosts. • The 1st 3 bits of all class C addresses are set to 110, leaving 21 bits for the Network
address, which means:
– there can be 2,097,150 (221 – 2) Class C Networks,
– but only 254 (28 – 2) Hosts per Network.
13 14
Classes IP Addresses - Summary Special Addresses
• A few addresses are set aside for specific purposes.
• Network addresses that are all binary zeros, all binary ones & network addresses
beginning with 127 are special Network addresses.
15 16
MCS 8106 6/12/2025
Special Addresses Special Addresses – Private address space
• Within each address class is a set of addresses that are set aside for use in
Default route: local networks sitting behind a firewall or NAT (Network Address
Translation) device or Networks not connected to the Internet.
• In computer networking,
the default route is a setting on a
computer that defines the packet • A list of these addresses for each IP address class that are available for use
forwarding rule to use when no in a LAN.
specific route can be determined • This is the private address space
for a given Internet Protocol (IP)
destination address.
• All packets for destinations not
established in the routing table
are sent via the default route.
17 18
Default Standard Subnet Masks Subnet Mask
• There are default standard subnet masks for Class • An IP address has 2 parts:
A, B and C addresses: – The Network identification.
– The Host identification.
• Frequently, the network & host portions of the address need to be separately
extracted.
• In most cases, if you know the address class, it’s easy to separate the 2 portions.
• The subnet masking process was developed to identify & extract the network and
host part of the address.
19 20
MCS 8106 6/12/2025
Subnets Subnets 223.1.1.2
223.1.1.1 223.1.1.1 223.1.1.4
• IP address consist of: 223.1.2.1 • How many?
223.1.1.2 223.1.1.3
– Subnet/network part (high order 223.1.1.4 223.1.2.9
bits) 223.1.9.2 223.1.7.0
223.1.2.2
– host part (low order bits) 223.1.1.3 223.1.3.27
• What’s a subnet ? LAN
– device interfaces with same 223.1.3.1 223.1.3.2 223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0
subnet/network part of IP address
– can physically reach each other 223.1.2.6 223.1.3.27
without intervening router network consisting of 3 subnets
223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2
21 22
Features of CIDR
• Elimination of classful addressing
• Classless Addressing
Classless Interdomain Routing
(CIDR)
23 24
MCS 8106 6/12/2025
IP addressing: CIDR IP addresses: how to get one?
• CIDR: Classless InterDomain Routing • Q: How does a host get IP address?
– subnet portion of address can of be arbitrary length • Two options:
– address format: a.b.c.d/x, where x is # bits in subnet portion of address – Given/hard-coded by system admin
– DHCP: Dynamic Host Configuration Protocol: dynamically get address from as server
• “plug-and-play”
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23
25 26
IP addresses: how to get one? IP addressing: the last word...
• Q: How does network get subnet part of IP address? • Q: How does an ISP get block of addresses?
• A: gets allocated portion of its provider ISP’s address space • A: ICANN: Internet Corporation for Assigned Names and Numbers:
– Allocates addresses
– Manages DNS (Domain Name System). DNS – Converts web address to IP address.
ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20
– Assigns domain names, resolves disputes
Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23
Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23
Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
... ….. …. ….
Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
27 28
MCS 8106 6/12/2025
NAT: Network Address Translation
rest of local network
Internet (e.g., home network)
10.0.0/24 10.0.0.1
Network Address Translation 10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
All datagrams leaving local Datagrams with source or
network have same single source NAT IP destination in this network
address: 138.76.29.7, have 10.0.0/24 address for
different source port numbers source, destination (as usual)
29 30
NAT: Network Address Translation NAT: Network Address Translation
NAT translation table
1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
sends datagram to • Motivation: local network uses just one IP address as far as outside
changes datagram
source addr from
138.76.29.7, 5001 10.0.0.1, 3345
…… ……
128.119.40, 80 word is concerned:
10.0.0.1, 3345 to
138.76.29.7, 5001,
– No need to be allocated range of addresses from ISP: - just one IP address is used
updates table
S: 10.0.0.1, 3345
D: 128.119.40.186, 80 for all devices
10.0.0.1
1 – Can change addresses of devices in local network without notifying outside
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4 world
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
– Can change ISP without changing addresses of devices in local network
4
S: 128.119.40.186, 80
3
D: 10.0.0.1, 3345
– Devices inside local net not explicitly addressable, visible by outside world (a
D: 138.76.29.7, 5001 10.0.0.3
3: Reply arrives
4: NAT router security plus).
changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345
31 32
MCS 8106 6/12/2025
ICMP: Internet Control Message Protocol
• Used by hosts & routers to communicate network-level information
– error reporting: unreachable host or network
ICMP and Traceroute – used by ping
• ICMP messages carried in IP datagrams
33 34
Traceroute
• The Traceroute or Trace command is used to show the complete route from a source
to a destination.
• Trace sends out probe packets one at a time to each router or switch in the path
between the source & the destination IP address entered.
35