Open danmar2000 opened 1 year ago
Thanks for the contribution!
I like the idea of making this easy and better for the situations that need it, and it helps to have an initial design+implementation to get things rolling. Now I just gotta deeply think about the design/approach.
Do you mind sharing how you're using the NIC information, why you need to handle it separately, and how it helps you to have it as a distinctly-typed object? That would help me think about it better.
In the meantime, here are some initial thoughts/reactions (you don't have to do any code changes based on these thoughts yet - I might "change my mind" multiple times as we talk+think it over):
How do we expect this to work for any address size other than 48-bit EUI/MAC?
Since you have size = 24
in the NIC
class, what happens with the current implementation if you do EUI64('01-23-45-67-89-ab-cd-ef').nic
or CDI32('01-23-45-67').nic
? Off the top of my head, it would be an error in the first case since 0x6789ABCDEF
is too large for a 24-bit NIC
, and it would produce the misleadingly/wrongly -sized NIC('00-00-67')
in the second case.
My current intuition is that each concrete HWAddress subclass should have its own NIC class. The OUI is universally sized, but the identifier part varies by address (and besides having a different size, it's also semantically not interchangeable - two device identifiers are not the same type of thing if they came from two different address types). A single class which somehow knows the class/size of the full address it goes with would be fine if the use-case for actually type-checking them is low.
I will probably change the name "NIC" to something more pedantically precise... Off the top of my head, I think "device identifier" or something. (I'm going to look up the terminology they use in the formal standards, and probably base the name on that.)
This has some big-picture abstract parallels with #8 (there, a lot of my thoughts were basically treating these address classes as fixed-size integers which were unconventionally MSB-aligned - here, the device-identifier is basically a more typical LSB-aligned fixed-width integer) and with #7 (in that case, I keep thinking about an address range class which also needs to know the size/class of the full address it corresponds to).
Thank you for your feedback!
I'm currently working on a network analyzer, and one of its key features is to analyze the devices involved in the captured data. When creating a Device object, I have a particular interest in the manufacturer information, which I can easily obtain from the OUI
. Additionally, I also require the device's identifier. While the complete physical address could serve as a unique identifier, it feels redundant to use it when the OUI
has already been extracted
Yes, I made a mistake, this implementation won't be suitable for physical addresses that don't consist of 48 bits. I think that implementing a NIC
per each HWAddress
is a good idea. In this way, the property nic
can be generic.
I agree, "nic" may not be the most appropriate name. After reviewing the EUI48/EUI64 and CDI32/CDI40 standards, I noticed they use the term "EI" (Extension Identifier). Perhaps using "EI" as the name would be more suitable in this context.
I find this really interesting and would love to dive into the code and read your comments. If you're open to the idea, I would also like to add some suggestions and provide feedback on your own suggestion.
Suggestions and feedback are totally welcome! That's a big part of why I put those thoughts in public GitHub issues.
This is still live in my head, I just haven't gotten around to giving it much thought.
@danmar2000 You mentioned having thoughts on the linked issue/discussion? I'd still love to hear those.
Thinking about it again, .ei
is probably fine.
I think I was giving too much weight to "I don't know what this is and I'm now frustrated/slowed!" abbreviation downsides. It's probably worth the benefits of consistency (.oui
and .ei
make sense together) and so on.
class _StartsWithOUI contains oui property, I added nic property.