Page MenuHomec4science

countbytes.hh
No OneTemporary

File Metadata

Created
Fri, Jul 4, 19:03

countbytes.hh

#ifndef CLICK_COUNTBYTES_HH
#define CLICK_COUNTBYTES_HH
#include <click/element.hh>
#include <click/notifier.hh>
#include <click/router.hh>
#include <click/confparse.hh>
#include <click/error.hh>
#include <click/config.h>
#include <click/args.hh>
#include "util.hh"
#include "routingpaths.hh"
#ifdef CLICK_USERLEVEL
# include <stdarg.h>
#endif
CLICK_DECLS
class RoutingPaths;
class CountBytes : public Element {
public:
CountBytes();
~CountBytes();
const char *class_name() const { return "CountBytes"; }
const char *port_count() const { return "1/1-2"; }
const char *processing() const { return AGNOSTIC; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
void push(int, Packet*);
Packet* pull(int);
void count_packet(Packet*);
void run_timer(Timer *timer);
void reset();
void reset_flow(IPAddress);
HashTable<IPAddress, Timestamp> get_time_table() {return _time_table;}
// handlers
void add_handlers();
static int bool_handler(const String &, Element *, void *,ErrorHandler *);
static int integer_handler(const String &, Element *, void *,ErrorHandler *);
static int objective_handler(const String &, Element *, void *,ErrorHandler *);
static int reset_flow_handler(const String &, Element *, void *,ErrorHandler *);
void set_active(bool b) {_active = b;}
void set_send_stop_ack(bool b) {_send_stop_ack = b;}
void set_objective(uint64_t n) {if(n!=_bytes_objective) reset(); _bytes_objective = n;}
void set_freq_print(int a) {_freq_print = a;_timer.schedule_after_sec(_freq_print);}
protected:
bool _active;
bool _debug;
bool _send_stop_ack;
uint64_t _bytes_objective;
int _freq_print;
Timer _timer;
IPAddress _my_ip;
RoutingPaths *_rtp;
HashTable<IPAddress, uint64_t> _bytes_flow;
HashTable<IPAddress, Timestamp> _first_packet;
HashTable<IPAddress, Timestamp> _last_active;
HashTable<IPAddress, Timestamp> _time_table;
};
CLICK_ENDDECLS
#endif

Event Timeline