|
@@ -32,7 +32,7 @@ void statistics::checkPayload(const PDU *pdu_l4) {
|
|
|
* @param ipAddressReceiver The destination IP.
|
|
|
* @param tcpPkt The packet to get checked.
|
|
|
*/
|
|
|
-void statistics::checkTCPChecksum(const std::string &ipAddressSender, const std::string &ipAddressReceiver, TCP tcpPkt) {
|
|
|
+void statistics::checkTCPChecksum(const IPv4Address ipAddressSender, const IPv4Address ipAddressReceiver, TCP tcpPkt) {
|
|
|
if(this->getDoExtraTests()) {
|
|
|
if(check_tcpChecksum(ipAddressSender, ipAddressReceiver, tcpPkt))
|
|
|
correctTCPChecksumCount++;
|
|
@@ -112,7 +112,7 @@ std::vector<float> statistics::calculateLastIntervalIPsEntropy(std::chrono::micr
|
|
|
*/
|
|
|
std::vector<float> statistics::calculateIPsCumEntropy(){
|
|
|
if(this->getDoExtraTests()) {
|
|
|
- std::vector <std::string> IPs;
|
|
|
+ std::vector <IPv4Address> IPs;
|
|
|
std::vector <float> IPsSrcProb;
|
|
|
std::vector <float> IPsDstProb;
|
|
|
|
|
@@ -226,7 +226,7 @@ void statistics::addIntervalStat(std::chrono::duration<int, std::micro> interval
|
|
|
* @param dport The destination port.
|
|
|
* @param timestamp The timestamp of the packet.
|
|
|
*/
|
|
|
-void statistics::addConvStat(const std::string &ipAddressSender,int sport,const std::string &ipAddressReceiver,int dport, std::chrono::microseconds timestamp){
|
|
|
+void statistics::addConvStat(const IPv4Address ipAddressSender,int sport,const IPv4Address ipAddressReceiver,int dport, std::chrono::microseconds timestamp){
|
|
|
|
|
|
conv f1 = {ipAddressReceiver, dport, ipAddressSender, sport};
|
|
|
conv f2 = {ipAddressSender, sport, ipAddressReceiver, dport};
|
|
@@ -259,7 +259,7 @@ void statistics::addConvStat(const std::string &ipAddressSender,int sport,const
|
|
|
* @param protocol The used protocol.
|
|
|
* @param timestamp The timestamp of the packet.
|
|
|
*/
|
|
|
-void statistics::addConvStatExt(const std::string &ipAddressSender,int sport,const std::string &ipAddressReceiver,int dport,const std::string &protocol, std::chrono::microseconds timestamp){
|
|
|
+void statistics::addConvStatExt(const IPv4Address ipAddressSender,int sport, const IPv4Address ipAddressReceiver,int dport,const std::string &protocol, std::chrono::microseconds timestamp){
|
|
|
if(this->getDoExtraTests()) {
|
|
|
convWithProt f1 = {ipAddressReceiver, dport, ipAddressSender, sport, protocol};
|
|
|
convWithProt f2 = {ipAddressSender, sport, ipAddressReceiver, dport, protocol};
|
|
@@ -349,7 +349,7 @@ void statistics::createCommIntervalStats(){
|
|
|
* @param ipAddress The IP address whose MSS packet counter should be incremented.
|
|
|
* @param mssValue The MSS value of the packet.
|
|
|
*/
|
|
|
-void statistics::incrementMSScount(const std::string &ipAddress, int mssValue) {
|
|
|
+void statistics::incrementMSScount(const IPv4Address ipAddress, int mssValue) {
|
|
|
mss_values[mssValue]++;
|
|
|
mss_distribution[{ipAddress, mssValue}]++;
|
|
|
}
|
|
@@ -359,7 +359,7 @@ void statistics::incrementMSScount(const std::string &ipAddress, int mssValue) {
|
|
|
* @param ipAddress The IP address whose window size packet counter should be incremented.
|
|
|
* @param winSize The window size of the packet.
|
|
|
*/
|
|
|
-void statistics::incrementWinCount(const std::string &ipAddress, int winSize) {
|
|
|
+void statistics::incrementWinCount(const IPv4Address ipAddress, int winSize) {
|
|
|
win_values[winSize]++;
|
|
|
win_distribution[{ipAddress, winSize}]++;
|
|
|
}
|
|
@@ -369,7 +369,7 @@ void statistics::incrementWinCount(const std::string &ipAddress, int winSize) {
|
|
|
* @param ipAddress The IP address whose TTL packet counter should be incremented.
|
|
|
* @param ttlValue The TTL value of the packet.
|
|
|
*/
|
|
|
-void statistics::incrementTTLcount(const std::string &ipAddress, int ttlValue) {
|
|
|
+void statistics::incrementTTLcount(const IPv4Address ipAddress, int ttlValue) {
|
|
|
ttl_values[ttlValue]++;
|
|
|
ttl_distribution[{ipAddress, ttlValue}]++;
|
|
|
}
|
|
@@ -379,7 +379,7 @@ void statistics::incrementTTLcount(const std::string &ipAddress, int ttlValue) {
|
|
|
* @param ipAddress The IP address whose ToS packet counter should be incremented.
|
|
|
* @param tosValue The ToS value of the packet.
|
|
|
*/
|
|
|
-void statistics::incrementToScount(const std::string &ipAddress, int tosValue) {
|
|
|
+void statistics::incrementToScount(const IPv4Address ipAddress, int tosValue) {
|
|
|
tos_values[tosValue]++;
|
|
|
tos_distribution[{ipAddress, tosValue}]++;
|
|
|
}
|
|
@@ -389,7 +389,7 @@ void statistics::incrementToScount(const std::string &ipAddress, int tosValue) {
|
|
|
* @param ipAddress The IP address whose protocol packet counter should be incremented.
|
|
|
* @param protocol The protocol of the packet.
|
|
|
*/
|
|
|
-void statistics::incrementProtocolCount(const std::string &ipAddress, const std::string &protocol) {
|
|
|
+void statistics::incrementProtocolCount(const IPv4Address ipAddress, const std::string &protocol) {
|
|
|
protocol_distribution[{ipAddress, protocol}].count++;
|
|
|
}
|
|
|
|
|
@@ -398,7 +398,7 @@ void statistics::incrementProtocolCount(const std::string &ipAddress, const std:
|
|
|
* @param ipAddress The IP address whose packet count is wanted.
|
|
|
* @param protocol The protocol whose packet count is wanted.
|
|
|
*/
|
|
|
-int statistics::getProtocolCount(const std::string &ipAddress, const std::string &protocol) {
|
|
|
+int statistics::getProtocolCount(const IPv4Address ipAddress, const std::string &protocol) {
|
|
|
return protocol_distribution[{ipAddress, protocol}].count;
|
|
|
}
|
|
|
|
|
@@ -408,7 +408,7 @@ int statistics::getProtocolCount(const std::string &ipAddress, const std::string
|
|
|
* @param protocol The protocol of the packet.
|
|
|
* @param byteSent The packet's size.
|
|
|
*/
|
|
|
-void statistics::increaseProtocolByteCount(const std::string &ipAddress, const std::string &protocol, long bytesSent) {
|
|
|
+void statistics::increaseProtocolByteCount(const IPv4Address ipAddress, const std::string &protocol, long bytesSent) {
|
|
|
protocol_distribution[{ipAddress, protocol}].byteCount += bytesSent;
|
|
|
}
|
|
|
|
|
@@ -418,7 +418,7 @@ void statistics::increaseProtocolByteCount(const std::string &ipAddress, const s
|
|
|
* @param protocol The protocol whose byte count is wanted.
|
|
|
* @return a float: The number of bytes
|
|
|
*/
|
|
|
-float statistics::getProtocolByteCount(const std::string &ipAddress, const std::string &protocol) {
|
|
|
+float statistics::getProtocolByteCount(const IPv4Address ipAddress, const std::string &protocol) {
|
|
|
return protocol_distribution[{ipAddress, protocol}].byteCount;
|
|
|
}
|
|
|
|
|
@@ -431,7 +431,7 @@ float statistics::getProtocolByteCount(const std::string &ipAddress, const std::
|
|
|
* @param ipAddressReceiver The IP address of the packet receiver.
|
|
|
* @param incomingPort The port used by the receiver.
|
|
|
*/
|
|
|
-void statistics::incrementPortCount(const std::string &ipAddressSender, int outgoingPort, const std::string &ipAddressReceiver,
|
|
|
+void statistics::incrementPortCount(const IPv4Address ipAddressSender, int outgoingPort, const IPv4Address ipAddressReceiver,
|
|
|
int incomingPort, const std::string &protocol) {
|
|
|
port_values[outgoingPort]++;
|
|
|
port_values[incomingPort]++;
|
|
@@ -449,7 +449,7 @@ void statistics::incrementPortCount(const std::string &ipAddressSender, int outg
|
|
|
* @param incomingPort The port used by the receiver.
|
|
|
* @param byteSent The packet's size.
|
|
|
*/
|
|
|
-void statistics::increasePortByteCount(const std::string &ipAddressSender, int outgoingPort, const std::string &ipAddressReceiver,
|
|
|
+void statistics::increasePortByteCount(const IPv4Address ipAddressSender, int outgoingPort, const IPv4Address ipAddressReceiver,
|
|
|
int incomingPort, long bytesSent, const std::string &protocol) {
|
|
|
ip_ports[{ipAddressSender, "out", outgoingPort, protocol}].byteCount += bytesSent;
|
|
|
ip_ports[{ipAddressReceiver, "in", incomingPort, protocol}].byteCount += bytesSent;
|
|
@@ -480,7 +480,7 @@ statistics::statistics(void) {
|
|
|
* @param ipAddress The IP address belonging to the given MAC address.
|
|
|
* @param macAddress The MAC address belonging to the given IP address.
|
|
|
*/
|
|
|
-void statistics::assignMacAddress(const std::string &ipAddress, const std::string &macAddress) {
|
|
|
+void statistics::assignMacAddress(const IPv4Address ipAddress, const std::string &macAddress) {
|
|
|
ip_mac_mapping[ipAddress] = macAddress;
|
|
|
}
|
|
|
|
|
@@ -491,7 +491,7 @@ void statistics::assignMacAddress(const std::string &ipAddress, const std::strin
|
|
|
* @param ipAddressReceiver The IP address of the packet receiver.
|
|
|
* @param bytesSent The packet's size.
|
|
|
*/
|
|
|
-void statistics::addIpStat_packetSent(const std::string &ipAddressSender, const std::string &ipAddressReceiver, long bytesSent, std::chrono::microseconds timestamp) {
|
|
|
+void statistics::addIpStat_packetSent(const IPv4Address ipAddressSender, const IPv4Address ipAddressReceiver, long bytesSent, std::chrono::microseconds timestamp) {
|
|
|
|
|
|
// Adding IP as a sender for first time
|
|
|
if(ip_statistics[ipAddressSender].pkts_sent==0){
|
|
@@ -517,7 +517,7 @@ void statistics::addIpStat_packetSent(const std::string &ipAddressSender, const
|
|
|
|
|
|
if(this->getDoExtraTests()) {
|
|
|
// Increment Degrees for sender and receiver, if Sender sends its first packet to this receiver
|
|
|
- std::unordered_set<std::string>::const_iterator found_receiver = contacted_ips[ipAddressSender].find(ipAddressReceiver);
|
|
|
+ std::unordered_set<IPv4Address>::const_iterator found_receiver = contacted_ips[ipAddressSender].find(ipAddressReceiver);
|
|
|
if(found_receiver == contacted_ips[ipAddressSender].end()){
|
|
|
// Receiver is NOT contained in the List of IPs, that the Sender has contacted, therefore this is the first packet in this direction
|
|
|
ip_statistics[ipAddressSender].out_degree++;
|
|
@@ -525,7 +525,7 @@ void statistics::addIpStat_packetSent(const std::string &ipAddressSender, const
|
|
|
|
|
|
// Increment overall_degree only if this is the first packet for the connection (both directions)
|
|
|
// Therefore check, whether Receiver has contacted Sender before
|
|
|
- std::unordered_set<std::string>::const_iterator sender_contacted = contacted_ips[ipAddressReceiver].find(ipAddressSender);
|
|
|
+ std::unordered_set<IPv4Address>::const_iterator sender_contacted = contacted_ips[ipAddressReceiver].find(ipAddressSender);
|
|
|
if(sender_contacted == contacted_ips[ipAddressReceiver].end()){
|
|
|
ip_statistics[ipAddressSender].overall_degree++;
|
|
|
ip_statistics[ipAddressReceiver].overall_degree++;
|
|
@@ -677,7 +677,7 @@ std::string statistics::getFormattedTimestamp(time_t seconds, suseconds_t micros
|
|
|
* @param ipAddress The IP address whose statistics should be calculated.
|
|
|
* @return a ip_stats struct containing statistical data derived by the statistical data collected.
|
|
|
*/
|
|
|
-ip_stats statistics::getStatsForIP(const std::string &ipAddress) {
|
|
|
+ip_stats statistics::getStatsForIP(const IPv4Address ipAddress) {
|
|
|
float duration = getCaptureDurationSeconds();
|
|
|
entry_ipStat ipStatEntry = ip_statistics[ipAddress];
|
|
|
|