Skip to content

Commit

Permalink
Merge pull request seed-labs#27 from amdfxlucas/optional-route-servers
Browse files Browse the repository at this point in the history
make creation of RouteServers optional in InternetExchanges
  • Loading branch information
lschulz authored Jan 28, 2025
2 parents a112bd7 + 3e6f405 commit 5dedd2b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
19 changes: 12 additions & 7 deletions seedemu/core/InternetExchange.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .Printable import Printable
from .enums import NetworkType, NodeRole
from .Node import Node
from .Node import Node,Router
from .Network import Network
from .AddressAssignmentConstraint import AddressAssignmentConstraint
from .Emulator import Emulator
Expand All @@ -19,13 +19,15 @@ class InternetExchange(Printable, Configurable):
__rs: Node
__name: str

def __init__(self, id: int, prefix: str = "auto", aac: AddressAssignmentConstraint = None):
def __init__(self, id: int, prefix: str = "auto", aac: AddressAssignmentConstraint = None, create_rs = True):
"""!
@brief InternetExchange constructor.
@param id ID (ASN) for the IX.
@param prefix (optional) prefix to use as peering LAN.
@param aac (option) AddressAssignmentConstraint to use.
@param create_rs (optional) create route server node for the IX or not.
( route servers are only relevant for BGP, thus the default is True. But RSes can be disabled for SCION)
"""

self.__id = id
Expand All @@ -34,18 +36,21 @@ def __init__(self, id: int, prefix: str = "auto", aac: AddressAssignmentConstrai
network = IPv4Network(prefix) if prefix != "auto" else IPv4Network("10.{}.0.0/24".format(self.__id))

self.__name = 'ix{}'.format(str(self.__id))
self.__rs = Node(self.__name, NodeRole.RouteServer, self.__id)
self.__net = Network(self.__name, NetworkType.InternetExchange, network, aac, False)

self.__rs.joinNetwork(self.__name)
if create_rs:
self.__rs = Router(self.__name, NodeRole.RouteServer, self.__id)
self.__rs.joinNetwork(self.__name)
else:
self.__rs = None

def configure(self, emulator: Emulator):
reg = emulator.getRegistry()

reg.register('ix', 'net', self.__name, self.__net)
reg.register('ix', 'rs', self.__name, self.__rs)

self.__rs.configure(emulator)
if self.__rs != None:
reg.register('ix', 'rs', self.__name, self.__rs)
self.__rs.configure(emulator)

def getId(self) -> int:
"""!
Expand Down
4 changes: 2 additions & 2 deletions seedemu/layers/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def setAutonomousSystem(self, asObject: AutonomousSystem):
asn = asObject.getAsn()
self.__ases[asn] = asObject

def createInternetExchange(self, asn: int, prefix: str = "auto", aac: AddressAssignmentConstraint = None) -> InternetExchange:
def createInternetExchange(self, asn: int, prefix: str = "auto", aac: AddressAssignmentConstraint = None, create_rs=True) -> InternetExchange:
"""!
@brief Create a new InternetExchange.
Expand All @@ -152,7 +152,7 @@ def createInternetExchange(self, asn: int, prefix: str = "auto", aac: AddressAss
@throws AssertionError if IX exists.
"""
assert asn not in self.__ixes, "ix{} already exist.".format(asn)
self.__ixes[asn] = InternetExchange(asn, prefix, aac)
self.__ixes[asn] = InternetExchange(asn, prefix, aac, create_rs)
return self.__ixes[asn]

def getInternetExchange(self, asn: int) -> InternetExchange:
Expand Down
4 changes: 3 additions & 1 deletion seedemu/layers/Routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def __installBird(self, node: Node):
node.addBuildCommand('touch /usr/share/doc/bird2/examples/bird.conf')
node.addSoftware('bird2')

node.setBaseSystem(BaseSystem.SEEDEMU_ROUTER)
base = node.getBaseSystem()
if not BaseSystem.doesAContainB(base,BaseSystem.SEEDEMU_ROUTER) and base !=BaseSystem.SEEDEMU_ROUTER:
node.setBaseSystem(BaseSystem.SEEDEMU_ROUTER)

def configure(self, emulator: Emulator):
reg = emulator.getRegistry()
Expand Down

0 comments on commit 5dedd2b

Please sign in to comment.