Question
An IP router implementing Classless Inter-domain Routing (CIDR) receives a packet with address 131.23.151.76. The router's routing table has the following entries:
| Prefix | Output Interface Identifier |
|---|---|
| 131.16.0.0/12 | 3 |
| 131.28.0.0/14 | 5 |
| 131.19.0.0/16 | 2 |
| 131.22.0.0/15 | 1 |
The identifier of the output interface on which this packet will be forwarded is _____.
Official answer and solution
- Official answer
- 1
- From
- Official GATE 2014 answer key
Solution
Convert the destination IP address and routing table prefixes to binary to find the matching entries and select the one with the longest prefix length.
-
Destination IP Address:
131.23.151.76- First octet: .
- Second octet in binary: .
-
Evaluate Routing Table Entries:
-
Prefix 1:
131.16.0.0/12(length 12, interface 3)
The first 12 bits consist of all 8 bits of octet 1 (131) and the first 4 bits of octet 2.
For16, binary is , so first 4 bits are0001.
For23, first 4 bits are0001.
Since0001matches0001, this prefix matches. (Prefix length = 12) -
Prefix 2:
131.28.0.0/14(length 14, interface 5)
Requires matching first 6 bits of octet 2.
For28, binary is -> first 6 bits are000111.
For23, first 6 bits are000101.
000111!=000101, so no match. -
Prefix 3:
131.19.0.0/16(length 16, interface 2)
Requires matching all 8 bits of octet 2 ().
Packet has , so no match. -
Prefix 4:
131.22.0.0/15(length 15, interface 1)
Requires matching first 7 bits of octet 2.
For22, binary is -> first 7 bits are0001011.
For23, binary is -> first 7 bits are0001011.
Since0001011matches0001011, this prefix matches! (Prefix length = 15)
-
-
Longest Prefix Match Rule:
Between the matching prefixes/12(interface 3) and/15(interface 1), the longest prefix is/15.
The associated interface identifier is 1.
1
Selecting the first matching entry in table order instead of finding the longest matching prefix.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2014 Computer Science and Information Technology (CS) Session 3
- Question
- 36 of 65, printed as CS Q.26
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.