jepri has asked for the wisdom of the Perl Monks concerning the following question:
$hash{MAC}{IP} $hash{MAC}{Port} $hash{MAC}{# of Packets} etc
It's not hard to see that this means that I can't see which IPs used which protocols, or how many packets were used for each protocol.
The obvious answer for the example above is: use a HoHoHoH
$hash{MAC}{IP}{Port}{#Packets}
but there are actually a few more variables involved, such as destination IP by source IP, destination port by source IP, etc . So I might be tempted by a data structure like this:
$hash{MAC}{IP}{Port}{Destination IP}{Port}{#Packets}
Obviously there are a few problems with this solution, including the fact that I might have to iterate over lots of sub-hashes, and it looks inelegant.
So what would you recommend? Should I maintain half a dozen separate hashes and update each one (possibly via a subroutine)? Should I create an object that will return data when called by methods like $obj->ports_by_ip($ip)?
____________________
Jeremy
I didn't believe in evil until I dated it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(ichimunki) Re: What data structure should I use to describe networked computers?
by ichimunki (Priest) on Mar 03, 2001 at 19:35 UTC | |
by dvergin (Monsignor) on Mar 03, 2001 at 19:47 UTC |