1
0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-11-15 13:34:32 +01:00

Disable timestamping for packets. We achieve 12 mpps with netmap

This commit is contained in:
Pavel Odintsov 2015-05-13 22:52:00 +02:00
parent 7799c6fcb5
commit 167484efaa
3 changed files with 19 additions and 4 deletions

@ -350,6 +350,12 @@ int extract_bit_value(uint8_t num, int bit) {
std::string print_simple_packet(simple_packet packet) {
std::stringstream buffer;
if (packet.ts.tv_sec == 0) {
// PF_RING and netmap do not generate timestamp for all packets because it's very CPU intensive operation
// But we want pretty attack report and fill it there
gettimeofday(&packet.ts, NULL);
}
buffer<<convert_timeval_to_date(packet.ts)<<" ";
buffer

@ -83,9 +83,13 @@ void consume_pkt(u_char* buffer, int len) {
memset(&packet_header, 0, sizeof(packet_header));
packet_header.len = len;
packet_header.caplen = len;
fastnetmon_parse_pkt((u_char*)buffer, &packet_header, 4, 1, 0);
// We do not calculate timestamps because timestamping is very CPU intensive operation:
// https://github.com/ntop/PF_RING/issues/9
u_int8_t timestamp = 0;
u_int8_t add_hash = 0;
fastnetmon_parse_pkt((u_char*)buffer, &packet_header, 4, timestamp, add_hash);
//char print_buffer[512];
//fastnetmon_print_parsed_pkt(print_buffer, 512, (u_char*)buffer, &packet_header);
//logger.info("%s", print_buffer);

@ -165,7 +165,12 @@ void parse_packet_pf_ring(const struct pfring_pkthdr *h, const u_char *p, const
// We should zeroify packet header because PFRING ZC did not do this!
memset((void*)&h->extended_hdr.parsed_pkt, 0, sizeof(h->extended_hdr.parsed_pkt));
pfring_parse_pkt((u_char*)p, (struct pfring_pkthdr*)h, 4, 1, 0);
// We do not calculate timestamps here because it's useless and consumes so much cpu
// https://github.com/ntop/PF_RING/issues/9
u_int8_t timestamp = 0;
u_int8_t add_hash = 0;
pfring_parse_pkt((u_char*)p, (struct pfring_pkthdr*)h, 4, timestamp, add_hash);
}
}