Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to expand the ASN number? #173

Open
Vivian-Q opened this issue Jan 21, 2024 · 4 comments
Open

How to expand the ASN number? #173

Vivian-Q opened this issue Jan 21, 2024 · 4 comments
Assignees

Comments

@Vivian-Q
Copy link

Hello,
I want to establish my own network and the number of my AS is more than 253, it occurs error:AssertionError: can't map ASN 255 to IX address. Is there any methods that I can expand the ASN number limitation?
Thanks!

@kevin-w-du
Copy link
Member

This is doable. When we create a network inside an AS, if we don't specify the network prefix, we will use "10.AS.0.0/16" as the network prefix. That is why AS is limited to 255. However, if you want to use a number larger than 255, you can provide the network prefix yourself (the default option is auto). See the following:

as350 = base.createAutonomousSystem(350)
as350.createNetwork(name='net0', prefix='128.230.0.0/16')

Moreover, when its BGP router joins a Internet Exchange, you need to specify the IP address as well (otherwise, the IP address on the IX network will be 10.IX.0.AS, which will cause exception if AS > 255). See the following code:

as350.createRouter('router0').joinNetwork('net0').joinNetwork('ix100', '10.100.0.35')

I believe this is all you need. Let me know if there are other problems.

@Vivian-Q
Copy link
Author

I have provide the network prefix by myself but it still have the problem, could you please tell me how to fix this?

This is my code:
emu = Emulator()
base = Base()
routing = Routing()
as_number_counter = 2
max_asn = 65535
router_counter = 1
as_mapping = {}
ix_mapping = {}
created_routers = set()
autonomous_systems = {}
internet_exchanges = {}
as_number = as_number_counter
autonomous_systems[as_number] = base.createAutonomousSystem(as_number)

Manually specify the network prefix

second_octet_network = as_number // 256
third_octet_network = as_number % 256
custom_network_prefix = "128.{}.{}.0/24".format(second_octet_network, third_octet_network)
autonomous_systems[as_number].createNetwork(name='net{}'.format(as_number), prefix=custom_network_prefix)        

# Create router and join Network and IX
ix_name = "ix{}".format(as_number)
custom_ix_prefix = "129.{}.{}.0/24".format(second_octet_network, third_octet_network)
internet_exchanges[ix_name] = base.createInternetExchange(as_number, custom_ix_prefix)
ix_mapping[station] = ix_name
as_mapping[station] = as_number

# Create router and join Network and IX
router_name = 'router{}'.format(router_counter)
while router_name in created_routers:
    router_counter += 1
    router_name = 'router{}'.format(router_counter)

# Assign IP address
router_ip_second_octet = router_counter // 256
router_ip_third_octet = router_counter % 256
ix_ip_address = "10.{}.{}.1".format(router_ip_second_octet, router_ip_third_octet)
created_routers.add(router_name)

autonomous_systems[as_number].createRouter(router_name).joinNetwork('net{}'.format(as_number)).joinNetwork(ix_name, ix_ip_address)
router_counter += 1
as_number_counter += 1

ebgp = Ebgp()

for u, v in G.edges:
as_u = as_mapping[u]
as_v = as_mapping[v]
ebgp.addPrivatePeerings(as_u, [as_u], [as_v], PeerRelationship.Peer)
emu.addLayer(base)
emu.addLayer(routing)
emu.addLayer(ebgp)
emu.render()
emu.compile(Docker(), './output')

**This is the error:**Traceback (most recent call last):
File "./subway_seed.py", line 101, in
emu.render()
File "/home/seed/seed-emulator/seedemu/core/Emulator.py", line 347, in render
self.__render('Base', False, True)
File "/home/seed/seed-emulator/seedemu/core/Emulator.py", line 152, in __render
layer.configure(self)
File "/home/seed/seed-emulator/seedemu/layers/Base.py", line 67, in configure
for ix in self.__ixes.values(): ix.configure(emulator)
File "/home/seed/seed-emulator/seedemu/core/InternetExchange.py", line 48, in configure
self.__rs.configure(emulator)
File "/home/seed/seed-emulator/seedemu/core/Node.py", line 295, in configure
self.__joinNetwork(reg.get("ix", "net", netname), address)
File "/home/seed/seed-emulator/seedemu/core/Node.py", line 435, in __joinNetwork
if address == "auto": _addr = net.assign(self.__role, self.__asn)
File "/home/seed/seed-emulator/seedemu/core/Network.py", line 237, in assign
if self.__type == NetworkType.InternetExchange: return self.__prefix[self.__aac.mapIxAddress(asn)]
File "/home/seed/seed-emulator/seedemu/core/AddressAssignmentConstraint.py", line 181, in mapIxAddress
assert asn >= 2 and asn <= 254, "can't map ASN {} to IX address.".format(asn)
AssertionError: can't map ASN 255 to IX address.

@kevin-w-du
Copy link
Member

Because of my limited time (have a full-time job), it will be better if you spend sufficient time to do the debugging first, and then show me your debugging results. I will then chip in to help you. That will be a better use of my time. Sorry about that. I don't have a large team to help me.

@wonkr
Copy link
Member

wonkr commented Jan 31, 2024

@Vivian-Q
This issue causes because of InternetExchange router_server ipaddress.
Router Server is created when InternetExchange is initialized. And its ipaddress become .ASN..ASN.
Even when you set a prefix of "129.{}.{}.0/24", it will assign 129.{}.{}.ASN. When a value of ASN is over 255, this will cause an error.

So, this is my suggestion to fix the issue. You need to assign ip address to Router Server as well as set a prefix.
internet_exchanges[ix_name] = base.createInternetExchange(as_number, custom_ix_prefix)
=>
internet_exchanges[ix_name] = base.createInternetExchange(as_number, custom_ix_prefix).getRouteServerNode().updateNetwork(ix_name, "129.{}.{}.255".format(second_octet_network, third_octet_network)) )

@wonkr wonkr self-assigned this Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants