Question
we will measure how long prefix Announcements last before they are withdrawn. This matters because, when a prefix gets Advertised and then Withdrawn, this information
This task will use cache files from the update_files subdirectories. These are update files, so you will pass "upd-file" in your call to set_data_interface_option(). Using the data from the cache files, we will measure how long prefix Announcements last before they are withdrawn by completing the function aw_event_durations(). Make sure that your function returns the data structure exactly as specified in bgpm.py.
In defining Announcement Withdrawal (AW) events, we will only consider explicit withdrawals. An explicit withdrawal occurs when a prefix is advertised with an (A)nnouncement and is then (W)ithdrawn. In contrast, an implicit withdrawal occurs when a prefix is advertised (A) and then re-advertised (A) - usually with different BGP attributes. Don't forget that we are only considering IPv4 prefixes.
To compute the duration of an Explicit AW event for a given peerIP/prefix, you will need to monitor the stream of (A)nnouncements and (W)ithdrawals separately per peerIP/prefix pair.
- Example: Given the stream: A1 A2 A3 W1 W2 W3 W4 for a specific peerIP/prefix pair, you have an implicit withdrawal A1-A2, another implicit withdrawal A2-A3, and, finally, an explicit withdrawal (and AW event) A3-W1. W1-W2, W2-W3, and W3-W4 are all meaningless, as there's no active advertisement. The duration of the AW event is the time difference between A3 and W1. Again, we are only looking for last A and first W.
- Example: Given the stream: A1 A2 A3 W1 W2 W3 W4 A4 A5 W4 for a specific peerIP/prefix pair, we have two AW events at A3-W1 and A5-W4.
code requirements as below:
import pybgpstream # Task 3: Announcement-Withdrawal Event Durations def aw_event_durations(cache_files): """ Identify Announcement and Withdrawal events and compute the duration of all explicit AW events in the input BGP data Args: cache_files: A chronologically sorted list of absolute (also called "fully qualified") path names Returns: A dictionary where each key is a string representing the IPv4 address of a peer (peerIP) and each value is a dictionary with keys that are strings representing a prefix and values that are the list of explicit AW event durations (in seconds) for that peerIP and prefix pair. For example: {"127.0.0.1": {"12.13.14.0/24": [4.0, 1.0, 3.0]}} corresponds to the peerIP "127.0.0.1", the prefix "12.13.14.0/24" and event durations of 4.0, 1.0 and 3.0. """ return {}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started