简体   繁体   English

在JAVA中存储IP流元组的最佳方法是什么?

[英]What is the best way to store a IP flow tuple in JAVA?

I am new to Network Programming. 我是网络编程的新手。 I have a task to store a source IP and port and Destination IP and port in a container in JAVA. 我的任务是将源IP和端口以及目标IP和端口存储在JAVA的容器中。

I am not able to find a good solution to it. 我找不到一个好的解决方案。

I am thinking of doing the following 我正在考虑做以下事情

Map<Inet4Address, port> SourceMap;
Map<Inet4Address,port> DestMap;
TreeMap<Map<Inet4Address, port> , Map<Inet4Address, port> > tupleMap;

Is this a good of storing tuples and iterating over them or is there a better way? 这是存储元组并对其进行迭代的好方法,还是有更好的方法?

Thanks in advance! 提前致谢!

Cheers! 干杯!

Two InetSocketAddresses will do it. 两个InetSocketAddresses可以做到。 Each one holds an IP address and a port. 每个都有一个IP地址和一个端口。

Your maps don't make much sense. 您的地图没有太大意义。 They would only allow for one connection to or from each IP address. 它们仅允许与每个IP地址建立一个连接或与之连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM