final Calendar cal = Calendar.getInstance();
Logger logger = Logger.getLogger(FlowStats.class.getName());
List<FlowDataProcessingRule> statsRules = new ArrayList<FlowDataProcessingRule>();
try {
statsRules.add(new FlowStatsRule(null, new FileOutputStream("flowsall.csv", true)));
statsRules.add(new IfaсeDistributionRule(null, new FileOutputStream("flowsOutIfaces.csv", true), true));
statsRules.add(new IfaсeDistributionRule(null, new FileOutputStream("flowsInIfaces.csv", true), false));
statsRules.add(new IfaсeDirectionsRule(null, new FileOutputStream("flowsIfacesDirections.csv", true)));
final FlowFilter srcWellKnownPorts = new PortFilter(1, 4096, false);
final FlowFilter dstWellKnownPorts = new PortFilter(1, 4096, true);
final FlowFilter udpFlows = new ProtoFilter(17);
final FlowFilter tcpFlows = new ProtoFilter(6);
/* TCP destination ports */
final AndFilter tcpDstFlows = new AndFilter();
tcpDstFlows.addFilter(tcpFlows);
tcpDstFlows.addFilter(dstWellKnownPorts);
statsRules.add(new PortDistributionRule(tcpDstFlows, new FileOutputStream("flowsTcpDstPorts.csv", true), true));
/* TCP source ports */
final AndFilter tcpSrcFlows = new AndFilter();
tcpSrcFlows.addFilter(tcpFlows);
tcpSrcFlows.addFilter(srcWellKnownPorts);
statsRules.add(new PortDistributionRule(tcpSrcFlows, new FileOutputStream("flowsTcpSrcPorts.csv", true), false));
/* UDP destination ports */
final AndFilter udpDstFlows = new AndFilter();
udpDstFlows.addFilter(udpFlows);
udpDstFlows.addFilter(dstWellKnownPorts);
statsRules.add(new PortDistributionRule(udpDstFlows, new FileOutputStream("flowsUdpDstPorts.csv", true), true));
/* UDP source ports */
final AndFilter udpSrcFlows = new AndFilter();
udpSrcFlows.addFilter(udpFlows);
udpSrcFlows.addFilter(srcWellKnownPorts);
statsRules.add(new PortDistributionRule(udpSrcFlows, new FileOutputStream("flowsUdpSrcPorts.csv", true), false));
/* UDP and TCP flows */
final OrFilter udpTcpFlows = new OrFilter();
udpTcpFlows.addFilter(udpFlows);
udpTcpFlows.addFilter(tcpFlows);
statsRules.add(new FlowStatsRule(udpTcpFlows, new FileOutputStream("flowsUdpTcp.csv", true)));
statsRules.add(new IpDirectionsRule(udpTcpFlows, new FileOutputStream("flowsIpDirections.csv", true)));
} catch (FileNotFoundException ex) {
Logger.getLogger(FlowStats.class.getName()).log(Level.SEVERE, null, ex);