M
Matt Bull
Hi,
I apologise in advance if this is off topic, but would appreciate any
pointers you chaps might be able to provide.
I'm relatively novice in the art of C so am after any suggestions about
implementing a very simple hash (or quasi hash)
I need to be able to store a counter and a timestamp for requests from
particular device MAC addresses (6 bytes, presented as xx:xx:xx:xx:xx:xx
where x is a hex digit), ideally in a dynamic data structure. Additionally I
need to be able to access the data quickly, hence my thoughts to use a
hashing function.
This may be naive but I'd thought to code something along the line of a tree
structure, with each octet representing a node holding 256 pointers to the
next set of nodes (from most significant to least significant octect) with
the last octect holding pointers to a simple record holding the data.
This would mean that at most i would need to traverse 6 tree nodes before
hitting the data whatever the volume of addresses.(?)
Does this seem feasible?
If so (and this is where I get unstuck )), in C i'd have a structure
defined as an array of 255 pointers, then allocate space for one of these
structures as I parse each octect of the mac address. I'm having difficulty
in defining the structures correctly so that the last but one octet
references the actual data rather than another set of node pointers.
Can someone please advise on the best way to do this? Or if you think the
above is complete pap suggest any easier or more sensible ( please )
solutions. I'm open to advice/flaming/suggestions!
Cheers,
Matt
I apologise in advance if this is off topic, but would appreciate any
pointers you chaps might be able to provide.
I'm relatively novice in the art of C so am after any suggestions about
implementing a very simple hash (or quasi hash)
I need to be able to store a counter and a timestamp for requests from
particular device MAC addresses (6 bytes, presented as xx:xx:xx:xx:xx:xx
where x is a hex digit), ideally in a dynamic data structure. Additionally I
need to be able to access the data quickly, hence my thoughts to use a
hashing function.
This may be naive but I'd thought to code something along the line of a tree
structure, with each octet representing a node holding 256 pointers to the
next set of nodes (from most significant to least significant octect) with
the last octect holding pointers to a simple record holding the data.
This would mean that at most i would need to traverse 6 tree nodes before
hitting the data whatever the volume of addresses.(?)
Does this seem feasible?
If so (and this is where I get unstuck )), in C i'd have a structure
defined as an array of 255 pointers, then allocate space for one of these
structures as I parse each octect of the mac address. I'm having difficulty
in defining the structures correctly so that the last but one octet
references the actual data rather than another set of node pointers.
Can someone please advise on the best way to do this? Or if you think the
above is complete pap suggest any easier or more sensible ( please )
solutions. I'm open to advice/flaming/suggestions!
Cheers,
Matt