NIC and MAC address
A network interface card (NIC) is the hardware that lets a device connect to a network, by cable or by Wi-Fi. Today it is usually built into the main board.
Every NIC has a MAC address (media access control address). It is assigned when the NIC is manufactured and is unique to that device.
A MAC address is 48 bits, written as 12 hexadecimal digits in 6 pairs, e.g. `00:1A:2B:3C:4D:5E`.
The first half is the manufacturer code (who made it). The second half is the serial code (which device it is).
e.g.ExampleMAC address 00:1A:2B:3C:4D:5E
Manufacturer code: 00:1A:2B
Serial code: 3C:4D:5E
48 bits gives 2⁴⁸ = 281,474,976,710,656 possible addresses.
?Why?Hex is used because 48 binary digits are too long for people to read. Each hex digit stands for 4 bits, so 12 hex digits = 48 bits.
IP address: IPv4 and IPv6
An IP address identifies a device on a network, and lets data be sent to the right place across the internet. It is given to the device by the network it joins, so it can change.
IPv4: 32 bits, written as four denary numbers from 0 to 255, separated by dots, e.g. `192.168.1.20`. This gives 2³² = 4,294,967,296 addresses.
IPv6: 128 bits, written as eight groups of four hex digits, separated by colons, e.g. `2001:0db8:85a3:0000:0000:8a2e:0370:7334`.
IPv6 was created because the world was running out of IPv4 addresses. Every phone, laptop and smart device needs one.
e.g.ExampleIPv4 192.168.1.20 in binary, 8 bits per number:
11000000.10101000.00000001.00010100
IPv6 groups of zeros can be shortened with ::
2001:0db8:85a3:0000:0000:8a2e:0370:7334 → 2001:db8:85a3::8a2e:370:7334
Try it in the toy: type 192.168.1.20 in the IPv4 tab, and the long IPv6 address above in the IPv6 tab, to check both answers. Then open the MAC address tab and compare the parts.
!Watch outA MAC address is fixed to the hardware. An IP address belongs to the connection and can change. A phone keeps its MAC address but gets a new IP address on school Wi-Fi.
There is something to try for this step in the IGCSE library.
Static and dynamic IP addresses
A static IP address is permanent. It does not change each time the device connects.
A dynamic IP address is assigned automatically each time the device connects, and can be different next time. It is given out by a server, often the router.
Static addresses are used for servers (such as a website or a school printer), so other devices can always find them. Dynamic addresses suit ordinary users.
The router
A router sends data packets to their destination. It reads the destination IP address in each packet's header and forwards it on the best route.
It connects a local network to the internet, for example a home or school network to the Internet Service Provider.
It also assigns IP addresses (dynamic, private ones) to the devices on the local network.
e.g.ExampleAt home, your laptop gets 192.168.1.20 from the router. You visit a website. The router sends your packets out to the internet, and passes the replies back to your laptop and not to your sister's phone.
?Why?This links back to topic 2: packet switching only works because routers read headers and choose routes.