Skip to content

Commit

Permalink
Disable timestamping for packets. We achieve 12 mpps with netmap
Browse files Browse the repository at this point in the history
  • Loading branch information
root authored and root committed May 13, 2015
1 parent c7e60c6 commit d51b5f7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 6 additions & 0 deletions src/fast_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions src/netmap_plugin/netmap_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion src/pfring_plugin/pfring_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit d51b5f7

Please sign in to comment.