public static JSONArray toPortStat(List<OFStatistics> ofs){
JSONArray jsonArray = new JSONArray();
for (OFStatistics ofst : ofs) {
OFPortStatisticsReply st = (OFPortStatisticsReply) ofst;
JSONObject jsonObject = new JSONObject();
if (st.getPortNumber() < -2) {
continue;
}
jsonObject.put("port_id", st.getPortNumber());
jsonObject.put("receive_packets", st.getreceivePackets());
jsonObject.put("transmit_packets", st.getTransmitPackets());
jsonObject.put("receive_bytes", st.getReceiveBytes());
jsonObject.put("transmit_bytes", st.getTransmitBytes());
jsonArray.add(jsonObject);
}