/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Problem 53 Propose a lookup algorithm for a... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Propose a lookup algorithm for a CIDR fowarding table that does not require a linear search of the entire table to find the longest match.

Short Answer

Expert verified
Use a trie data structure to efficiently insert and lookup CIDR prefixes, which allows you to find the longest prefix match without performing a linear search.

Step by step solution

01

Title - Understand CIDR and Forwarding Tables

CIDR stands for Classless Inter-Domain Routing and is used for IP address allocation and route aggregation. A forwarding table contains routes that guide the forwarding of packets to their destinations. CIDR allows for variable-length subnet masking, which means subnet masks can be of any length.
02

Title - Conceptualize Trie-based Data Structure

Consider using a trie, a tree-like data structure, where each node represents a bit in the IP address. A trie supports fast lookups and is efficient for longest prefix matching used in CIDR forwarding.
03

Title - Initialize the Trie

Initialize the trie root node. Each trie node can have at most two children: one representing bit ‘0’ and the other representing bit ‘1’. The root node represents the start of any IP prefix.
04

Title - Insert Prefixes into the Trie

For each CIDR prefix in the forwarding table, insert it into the trie. Traverse the trie based on each bit of the prefix. When you reach the end of the prefix, mark that node as a valid endpoint.
05

Title - Implement the Lookup Function

For a given destination IP, traverse the trie according to its bits. Keep track of the longest prefix found during traversal. If a valid endpoint is found, update the longest prefix match before continuing.
06

Title - Return Longest Match

Once traversal is complete, return the longest prefix match found. This endpoint will be the longest matching prefix in the forwarding table for the given IP address.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

Key Concepts

These are the key concepts you need to understand to accurately answer the question.

CIDR (Classless Inter-Domain Routing)
CIDR stands for Classless Inter-Domain Routing, and it revolutionized IP address allocation and routing.
Instead of using the traditional classful network design (classes A, B, and C), CIDR allows for flexible and more efficient allocation, using variable-length subnet masking.
This means that an IP address and its subnet mask are noted together in the format: prefix/length (e.g., 192.168.1.0/24).
This provides flexibility and helps in preventing the wastage of IP addresses, which is crucial as the internet grows.
CIDR is essential for efficient route aggregation and routing using the CIDR forwarding algorithm.
Trie Data Structure
A trie, also known as a prefix tree, is an efficient data structure for storing a dynamic set of strings.
Each node in a trie represents a single character of a string. When used for IP routing, each node represents a bit of the IP address.
Here’s why a trie is useful:
  • Fast Lookup: Tries give rapid search results and are proficient in prefix matching.
  • Space-efficient: Tries can be space-efficient if they share common prefixes between strings (or IP addresses).
In the context of CIDR and IP routing, each path from the root to a node represents a potential IP address prefix, which assists in quick lookup and insertion operations.
Longest Prefix Matching
Longest prefix matching is a core principle in IP routing.
When a packet is routed, the router needs to determine which rule to apply from its forwarding table.
It does this by finding the most specific rule that matches the destination IP address - essentially the longest matching prefix.
This ensures packets are routed accurately to their destinations.
For instance, if the forwarding table has rules for 192.168.1.0/24 and 192.168.1.128/25, and a packet needs to be forwarded to 192.168.1.130, the router will use the rule 192.168.1.128/25 because it’s a longer (more specific) prefix match.
IP Routing
IP routing is the process that enables data packets to travel across different networks to reach their destination.
The router determines the best path for forwarding packets based on the destination IP address in the forwarding table.
Routers use various algorithms and protocols, like RIP, OSPF, and BGP, to keep their forwarding tables updated.
In the context of a CIDR forwarding table, the router doesn’t perform a linear search.
Instead, it uses data structures like tries to efficiently locate the longest prefix match, which significantly speeds up the lookup process.
Forwarding Table
A forwarding table, also known as a routing table, is an essential component in routers.
This table contains a set of rules that determine the next hop for incoming packets.
Each entry in the table usually includes:
  • The destination network (CIDR prefix)
  • The subnet mask
  • The next-hop IP address or interface
The primary function of the forwarding table is to facilitate the quick lookup process.
Combining CIDR and tries, routers can efficiently match incoming packets to the longest matching prefix in the forwarding table and send them along the optimal path.

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Suppose IP routers learned about IP networks and subnets the way Ethernet learning bridges learn about hosts: by noting the appearance of new ones and the interface by which they arrive. Compare this with existing distance-vector router learning (a) for a leaf site with a single attachment to the Internet, and (b) for internal use at an organization that did not connect to the Internet. Assume that routers only receive new-network notices from other routers, and that the originating routers receive their IP network information via configuration.

Suppose an IP implementation adheres literally to the following algorithm on receipt of a packet, \(\mathrm{P}\), destined for IP address \(\mathrm{D}\) : if ( Ethernet address for D is in ARP cache)) (send P) else (send out an ARP query for D) (put \(P\) into a queue until the response comes back) (a) If the IP layer receives a burst of packets destined for D, how might this algorithm waste resources unnecessarily? (b) Sketch an improved version. (c) Suppose we simply drop P, after sending out a query, when cache lookup fails. How would this behave? (Some early ARP implementations allegedly did this.)

Suppose a network \(N\) within a larger organization \(A\) acquires its own direct connection to an Internet service provider, in addition to an existing connection via A. Let \(R 1\) be the router connecting \(N\) to its own provider, and let \(R 2\) be the router connecting \(N\) to the rest of \(A\). (a) Assuming \(\mathrm{N}\) remains a subnet of A, how should R1 and R2 be configured? What limitations would still exist with N's use of its separate connection? Would A be prevented from using N's connection? Specify your configuration in terms of what R1 and R2 should advertise, and with what paths. Assume a BGP-like mechanism is available. (b) Now suppose \(N\) gets its own network number; how does this change your answer in (a)? (c) Describe a router configuration that would allow A to use N's link when its own link is down.

Suppose \(\mathrm{P}, \mathrm{Q}\), and \(\mathrm{R}\) are network service providers, with respective CIDR address allocations (using the notation of Exercise 45) C1.0.0.0/8, C2.0.0.0/8, and \(C 3.0 .0 .0 / 8\). Each provider's customers initially receive address allocations that are a subset of the provider's. P has the following customers: PA, with allocation C1.A3.0.0/16, and PB, with allocation C1.B0.0.0/12. Q has the following customers: QA, with allocation C2.0A.10.0/20, and \(\mathrm{QB}\), with allocation \(\mathrm{C} 2.0 \mathrm{~B} .0 .0 / 16\). Assume there are no other providers or customers. (a) Give routing tables for \(\mathrm{P}, \mathrm{Q}\), and \(\mathrm{R}\), assuming each provider connects to both of the others. (b) Now assume \(P\) is connected to \(Q\) and \(Q\) is connected to \(R\), but \(P\) and \(R\) are not directly connected. Give tables for \(\mathrm{P}\) and \(\mathrm{R}\). (c) Suppose customer PA acquires a direct link to Q, and QA acquires a direct link to \(\mathrm{P}\), in addition to existing links. Give tables for \(\mathrm{P}\) and \(\mathrm{Q}\), ignoring \(\mathrm{R}\).

Suppose a TCP message that contains 2048 bytes of data and 20 bytes of TCP header is passed to IP for delivery across two networks of the Internet (i.e., from the source host to a router to the destination host). The first network uses 14-byte headers and has an MTU of 1024 bytes; the second uses 8-byte headers with an MTU of 512 bytes. Each network's MTU gives the size of the largest IP datagram that can be carried in a link-layer frame. Give the sizes and offsets of the sequence of fragments delivered to the network layer at the destination host. Assume all IP headers are 20 bytes.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.