statistics.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*
  2. * Class providing containers and access methods for statistical data collection.
  3. */
  4. #ifndef CPP_PCAPREADER_STATISTICS_H
  5. #define CPP_PCAPREADER_STATISTICS_H
  6. #include <vector>
  7. #include <unordered_map>
  8. #include <list>
  9. #include <tuple>
  10. #include <tins/timestamp.h>
  11. #include <tins/ip_address.h>
  12. #include "utilities.h"
  13. using namespace Tins;
  14. #define COMM_INTERVAL_THRESHOLD 10e6 // in microseconds; i.e. here 10s
  15. /*
  16. * Definition of structs used in unordered_map fields
  17. */
  18. /*
  19. * Struct used as data structure for method get_stats_for_ip, represents:
  20. * - Incoming bandwidth in KBits
  21. * - Outgoing bandwidth in KBits
  22. * - Number of incoming packets per second
  23. * - Number of outgoing packets per second
  24. * - Average size of sent packets in kbytes
  25. * - Average size of received packets in kybtes
  26. * - Average value of TCP option Maximum Segment Size (MSS)
  27. */
  28. struct ip_stats {
  29. float bandwidthKBitsIn;
  30. float bandwidthKBitsOut;
  31. float packetPerSecondIn;
  32. float packetPerSecondOut;
  33. float AvgPacketSizeSent;
  34. float AvgPacketSizeRecv;
  35. };
  36. /*
  37. * Struct used to represent a conversation by:
  38. * - IP address A
  39. * - Port A
  40. * - IP address B
  41. * - Port B
  42. */
  43. struct conv{
  44. std::string ipAddressA;
  45. int portA;
  46. std::string ipAddressB;
  47. int portB;
  48. bool operator==(const conv &other) const {
  49. return ipAddressA == other.ipAddressA
  50. && portA == other.portA
  51. &&ipAddressB == other.ipAddressB
  52. && portB == other.portB;
  53. }
  54. };
  55. /*
  56. * Struct used to represent a conversation by:
  57. * - IP address A
  58. * - Port A
  59. * - IP address B
  60. * - Port B
  61. * - Protocol
  62. */
  63. struct convWithProt{
  64. std::string ipAddressA;
  65. int portA;
  66. std::string ipAddressB;
  67. int portB;
  68. std::string protocol;
  69. bool operator==(const convWithProt &other) const {
  70. return ipAddressA == other.ipAddressA
  71. && portA == other.portA
  72. &&ipAddressB == other.ipAddressB
  73. && portB == other.portB
  74. && protocol == other.protocol;
  75. }
  76. };
  77. /*
  78. * Struct used to represent:
  79. * - IP address (IPv4 or IPv6)
  80. * - MSS value
  81. */
  82. struct ipAddress_mss {
  83. std::string ipAddress;
  84. int mssValue;
  85. bool operator==(const ipAddress_mss &other) const {
  86. return ipAddress == other.ipAddress
  87. && mssValue == other.mssValue;
  88. }
  89. };
  90. /*
  91. * Struct used to represent:
  92. * - IP address (IPv4 or IPv6)
  93. * - ToS value
  94. */
  95. struct ipAddress_tos {
  96. std::string ipAddress;
  97. int tosValue;
  98. bool operator==(const ipAddress_tos &other) const {
  99. return ipAddress == other.ipAddress
  100. && tosValue == other.tosValue;
  101. }
  102. };
  103. /*
  104. * Struct used to represent:
  105. * - IP address (IPv4 or IPv6)
  106. * - Window size
  107. */
  108. struct ipAddress_win {
  109. std::string ipAddress;
  110. int winSize;
  111. bool operator==(const ipAddress_win &other) const {
  112. return ipAddress == other.ipAddress
  113. && winSize == other.winSize;
  114. }
  115. };
  116. /*
  117. * Struct used to represent:
  118. * - IP address (IPv4 or IPv6)
  119. * - TTL value
  120. */
  121. struct ipAddress_ttl {
  122. std::string ipAddress;
  123. int ttlValue;
  124. bool operator==(const ipAddress_ttl &other) const {
  125. return ipAddress == other.ipAddress
  126. && ttlValue == other.ttlValue;
  127. }
  128. };
  129. /*
  130. * Struct used to represent:
  131. * - IP address (IPv4 or IPv6)
  132. * - Protocol (e.g. TCP, UDP, IPv4, IPv6)
  133. */
  134. struct ipAddress_protocol {
  135. std::string ipAddress;
  136. std::string protocol;
  137. bool operator==(const ipAddress_protocol &other) const {
  138. return ipAddress == other.ipAddress
  139. && protocol == other.protocol;
  140. }
  141. };
  142. /*
  143. * Struct used to represent:
  144. * - Number of received packets
  145. * - Number of sent packets
  146. * - Data received in kbytes
  147. * - Data sent in kbytes
  148. */
  149. struct entry_ipStat {
  150. long pkts_received;
  151. long pkts_sent;
  152. float kbytes_received;
  153. float kbytes_sent;
  154. std::string ip_class;
  155. int in_degree;
  156. int out_degree;
  157. int overall_degree;
  158. // Collects statstics over time interval
  159. std::vector<float> interval_pkt_rate;
  160. float max_interval_pkt_rate;
  161. float min_interval_pkt_rate;
  162. std::vector<std::chrono::microseconds> pkts_sent_timestamp;
  163. std::vector<std::chrono::microseconds> pkts_received_timestamp;
  164. bool operator==(const entry_ipStat &other) const {
  165. return pkts_received == other.pkts_received
  166. && pkts_sent == other.pkts_sent
  167. && kbytes_sent == other.kbytes_sent
  168. && kbytes_received == other.kbytes_received
  169. && interval_pkt_rate == other.interval_pkt_rate
  170. && max_interval_pkt_rate == other.max_interval_pkt_rate
  171. && min_interval_pkt_rate == other.min_interval_pkt_rate
  172. && ip_class == other.ip_class
  173. && pkts_sent_timestamp == other.pkts_sent_timestamp
  174. && pkts_received_timestamp == other.pkts_received_timestamp;
  175. }
  176. };
  177. /*
  178. * Struct used to represent:
  179. * - Number of transmitted packets
  180. * - Number of transmitted bytes
  181. */
  182. struct entry_portStat {
  183. int count;
  184. float byteCount;
  185. };
  186. /*
  187. * Struct used to represent:
  188. * - Number of times the protocol is seen
  189. * - Amount of bytes transmitted with this protocol
  190. */
  191. struct entry_protocolStat {
  192. int count;
  193. float byteCount;
  194. };
  195. /*
  196. * Struct used to represent interval statistics:
  197. * - # packets
  198. * - # bytes
  199. * - IP source entropy
  200. * - IP destination entropy
  201. * - IP source cumulative entropy
  202. * - IP destination cumulative entropy
  203. * - # packets that have payload
  204. * - # incorrect TCP checksum
  205. * - # correct TCP checksum
  206. * - # novel IPs
  207. * - # novel TTL
  208. * - # novel Window Size
  209. * - # novel ToS
  210. * - # novel MSS
  211. */
  212. struct entry_intervalStat {
  213. int pkts_count;
  214. float kbytes;
  215. float ip_src_entropy;
  216. float ip_dst_entropy;
  217. float ip_src_cum_entropy;
  218. float ip_dst_cum_entropy;
  219. int payload_count;
  220. int incorrect_tcp_checksum_count;
  221. int correct_tcp_checksum_count;
  222. int novel_ip_count;
  223. int novel_ttl_count;
  224. int novel_win_size_count;
  225. int novel_tos_count;
  226. int novel_mss_count;
  227. int novel_port_count;
  228. bool operator==(const entry_intervalStat &other) const {
  229. return pkts_count == other.pkts_count
  230. && kbytes == other.kbytes
  231. && ip_src_entropy == other.ip_src_entropy
  232. && ip_dst_entropy == other.ip_dst_entropy
  233. && ip_src_cum_entropy == other.ip_src_cum_entropy
  234. && ip_dst_cum_entropy == other.ip_dst_cum_entropy
  235. && payload_count == other.payload_count
  236. && incorrect_tcp_checksum_count == other.incorrect_tcp_checksum_count
  237. && novel_ip_count == other.novel_ip_count
  238. && novel_ttl_count == other.novel_ttl_count
  239. && novel_win_size_count == other.novel_win_size_count
  240. && novel_tos_count == other.novel_tos_count
  241. && novel_mss_count == other.novel_mss_count
  242. && novel_port_count == other.novel_port_count;
  243. }
  244. };
  245. /*
  246. * Struct used to represent converstaion statistics:
  247. * - # packets
  248. * - Average packet rate
  249. * - Timestamps of packets
  250. * - Inter-arrival time
  251. * - Average inter-arrival time
  252. */
  253. struct entry_convStat {
  254. long pkts_count;
  255. float avg_pkt_rate;
  256. std::vector<std::chrono::microseconds> pkts_timestamp;
  257. std::vector<std::chrono::microseconds> interarrival_time;
  258. std::chrono::microseconds avg_interarrival_time;
  259. bool operator==(const entry_convStat &other) const {
  260. return pkts_count == other.pkts_count
  261. && avg_pkt_rate == avg_pkt_rate
  262. && pkts_timestamp == other.pkts_timestamp
  263. && interarrival_time == other.interarrival_time
  264. && avg_interarrival_time == other.avg_interarrival_time;
  265. }
  266. };
  267. /*
  268. * Struct used to represent:
  269. * - IP address (IPv4 or IPv6)
  270. - Traffic direction (out: outgoing connection, in: incoming connection)
  271. * - Port number
  272. */
  273. struct ipAddress_inOut_port {
  274. std::string ipAddress;
  275. std::string trafficDirection;
  276. int portNumber;
  277. std::string protocol;
  278. bool operator==(const ipAddress_inOut_port &other) const {
  279. return ipAddress == other.ipAddress
  280. && trafficDirection == other.trafficDirection
  281. && portNumber == other.portNumber
  282. && protocol == other.protocol;
  283. }
  284. };
  285. /*
  286. * Struct used to represent a communication interval (for two hosts):
  287. * - Timestamp of the first packet in the interval
  288. * - Timestamp of the last packet in the interval
  289. * - The count of packets within the interval
  290. */
  291. struct commInterval{
  292. std::chrono::microseconds start;
  293. std::chrono::microseconds end;
  294. long pkts_count;
  295. bool operator==(const commInterval &other) const {
  296. return start == other.start
  297. && end == other.end
  298. && pkts_count == other.pkts_count;
  299. }
  300. };
  301. /*
  302. * Struct used to represent converstaion statistics:
  303. * - commnication intervals
  304. * - # packets
  305. * - Average packet rate
  306. * - average # packets per communication interval
  307. * - Average time between intervals
  308. * - Average duration of a communication interval
  309. * - Overall communication duration
  310. * - Timestamps of packets
  311. * - Inter-arrival time
  312. * - Average inter-arrival time
  313. */
  314. struct entry_convStatExt {
  315. std::vector<commInterval> comm_intervals;
  316. long pkts_count;
  317. float avg_pkt_rate;
  318. double avg_int_pkts_count;
  319. double avg_time_between_ints;
  320. double avg_interval_time;
  321. double total_comm_duration;
  322. std::vector<std::chrono::microseconds> pkts_timestamp;
  323. std::vector<std::chrono::microseconds> interarrival_time;
  324. std::chrono::microseconds avg_interarrival_time;
  325. bool operator==(const entry_convStatExt &other) const {
  326. return comm_intervals == other.comm_intervals
  327. && pkts_count == other.pkts_count
  328. && avg_pkt_rate == avg_pkt_rate
  329. && avg_int_pkts_count == other.avg_int_pkts_count
  330. && avg_time_between_ints == other.avg_time_between_ints
  331. && avg_interval_time == other.avg_interval_time
  332. && total_comm_duration == other.total_comm_duration
  333. && pkts_timestamp == other.pkts_timestamp
  334. && interarrival_time == other.interarrival_time
  335. && avg_interarrival_time == other.avg_interarrival_time;
  336. }
  337. };
  338. /*
  339. * Struct used to represent:
  340. * - Source MAC address
  341. * - Destination MAC address
  342. * - Payload type number
  343. */
  344. struct unrecognized_PDU {
  345. std::string srcMacAddress;
  346. std::string dstMacAddress;
  347. uint32_t typeNumber;
  348. bool operator==(const unrecognized_PDU &other) const {
  349. return srcMacAddress == other.srcMacAddress
  350. && dstMacAddress == other.dstMacAddress
  351. && typeNumber == other.typeNumber;
  352. }
  353. };
  354. /*
  355. * Struct used to represent:
  356. * - Number of occurrences
  357. * - Formatted timestamp of last occurrence
  358. */
  359. struct unrecognized_PDU_stat {
  360. int count;
  361. std::string timestamp_last_occurrence;
  362. };
  363. /*
  364. * Definition of hash functions for structs used as key in unordered_map
  365. */
  366. namespace std {
  367. template<>
  368. struct hash<ipAddress_ttl> {
  369. std::size_t operator()(const ipAddress_ttl &k) const {
  370. using std::size_t;
  371. using std::hash;
  372. using std::string;
  373. return ((hash<string>()(k.ipAddress)
  374. ^ (hash<int>()(k.ttlValue) << 1)) >> 1);
  375. }
  376. };
  377. template<>
  378. struct hash<ipAddress_mss> {
  379. std::size_t operator()(const ipAddress_mss &k) const {
  380. using std::size_t;
  381. using std::hash;
  382. using std::string;
  383. return ((hash<string>()(k.ipAddress)
  384. ^ (hash<int>()(k.mssValue) << 1)) >> 1);
  385. }
  386. };
  387. template<>
  388. struct hash<ipAddress_tos> {
  389. std::size_t operator()(const ipAddress_tos &k) const {
  390. using std::size_t;
  391. using std::hash;
  392. using std::string;
  393. return ((hash<string>()(k.ipAddress)
  394. ^ (hash<int>()(k.tosValue) << 1)) >> 1);
  395. }
  396. };
  397. template<>
  398. struct hash<ipAddress_win> {
  399. std::size_t operator()(const ipAddress_win &k) const {
  400. using std::size_t;
  401. using std::hash;
  402. using std::string;
  403. return ((hash<string>()(k.ipAddress)
  404. ^ (hash<int>()(k.winSize) << 1)) >> 1);
  405. }
  406. };
  407. template<>
  408. struct hash<conv> {
  409. std::size_t operator()(const conv &k) const {
  410. using std::size_t;
  411. using std::hash;
  412. using std::string;
  413. return ((hash<string>()(k.ipAddressA)
  414. ^ (hash<int>()(k.portA) << 1)) >> 1)
  415. ^ ((hash<string>()(k.ipAddressB)
  416. ^ (hash<int>()(k.portB) << 1)) >> 1);
  417. }
  418. };
  419. template<>
  420. struct hash<convWithProt> {
  421. std::size_t operator()(const convWithProt &c) const {
  422. using std::size_t;
  423. using std::hash;
  424. using std::string;
  425. return ((hash<string>()(c.ipAddressA)
  426. ^ (hash<int>()(c.portA) << 1)) >> 1)
  427. ^ ((hash<string>()(c.ipAddressB)
  428. ^ (hash<int>()(c.portB) << 1)) >> 1)
  429. ^ (hash<string>()(c.protocol));
  430. }
  431. };
  432. template<>
  433. struct hash<ipAddress_protocol> {
  434. std::size_t operator()(const ipAddress_protocol &k) const {
  435. using std::size_t;
  436. using std::hash;
  437. using std::string;
  438. return ((hash<string>()(k.ipAddress)
  439. ^ (hash<string>()(k.protocol) << 1)) >> 1);
  440. }
  441. };
  442. template<>
  443. struct hash<ipAddress_inOut_port> {
  444. std::size_t operator()(const ipAddress_inOut_port &k) const {
  445. using std::size_t;
  446. using std::hash;
  447. using std::string;
  448. return ((hash<string>()(k.ipAddress)
  449. ^ (hash<string>()(k.trafficDirection) << 1)) >> 1)
  450. ^ (hash<int>()(k.portNumber) << 1);
  451. }
  452. };
  453. template<>
  454. struct hash<unrecognized_PDU> {
  455. std::size_t operator()(const unrecognized_PDU &k) const {
  456. using std::size_t;
  457. using std::hash;
  458. using std::string;
  459. return ((hash<string>()(k.srcMacAddress)
  460. ^ (hash<string>()(k.dstMacAddress) << 1)) >> 1)
  461. ^ (hash<uint32_t>()(k.typeNumber) << 1);
  462. }
  463. };
  464. }
  465. class statistics {
  466. public:
  467. /*
  468. * Constructor
  469. */
  470. statistics();
  471. /*
  472. * Methods
  473. */
  474. std::string getFormattedTimestamp(time_t seconds, suseconds_t microseconds) const;
  475. /*
  476. * Access methods for containers
  477. */
  478. void incrementPacketCount();
  479. void calculateIPIntervalPacketRate(std::chrono::duration<int, std::micro> interval, std::chrono::microseconds intervalStartTimestamp);
  480. void incrementMSScount(std::string ipAddress, int mssValue);
  481. void incrementWinCount(std::string ipAddress, int winSize);
  482. void addConvStat(std::string ipAddressSender,int sport,std::string ipAddressReceiver,int dport, std::chrono::microseconds timestamp);
  483. void addConvStatExt(std::string ipAddressSender,int sport,std::string ipAddressReceiver,int dport,std::string protocol, std::chrono::microseconds timestamp);
  484. void createCommIntervalStats();
  485. std::vector<float> calculateIPsCumEntropy();
  486. std::vector<float> calculateLastIntervalIPsEntropy(std::chrono::microseconds intervalStartTimestamp);
  487. void addIntervalStat(std::chrono::duration<int, std::micro> interval, std::chrono::microseconds intervalStartTimestamp, std::chrono::microseconds lastPktTimestamp);
  488. void checkPayload(const PDU *pdu_l4);
  489. void checkTCPChecksum(std::string ipAddressSender, std::string ipAddressReceiver, TCP tcpPkt);
  490. void checkToS(uint8_t ToS);
  491. void incrementToScount(std::string ipAddress, int tosValue);
  492. void incrementTTLcount(std::string ipAddress, int ttlValue);
  493. void incrementProtocolCount(std::string ipAddress, std::string protocol);
  494. void increaseProtocolByteCount(std::string ipAddress, std::string protocol, long bytesSent);
  495. void incrementUnrecognizedPDUCount(std::string srcMac, std::string dstMac, uint32_t typeNumber,
  496. std::string timestamp);
  497. void incrementPortCount(std::string ipAddressSender, int outgoingPort, std::string ipAddressReceiver,
  498. int incomingPort, std::string protocol);
  499. void increasePortByteCount(std::string ipAddressSender, int outgoingPort, std::string ipAddressReceiver,
  500. int incomingPort, long bytesSent, std::string protocol);
  501. int getProtocolCount(std::string ipAddress, std::string protocol);
  502. float getProtocolByteCount(std::string ipAddress, std::string protocol);
  503. void setTimestampFirstPacket(Tins::Timestamp ts);
  504. void setTimestampLastPacket(Tins::Timestamp ts);
  505. Tins::Timestamp getTimestampFirstPacket();
  506. Tins::Timestamp getTimestampLastPacket();
  507. void assignMacAddress(std::string ipAddress, std::string macAddress);
  508. void addIpStat_packetSent(std::string filePath, std::string ipAddressSender, std::string ipAddressReceiver, long bytesSent, std::chrono::microseconds timestamp);
  509. int getPacketCount();
  510. int getSumPacketSize();
  511. void addMSS(std::string ipAddress, int MSSvalue);
  512. void writeToDatabase(std::string database_path);
  513. void addPacketSize(uint32_t packetSize);
  514. std::string getCaptureDurationTimestamp() const;
  515. float getCaptureDurationSeconds() const;
  516. float getAvgPacketSize() const;
  517. void printStats(std::string ipAddress);
  518. bool getDoExtraTests();
  519. void setDoExtraTests(bool var);
  520. /*
  521. * IP Address-specific statistics
  522. */
  523. ip_stats getStatsForIP(std::string ipAddress);
  524. private:
  525. /*
  526. * Data fields
  527. */
  528. Tins::Timestamp timestamp_firstPacket;
  529. Tins::Timestamp timestamp_lastPacket;
  530. float sumPacketSize = 0;
  531. int packetCount = 0;
  532. /* Extra tests includes:
  533. * - calculate IPs entropies for intervals
  534. * - calculate IPs cumulative entropies interval-wise
  535. * - check payload availability
  536. * - chech TCP checksum correctness
  537. */
  538. bool doExtraTests = false;
  539. int payloadCount = 0;
  540. int incorrectTCPChecksumCount = 0;
  541. int correctTCPChecksumCount = 0;
  542. // Variables that are used for interval-wise statistics
  543. int intervalPayloadCount = 0;
  544. int intervalIncorrectTCPChecksumCount = 0;
  545. int intervalCorrectTCPChecksumCount = 0;
  546. int intervalCumPktCount = 0;
  547. float intervalCumSumPktSize = 0;
  548. int intervalCumNovelIPCount = 0;
  549. int intervalCumNovelTTLCount = 0;
  550. int intervalCumNovelWinSizeCount = 0;
  551. int intervalCumNovelToSCount = 0;
  552. int intervalCumNovelMSSCount = 0;
  553. int intervalCumNovelPortCount = 0;
  554. /*
  555. * Data containers
  556. */
  557. // {IP Address, TTL value, count}
  558. std::unordered_map<ipAddress_ttl, int> ttl_distribution;
  559. // {IP Address, MSS value, count}
  560. std::unordered_map<ipAddress_mss, int> mss_distribution;
  561. // {IP Address, Win size, count}
  562. std::unordered_map<ipAddress_win, int> win_distribution;
  563. // {IP Address, ToS value, count}
  564. std::unordered_map<ipAddress_tos, int> tos_distribution;
  565. // {IP Address A, Port A, IP Address B, Port B, #packets, packets timestamps, inter-arrival times,
  566. // average of inter-arrival times}
  567. std::unordered_map<conv, entry_convStat> conv_statistics;
  568. // {IP Address A, Port A, IP Address B, Port B, comm_intervals, #packets, avg. pkt rate, avg. #packets per interval,
  569. // avg. time between intervals, avg. interval time, duration, packets timestamps, inter-arrivtal times, average of inter-arrival times}
  570. // Also stores conversation with only one exchanged message. In this case avgPktRate, minDelay, maxDelay and avgDelay are -1
  571. std::unordered_map<convWithProt, entry_convStatExt> conv_statistics_extended;
  572. // {Last timestamp in the interval, #packets, #bytes, source IP entropy, destination IP entropy,
  573. // source IP cumulative entropy, destination IP cumulative entropy, #payload, #incorrect TCP checksum,
  574. // #correct TCP checksum, #novel IP, #novel TTL, #novel Window Size, #novel ToS,#novel MSS}
  575. std::unordered_map<std::string, entry_intervalStat> interval_statistics;
  576. // {TTL value, count}
  577. std::unordered_map<int, int> ttl_values;
  578. // {Win size, count}
  579. std::unordered_map<int, int> win_values;
  580. // {ToS, count}
  581. std::unordered_map<int, int> tos_values;
  582. // {MSS, count}
  583. std::unordered_map<int, int> mss_values;
  584. // {Port, count}
  585. std::unordered_map<int, int> port_values;
  586. //{IP Address, contacted IP Addresses}
  587. std::unordered_map<std::string, std::vector<std::string>> contacted_ips;
  588. // {IP Address, Protocol, #count, #Data transmitted in bytes}
  589. std::unordered_map<ipAddress_protocol, entry_protocolStat> protocol_distribution;
  590. // {IP Address, #received packets, #sent packets, Data received in kbytes, Data sent in kbytes}
  591. std::unordered_map<std::string, entry_ipStat> ip_statistics;
  592. // {IP Address, in_out, Port Number, #count, #Data transmitted in bytes}
  593. std::unordered_map<ipAddress_inOut_port, entry_portStat> ip_ports;
  594. // {IP Address, MAC Address}
  595. std::unordered_map<std::string, std::string> ip_mac_mapping;
  596. // {Source MAC, Destination MAC, typeNumber, #count, #timestamp of last occurrence}
  597. std::unordered_map<unrecognized_PDU, unrecognized_PDU_stat> unrecognized_PDUs;
  598. };
  599. #endif //CPP_PCAPREADER_STATISTICS_H