-
Notifications
You must be signed in to change notification settings - Fork 1
Added support for SCION ASNs > 255. #28
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
Conversation
Nice to see that things are proceeding here! 🔥 I have two questions for this one:
|
Regarding 1: You were right, I ignored the SCION spec in that case, I fixed that... Regarding 2: I didn't modify subnetting and all these related functions so far. Currently all IP addresses have to be defined manually for ASNs>255 when creating the topology (e.g. |
can't we refactor the code duplication into a free function 'def ASN2str(asn: int)->str' and have ScionAutonomousSystem::getAsnStr(self) and IA::_ str _() call it (the former simply prepending the 'ISD-' to the result) ?! Also move the computation of asn2 &3 beyond the quick-out wich only depends on asn1 .. . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all functionality related to parsing and printing SCION ASNs (or ISD-ASN) pairs should be bundeled in one or two classes. I propose adding a method getScionAsn() -> IA
to ScionAutonomousSystem that returns a smart ASN type that handles being turned into a string correctly. This new method should be called in ScionIsd and other SCION-specific layers instead of getAsn()
.
A Python IA, ISD-ASN class has been implemented many times.
- Here is one for just the ASN from may Scapy layer: https://github.com/lschulz/scapy-scion-int/blob/main/scapy_scion/scion_addr.py
- The current ISD-AS for Python from scionproto: https://github.com/scionproto/scion/blob/master/tools/topology/scion_addr.py
- There was also an older implementation that I used some years ago: https://github.com/lschulz/scion-ixp-testbed/blob/master/ixp_testbed/address.py
- Probably some more that I forgot
Reviewed 1 of 4 files at r1, 1 of 2 files at r2, all commit messages.
Reviewable status: 2 of 4 files reviewed, 3 unresolved discussions (waiting on @LencigGaer)
seedemu/core/ScionAutonomousSystem.py
line 21 at r2 (raw file):
def __str__(self): asn1 = f"{self.asn:012x}"[:3].lstrip('0') + f"{self.asn:012x}"[3]
This way of converting to a string seems a bit wasteful, it did it like this:
https://github.com/lschulz/scapy-scion-int/blob/61fd17457c07c8b61287e5e180112386af3e6139/scapy_scion/scion_addr.py#L47
seedemu/core/ScionAutonomousSystem.py
line 276 at r2 (raw file):
return self.__generateStaticInfoConfig def getAsnStr(self):
I agree with @amdfxlucas, the code from above shouldn't be duplicated here.
seedemu/layers/ScionIsd.py
line 204 at r2 (raw file):
return path def __asn_to_name(self, asn: int) -> str:
Same as in the other file, call the same code.
Agreed, I also wasn't happy with the code duplication. I now created a new class MORE DETAILS: The SCION SEED code used the The I added the function In order to allow the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 4 files reviewed, 3 unresolved discussions (waiting on @amdfxlucas and @lschulz)
seedemu/core/ScionAutonomousSystem.py
line 21 at r2 (raw file):
Previously, lschulz (Lars-Christian Schulz) wrote…
This way of converting to a string seems a bit wasteful, it did it like this:
https://github.com/lschulz/scapy-scion-int/blob/61fd17457c07c8b61287e5e180112386af3e6139/scapy_scion/scion_addr.py#L47
Done.
seedemu/core/ScionAutonomousSystem.py
line 276 at r2 (raw file):
Previously, lschulz (Lars-Christian Schulz) wrote…
I agree with @amdfxlucas, the code from above shouldn't be duplicated here.
Done.
seedemu/layers/ScionIsd.py
line 204 at r2 (raw file):
Previously, lschulz (Lars-Christian Schulz) wrote…
Same as in the other file, call the same code.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be a good idea to add a SCION test case with long ASNs to avoid regressions in the future.
Reviewed 3 of 3 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @LencigGaer)
seedemu/layers/ScionIsd.py
line 143 at r3 (raw file):
as_: ScionAutonomousSystem = base_layer.getAutonomousSystem(asn) isds = self.getAsIsds(asn)
Avoid trailing whitespace (PEP8). You can just set your editor to trim trailing whitespace or use a Python code formatter like black.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a testcase for this.
Also noticed that I wasn't handling large ASNs for the Graphable class correctly - I fixed that.
Reviewable status: 2 of 9 files reviewed, 1 unresolved discussion (waiting on @lschulz)
seedemu/layers/ScionIsd.py
line 143 at r3 (raw file):
Previously, lschulz (Lars-Christian Schulz) wrote…
Avoid trailing whitespace (PEP8). You can just set your editor to trim trailing whitespace or use a Python code formatter like black.
Done.
…N handling to remove duplicated string conversions.
98c4779
to
4aa8b0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 0 of 12 files reviewed, 1 unresolved discussion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 8 of 10 files at r4, 4 of 4 files at r5, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @LencigGaer)
* Added support for SCION ASNs > 255. * Fixed support for 2^16<ASN<2^32 * Refactored IA class with new constructor. Added ScionASN class for ASN handling to remove duplicated string conversions. * Added testcase for large ASNs. Fixed Graphable bug for large ASNs. * Update requirements.txt and fix test case --------- Co-authored-by: Lars-Christian Schulz <[email protected]>
fixes #6
This change is