Java DataStructure for writing 4 pieces of information

I need to extract two pieces of information about two IP addresses, and then write this data and two addresses. I was thinking of pairing for IP addresses, but by what data structure can I write all this information? Thanks

+3
source share
6 answers
PcapPacketHandler<String> jPacketHandler = new PcapPacketHandler<String>(){
            int totalLength = 0;
            public void nextPacket(PcapPacket packet, String user) {
                        Ip4 ip = new Ip4();
                        String sIP;
                        String dIP;
                        if (packet.hasHeader(ip) == false){
                            return;
                        }
                         totalLength = totalLength+ ip.getPayloadLength();
                         sIP = org.jnetpcap.packet.format.FormatUtils.ip(ip.source());
                         dIP = org.jnetpcap.packet.format.FormatUtils.ip(ip.destination());
                         System.out.println("SIP = "+sIP+"  "+"destIP = "+dIP+" "+"Payload Length = "+ip.getPayloadLength());
                         System.out.println("Total Length = "+totalLength);
                }
      };

        pcap.loop(10, jPacketHandler, "");
        pcap.close();
+1
source

Although this is not a Javascript application, you can use JSON as it provides a concise way to read / store several pieces of data together. Check out the JSON Java Documentation to learn about classes and download the associated source.

0
source

, Hashmap. , , , .

0

(POJO), , , Serializable. , ( ), ( ).

0

- ...

class BigClass { //<br>
   private IPAdreess  addr1; //<br>
   private IPAddress  addr2;  //<br>
   private SomeInfo   additionalInfo;//<br>

   //implement accessors//<br>

   //implement equals, hashCode//<br> 

}//<br>

IPAddress, SomeInfo - . java InetAddress IP-. , .

"" . ? ? ? 100s? ?

? .

0

I don’t quite understand which schedule you want to build accurately. I would do it

  • Dump all data to sql database
  • Run a query to enter input for your chart.
  • Set up a schedule, for example. with JFreeChart or even Excel

I submit a query by line

select source_ip, dest_ip, sum(time), sum(sent_bytes) group by source_ip, dest_ip
0
source

Source: https://habr.com/ru/post/1758502/


All Articles