IP Network: Route Summarization

IP Network: Route Summarization

An IP network is a set of routers that communicate routing information using a protocol. A router is uniquely identified by an IP address.
In IPv4, an IP address consists of 32 bits, canonically represented as 4 decimal numbers of 8 bits each. The decimal numbers range from 0 (00000000) to 255 (11111111).
Each router has a "routing table" that contains a list of IP addresses, for the router to know where to send IP packets.

Route summarization in IP networks

As the network grows large (hundreds of routers), the number of IP addresses in the routing table increases rapidly. Maintaining a high number of IP addresses in the routing table would result in a loss of performances (memory, bandwidth and CPU resources limitation).
Route summarization, also called route aggregation, consists in reducing the number of routes by aggregating them into a "summary route".

Let's consider the following example:

summary route

We have 4 routers connected to A . A is aware about all 4 IP addresses, because it has a direct interface to each of them. However, A will not send them all to B .
Instead, it will aggregate the addresses into a summary route, and send this new route to B .
This implies that:

  1. - Less bandwidth is used on the link between A and B .
  2. - B saves memory: it has only one route to store in its routing table
  3. - B saves CPU resources: there are less entries to consider when handling incoming IP packets

Computing a summary route

A has all 4 addresses stored in its routing table.

Address 1 172.16.12.0
Address 2 172.16.13.0
Address 3 ...


A will convert these IP addresses to binary format, align them and find the boundary line between the common prefix on the left (highlighted in red), and the remaining bits on the right.

Address 1 10101100 00010000 000011 00 00000000
Address 2 10101100 00010000 000011 01 00000000
Address 3 10101100 00010000 000011 10 00000000
Address 4 10101100 00010000 000011 11 00000000


A creates a new IP address made of the common bits, and all other bits set to "0".
This new IP address is converted back to decimal numbers.
Finally, A computes the number of common bits, also called "subnet".
The summary route is this new IP address, followed by a slash and the subnet: 172.16.12.0/22

Input: A list of strings containing the IP addresses

Output: A string containing the summary route, represented as an IP address, followed by a slash and the subnet.

Example:

checkio(["172.16.12.0", "172.16.13.0", "172.16.14.0", "172.16.15.0"]) == "172.16.12.0/22"
checkio(["172.16.12.0", "172.16.13.0", "172.155.43.9"]) == "172.0.0.0/8"
checkio(["172.16.12.0", "172.16.13.0", "172.155.43.9", "146.11.2.2"]) == "128.0.0.0/2"

Preconditions:
all(re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$",d) for d in data))
all(-1 < int(n) < 256 for n in d.split(".") for d in data)
len(data) == len(set(data)) and len(data) > 1

You should be an authorized user in order to see the full description and start solving this mission.
20
Settings
Code:
Other:
Invalid hot key. Each hot key should be unique and valid
Hot keys:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

Pair Programming (Beta-version)

Welcome to Pair Programming! Engage in real-time collaboration on coding projects by starting a session and sharing the provided unique URL with friends or colleagues. This feature is perfect for joint project development, debugging, or learning new skills together. Simply click 'Start Session' to begin your collaborative coding journey!

Waiting for Pair Programming to start...

You are trying to join a pair programming session that has not started yet.

Please wait for the session creator to join.

Waiting for Pair Programming to reconnect...

It looks like the creator of the pair programming session closed the editor window.

It might happen accidentally, so that you can wait for reconnection.

×
 
 
<< <
> >>
exec show

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in a moment
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Go to the next mission