I'm using a bunch of layed maps to try and store information about some network traffic in a packet sniffing application. For example if I have 4 packets going from 192.1.1.1 from port 1 to 255.255.255.255 port 2 the structure should store the IPs and Ports as Keys and the data should be the frequency
[192.1.1.1, [ 1, [ 255.255.255.255, [ 2 , 4]]]]
would be a good representation of how it should be stored.
Yet when I look at the data, I'll get the same IP's and ports 4 times all with a last field (the number of packets) as 1. I'm not sure if its not recognizing the old keys or what is going wrong. Here is a sample of some of the code.
definition of the map
map <u_char*, map<int, map<u_char*, map<int, int> > > > total_map;
storing to the map
hbkt.total_map[inip][inport][outip][outport] = hbkt.total_map[inip][inport][outip][outport] + 1;
If anyone has any ideas that'd be great. I'm not sure if I'm using the map wrong or if its my logic. Or even if someone has a better idea for storing all this information. Thanks alot, always appreciated.
[192.1.1.1, [ 1, [ 255.255.255.255, [ 2 , 4]]]]
would be a good representation of how it should be stored.
Yet when I look at the data, I'll get the same IP's and ports 4 times all with a last field (the number of packets) as 1. I'm not sure if its not recognizing the old keys or what is going wrong. Here is a sample of some of the code.
definition of the map
map <u_char*, map<int, map<u_char*, map<int, int> > > > total_map;
storing to the map
hbkt.total_map[inip][inport][outip][outport] = hbkt.total_map[inip][inport][outip][outport] + 1;
If anyone has any ideas that'd be great. I'm not sure if I'm using the map wrong or if its my logic. Or even if someone has a better idea for storing all this information. Thanks alot, always appreciated.