[docs]classPlugin(AbstractPlugin):""" This MC helps verify that there are no collisions between Autonomous System (AS) numbers in a given experiment. If there is a collision, a :py:exc:`RuntimeError` is thrown. """
[docs]defrun(self):""" Perform the main logic for the AS checking MC. Raises: RuntimeError: If two routers have the same AS number. """as_dict={}forvertexinself.g.get_vertices():ifvertex.is_decorated_by(GenericRouter):as_num=int(vertex.get_bgp_as())# `get_bgp_as` will return a negative number if the AS doesn't existifas_num<0:continueifas_numinas_dict:raiseRuntimeError("Two different routers have the same AS number, this can cause"" strange routing issues within your topology. Please"" fix this prior to launching your experiment."f" Routers: {as_dict[as_num]} and {vertex.name} share the"f" AS number: {as_num}.")as_dict[as_num]=vertex.name