Edexcel International Advanced Level Computer Science, point 3.1.3
Definition and function
A network address is a number that identifies a device on a network, so that data can be sent to the right place. Two kinds are used together: an IP address (where the device is on the network, used by the router to deliver data between networks) and a MAC address (which device it is, used within a local network).
Why needed
Without unique addresses, a network wouldn't know where to send each packet. Every device must be identifiable.
a. Internet protocol (IP) addresses
An IP address identifies a device's connection to a network. It can change (unless it is static: for example when you move to a different Wi-Fi), and it is allocated by software (often by DHCP).
IPv4
- 32 bits, written as four numbers from 0 to 255, separated by dots (dotted decimal). Each number is one byte (8 bits).
- Example:
192.168.1.10 - Number of addresses: (about 4.3 billion).
- Problem: that is not enough for all the world's devices. Address exhaustion has been delayed by NAT (many private devices sharing one public address), but it is a main reason for IPv6.
IPv6
- 128 bits, written as eight groups of four hexadecimal digits, separated by colons. Each group is 16 bits.
- Example:
2001:0db8:85a3:0000:0000:8a2e:0370:7334 - Shortening: leading zeros in a group can be dropped, and one run of all-zero groups can be replaced by
::, so the example becomes2001:db8:85a3::8a2e:370:7334. - Number of addresses: , which is enough for every device, many times over.
| IPv4 | IPv6 | |
|---|---|---|
| Size | 32 bits | 128 bits |
| Notation | Dotted decimal | Colon-separated hexadecimal |
| Groups | 4 numbers (0 to 255) | 8 groups of 4 hex digits |
| Number of addresses | (about 4.3 billion) | (about ) |
| Example | 192.168.1.10 |
2001:db8::1 |
| Notes | Running out, needs NAT | No shortage, built-in support for newer features |
Public and private addresses
- Public IP addresses are unique across the Internet, and allocated by the ISP.
- Private addresses (such as
192.168.x.x,10.x.x.x) are used inside a home or office network, can be reused in different networks, and aren't routed on the Internet. The router's NAT converts between private and public addresses.
Static and dynamic
- Static: fixed. It's used for servers and printers, since others must always find them.
- Dynamic: given out temporarily by DHCP each time a device joins, so it can change. It's easier to manage, and is typical for phones, laptops and tablets on home networks, which join and leave often.
Address classes
Older IPv4 networks were split into classes, by the first number of the address. The class sets how much of the address is the network part and how much is the host part:
| Class | First number | Network part | Host part | Suits |
|---|---|---|---|---|
| A | 1 to 126 | First byte | Last 3 bytes | A few very large networks (over 16 million hosts each) |
| B | 128 to 191 | First 2 bytes | Last 2 bytes | Medium networks (about 65 000 hosts) |
| C | 192 to 223 | First 3 bytes | Last byte | Many small networks (254 hosts) |
So 192.168.1.10 is a class C address. (Addresses starting 127 are kept for testing the computer itself, and modern networks use subnet masks instead of fixed classes.)
Network part and host part
An IP address has a network part (which network) and a host part (which device on it). A subnet mask shows where the split is. For 192.168.1.10 with mask 255.255.255.0 (also written /24):
- Network:
192.168.1. Host:10. - Number of host addresses (2 are reserved: the network address itself, with host bits all 0, and the broadcast address, with host bits all 1).
In general, with host bits: usable hosts .
b. Media access control (MAC) address
- Definition: a unique identifier assigned to a network interface card (NIC) by its manufacturer.
- Format: 48 bits (6 bytes), written as six pairs of hexadecimal digits, for example
00:1A:2B:3C:4D:5E(or with hyphens).- The first 24 bits identify the manufacturer (the OUI), and the last 24 bits identify the individual card.
- Number of addresses: .
- Function: it identifies the device on a local network. Switches use MAC addresses to deliver frames to the right port.
- Characteristics: it is normally fixed and built into the hardware (it can be changed in software, called spoofing).
IP address and MAC address compared
| IP address | MAC address | |
|---|---|---|
| Identifies | A device's connection (its location on a network) | The physical network card |
| Set by | Network/ISP (software, changes) | Manufacturer (hardware, fixed) |
| Size | 32 bits (IPv4) or 128 bits (IPv6) | 48 bits |
| Used by | Routers, between networks | Switches, within a network |
| Unique? | Within the network (public ones globally) | Globally (in principle) |
How they work together
When a packet travels from your laptop to a website, the IP addresses of the source and destination stay the same all the way, but the MAC addresses change at each hop, as the packet is handed from one device to the next on each local network.
Expressions involving addresses
Typical calculations:
- Number of addresses with bits: .
- IPv4 as a 32-bit number:
192.168.1.10. - Hosts in a subnet: .
- Network address: apply the mask with a bitwise AND (2.2.2) to the address.
Worked example
Task: a network uses the IPv4 address 10.4.77.19 with a subnet mask of 255.255.0.0 (/16). (a) Write the address in binary. (b) Find the network address. (c) How many devices can the network have?
(a) 00001010, 00000100, 01001101, 00010011, so the address is 00001010.00000100.01001101.00010011.
(b) The mask 255.255.0.0 keeps the first two bytes, so the network address is 10.4.0.0 (found by ANDing each byte with the mask: AND and AND ).
(c) There are 16 host bits (the last two bytes), so usable device addresses (the all-0 network address and the all-1 broadcast address 10.4.255.255 are reserved).
Exam tip: know the sizes: IPv4 is 32 bits (4 bytes, dotted decimal), IPv6 is 128 bits (hex), and a MAC is 48 bits (6 hex pairs). Explain why IPv6 exists (IPv4 addresses are running out). For "difference between IP and MAC", say IP is a logical address given by the network and can change, but MAC is a physical address from the manufacturer. For the number of addresses, show .
Check yourself
How many bits are in an IPv4 address and an IPv6 address?
IPv4 has 32 bits and IPv6 has 128 bits.
Why was IPv6 introduced?
IPv4 has only about 4.3 billion addresses, which isn't enough for all the devices that need one, whereas IPv6 has about 3.4 × 10³⁸.
What is a MAC address, and who sets it?
A unique 48-bit identifier for a network interface card, set by the manufacturer and normally fixed in the hardware.
Give one difference between an IP address and a MAC address
An IP address is a logical address allocated by the network that can change and is used by routers. A MAC address is a fixed physical address from the manufacturer, used within a local network.
How many usable host addresses does a subnet with 6 host bits have?
2⁶ − 2 = 62.