MAC addressing in Computer Networks - Time & Space Complexity
When working with MAC addressing, it is important to understand how the process of looking up or managing MAC addresses grows as the network size increases.
We want to know how the time to find or handle a MAC address changes when there are more devices on the network.
Analyze the time complexity of the following MAC address lookup process.
function findMacAddress(macTable, targetMac) {
for (let entry of macTable) {
if (entry.mac === targetMac) {
return entry.port;
}
}
return null;
}
This code searches through a list of MAC address entries to find the port associated with a target MAC address.
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Looping through each MAC address entry in the table.
- How many times: Up to once for each entry until the target is found or the list ends.
As the number of MAC addresses in the table grows, the time to find one may grow roughly in direct proportion.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | Up to 10 checks |
| 100 | Up to 100 checks |
| 1000 | Up to 1000 checks |
Pattern observation: The number of checks grows linearly with the number of MAC addresses.
Time Complexity: O(n)
This means the time to find a MAC address grows directly with the number of addresses stored.
[X] Wrong: "Finding a MAC address always takes the same time no matter how many devices there are."
[OK] Correct: Because the search checks each entry one by one, more entries mean more time needed.
Understanding how MAC address lookup time grows helps you explain network device behavior clearly and shows you can think about efficiency in real systems.
"What if the MAC addresses were stored in a hash table instead of a list? How would the time complexity change?"
Practice
Solution
Step 1: Understand the role of MAC addresses
A MAC address is a unique identifier assigned to network interfaces for communications on the physical network segment.Step 2: Identify what MAC addresses represent
They identify devices on a local network, not IP addresses or domain names.Final Answer:
A device on a local network -> Option DQuick Check:
MAC address = device ID on local network [OK]
- Confusing MAC address with IP address
- Thinking MAC identifies websites
- Assuming MAC is a protocol
Solution
Step 1: Recognize MAC address format
MAC addresses are shown as six pairs of hexadecimal numbers separated by colons or dashes.Step 2: Match the correct format
00:1A:2B:3C:4D:5E matches this format: six pairs separated by colons with hex digits.Final Answer:
00:1A:2B:3C:4D:5E -> Option AQuick Check:
MAC format = hex pairs separated by colons [OK]
- Confusing MAC with IP address format
- Including URL or protocol parts
- Using decimal numbers instead of hex
AC:DE:48:00:11:22, which part typically identifies the manufacturer?Solution
Step 1: Understand MAC address structure
The first three pairs (first 24 bits) of a MAC address identify the manufacturer, called the OUI (Organizationally Unique Identifier).Step 2: Identify the first three pairs
In AC:DE:48:00:11:22, the first three pairs are AC:DE:48, which represent the manufacturer.Final Answer:
AC:DE:48 -> Option CQuick Check:
First 3 pairs = manufacturer ID [OK]
- Choosing last three pairs as manufacturer
- Mixing pairs in the middle
- Not knowing OUI meaning
00-1G-2B-3C-4D-5E. What is wrong with this MAC address?Solution
Step 1: Check valid characters in MAC address
MAC addresses use hexadecimal digits: 0-9 and A-F only.Step 2: Identify invalid character
The character 'G' is not a valid hex digit, so the MAC address is invalid.Final Answer:
It has an invalid character 'G' -> Option BQuick Check:
Hex digits only: 0-9, A-F [OK]
- Ignoring invalid hex characters
- Confusing dashes and colons as errors
- Counting pairs incorrectly
00:1A:2B. Which method best uses MAC addresses to do this?Solution
Step 1: Understand OUI position in MAC address
The OUI is always the first three pairs of the MAC address, identifying the manufacturer.Step 2: Choose the correct filtering method
To filter devices by manufacturer, check if the MAC address starts with the OUI '00:1A:2B'.Final Answer:
Check if the MAC address starts with '00:1A:2B' -> Option AQuick Check:
OUI = start of MAC address [OK]
- Checking MAC end instead of start
- Looking for OUI in the middle
- Assuming OUI can be anywhere
Ready to prove it?
Pass the test and this pattern moves unknown
