DK

Understanding IP and MAC Addresses

Addressing in Networks

  • Connecting devices in a network requires two things: media and addressing.
  • There are two types of addresses used on computers: IP address and MAC address.
    • IP Address: A logical address that can be changed.
    • MAC Address: A physical address that cannot be changed.

IP Addresses

  • An IP address is made up of 32 bits and consists of four octets.
  • Octet: A box containing eight bits; an IP address has four octets.
    • Each octet contains 8 bits, summing up to 32 bits for the entire IP address.
  • An IP address comprises two things:
    • NID: Network Identifier
    • HID: Host Identifier

NID and HID Explained

  • Network Identifier (NID): Indicates which network a device belongs to.
  • Host Identifier (HID): Identifies a specific device (host) within that network.
  • Analogy with a multistory building with different departments:
    • The building is divided into subnetworks, each representing a department (e.g., sales, accounts, IT, HR).
    • Computers within each department are hosts.
    • When computer PC5 from the sales team wants to send a packet to PC19 in the IT team:
      • HID identifies which computer (PC5) is sending the message.
      • NID identifies which department (IT) the message needs to go to.
      • Once the packet reaches the IT department, HID identifies the specific computer (PC19) to deliver the packet to.

IP Address Representation

  • IP addresses can be represented in:
    • Decimal form: e.g., 192.168.0.1
    • Binary form: e.g., 11000000.10101000.00000000.00000001

MAC Addresses

  • The size of a MAC address is 48 bits.

  • A MAC address is divided into octets.

  • It comprises two parts:

    • OUI: Organizationally Unique Identifier
    • Vendor-specific value (Vendor ID)
  • MAC Addresses are represented in hexadecimal form:

    • e.g., AB:11:22:AA:CC:12
  • OUI is assigned by IEEE to identify the organization that manufactured the network interface card.

  • The vendor ID is assigned by the manufacturer to uniquely identify each network interface card they produce.

Classification of IP Addresses Based on NID and HID

  • IP addresses are classified into three classes: A, B, and C, based on the number of octets reserved for NID and HID.
  • Class A:
    • One octet for NID.
    • Three octets for HID.
  • Class B:
    • Two octets for NID.
    • Two octets for HID.
  • Class C:
    • Three octets for NID.
    • One octet for HID.
  • Class C provides the minimum number of hosts, while class A provides the maximum.

Determining Which Class to Use

  • Class C has one octet (8 bits) for the host ID, allowing for a range of 0 to 255.
  • Formula to calculate the number of possible host:
    • 2^n - 2 where n is the number of bits used for the host ID.
    • Subtract 2 because one address is used for network address, and the other is for broadcast address.
      • Therefore, Class C: 2^8 - 2 = 254 . Usable host addresses ranges from 1 to 254.
  • If you have a small network (up to 254 hosts), Class C is sufficient.
  • Class B has two octets (16 bits) for the host ID, allowing for a range of 0 to 65535.
    * Therefore, Class B: 2^{16} - 2 = 65,534 . Usable host addresses ranges from 1 to 65,534.
  • If you have a medium-sized network (up to 65,534 hosts), Class B is suitable.
  • Class A has three octets (24 bits) for the host ID, allowing for a range of 0 to 16,777,215
    * Therefore, Class A: 2^{24} - 2 = 16,777,214 . Usable host addresses ranges from 1 to 16,777,214.
  • If you have a large network, Class A is more appropriate.

Second Classification: Based on Decimal Range

  • Class A: 0 to 126
  • Class B: 128 to 191
  • Class C: 192 to 223
  • Class D: 224 to 239
  • Class E: 240 to 255

How to Identify the Class

  • By looking at the first octet, we can determine the class of the IP address. For example:
    • If an IP address is 10.10.15.1, the first octet is 10, which falls in the range of Class A (0 to 126).
    • If an IP address is 172.16.2.0.3, the first octet is 172, which falls in the range of Class B (128 to 191).
    • If an IP address is 192.168.1.15, the first octet is 192, which falls in the range of Class C (192 to 223).

Usage of IP Address Classes

  • Classes A, B, and C are used in Local Area Networks (LANs).
  • Class D is reserved for multicasting, which is used to send a message to multiple recipients
    • Addresses in this class typically look like 224.0.0.1 or 224.0.0.5.
  • Class E is a reserved class for scientific research purposes.

Importance of Network ID

  • Devices can only communicate if they are on the same network. If you have devices on different networks, you need to use a router to facilitate communication between them.
  • A switch is not the appropriate device to communicate machines which are lying into different networks.
  • Router is a device which connect different networks.
  • Switch is a device which is used to formation of LAN. All the machines are part of same network.

Subnet Mask

  • With every IP address, there is a subnet mask.
  • The computer is intelligent enough to calculate default subnet mask for every IP, but it is important to be aware of the following:
    • If using a Class A address, the subnet mask should be 255.0.0.0.
    • If using a Class B address, the subnet mask should be 255.255.0.0.
    • If using a Class C address, the subnet mask should be 255.255.255.0.

MAC Address Breakdown

  • A MAC address is divided into two parts.
    • Organizationally Unique Identifier (OUI): Value that companies need to purchase from IEEE.
    • Vendor Specific Value: the value added by the vendor.
  • Whenever the vendor has exhausted all the combinations for the vendor specific value they will purchase a new OUI from IEEE.

Key Differences Summary

  • An IP address is a logical address that can be changed, while a MAC address is a fixed hardware address that cannot be changed.
  • MAC Addresses is inbound on your lend cards.