BGP and inter-domain routing in Computer Networks - Time & Space Complexity
When studying BGP and inter-domain routing, it is important to understand how the time to process routing updates grows as the network size increases.
We want to know how the routing decisions and message exchanges scale when more networks connect.
Analyze the time complexity of the following simplified BGP update processing.
for each received_update in updates:
for each route in routing_table:
if route conflicts with received_update:
update route
add new routes from received_update
This code processes each BGP update by checking existing routes and updating or adding routes accordingly.
Look at the loops and repeated checks in the code.
- Primary operation: The inner loop that checks each route in the routing table for conflicts.
- How many times: For each update received, it loops through all routes in the routing table.
As the number of updates and routes grows, the work increases.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 updates, 10 routes | About 100 checks |
| 100 updates, 100 routes | About 10,000 checks |
| 1000 updates, 1000 routes | About 1,000,000 checks |
Pattern observation: The number of operations grows quickly as both updates and routes increase, roughly multiplying together.
Time Complexity: O(n * m)
This means the time to process updates grows proportionally to the number of updates times the number of routes.
[X] Wrong: "Processing each update takes the same fixed time regardless of routing table size."
[OK] Correct: Each update must be checked against many routes, so more routes mean more work and longer processing time.
Understanding how routing update processing scales helps you explain network performance and design choices clearly in discussions or interviews.
What if the routing table used a data structure that allows faster lookups? How would the time complexity change?
Practice
Solution
Step 1: Understand BGP's role
BGP is designed to connect different large networks, called autonomous systems, on the internet.Step 2: Identify BGP's function
It shares routing information to find the best path for data between these networks.Final Answer:
To exchange routing information between different large networks on the internet -> Option BQuick Check:
BGP = Routing between large networks [OK]
- Confusing BGP with encryption protocols
- Thinking BGP assigns IP addresses
- Mixing BGP with local network management
Solution
Step 1: Recall BGP neighbor syntax
The standard BGP command to define a neighbor includes the keyword 'neighbor', the IP address, and 'remote-as' followed by the AS number.Step 2: Match syntax to options
neighbor 192.168.1.1 remote-as 65001 matches this format exactly: 'neighbor 192.168.1.1 remote-as 65001'. Others mix order or keywords incorrectly.Final Answer:
neighbor 192.168.1.1 remote-as 65001 -> Option AQuick Check:
neighbor IP remote-as AS_number = correct syntax [OK]
- Swapping the order of IP and AS number
- Using 'set' instead of 'neighbor'
- Placing 'remote-as' before IP address
AS Path: 65001 65002 65003 AS Path: 65001 65004 AS Path: 65005 65003Which AS path will BGP prefer to route traffic?
Solution
Step 1: Understand BGP path selection criteria
BGP prefers the path with the shortest AS path length to reduce the number of hops.Step 2: Compare AS path lengths
Paths lengths are: 3 for '65001 65002 65003', 2 for '65001 65004', and 2 for '65005 65003'. Among these, the shortest paths are the ones with length 2.Step 3: Consider origin and other attributes
Since no other attributes are given, BGP will prefer the path with the shortest AS path regardless of starting AS. Both '65001 65004' and '65005 65003' have length 2, but BGP prefers the path with the lowest next-hop IP or other tie-breakers. Without additional info, the shortest path is preferred. So either could be correct, but typically the path starting with the local AS is preferred. However, since local AS is not specified, the shortest path is the main factor.Final Answer:
AS Path: 65005 65003 -> Option CQuick Check:
Shortest AS path length = preferred [OK]
- Choosing longest AS path
- Ignoring AS path length
- Assuming all paths are equal
Solution
Step 1: Identify common BGP neighbor issues
If no routes are exchanged, a common cause is that the neighbor IP is wrong or unreachable, preventing session establishment.Step 2: Evaluate other options
Hostname settings do not affect BGP neighbor sessions. Missing default gateway or subnet mask issues may affect general connectivity but are less direct causes than neighbor IP errors.Final Answer:
The neighbor IP address is incorrect or unreachable -> Option DQuick Check:
Neighbor IP correct and reachable = routes exchanged [OK]
- Ignoring neighbor IP correctness
- Blaming unrelated settings like hostname
- Overlooking basic connectivity issues
Solution
Step 1: Understand BGP path preference controls
BGP chooses routes based on path attributes like AS path length. To prefer one ISP's route, you can make the other ISP's path look longer.Step 2: Apply AS path prepending
AS path prepending adds extra AS numbers to the path advertised to ISP B, making it appear longer and less preferred.Step 3: Evaluate other options
Changing hostname or using static routes won't affect BGP path selection properly. Disabling BGP on ISP B is extreme and not practical.Final Answer:
AS path prepending to make ISP B's path appear longer -> Option AQuick Check:
AS path prepending = prefer one ISP over another [OK]
- Thinking hostname affects routing preference
- Using static routes instead of BGP
- Disabling connections instead of adjusting path attributes
Ready to prove it?
Pass the test and this pattern moves unknown
