Page MenuHomec4science

delaytcp.hh
No OneTemporary

File Metadata

Created
Sat, Jul 5, 19:47

delaytcp.hh

#ifndef CLICK_DELAYTCP_HH
#define CLICK_DELAYTCP_HH
#include <click/element.hh>
#include <click/notifier.hh>
#include <click/router.hh>
#include <click/confparse.hh>
#include <click/ipaddress.hh>
#include <click/hashtable.hh>
#include <click/timer.hh>
#include <click/error.hh>
#include <click/args.hh>
#include <clicknet/tcp.h>
#include "util.hh"
CLICK_DECLS
// hashtable for the pointers of the packets waiting in the buffer for each src
typedef HashTable<uint16_t, Packet*> PacketTable;
typedef HashTable<uint16_t, FormatedRoute> RouteTable;
class DelayTcp : public Element {
public:
DelayTcp();
~DelayTcp();
const char *class_name() const { return "DelayTcp"; }
const char *port_count() const { return "1/1"; }
//push input 0 : packets to re-order
//push output 0 : re-ordered packets to deliver
const char *processing() const { return "h/h"; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
void push(int port, Packet*);
void run_timer(Timer*);
void set_active(bool active) {_active=active;_print_error=false;}
void set_debug(bool debug) {_debug=debug;}
void set_verb_debug(bool debug) {_verb_debug=debug;}
void set_fixed_delay(double a) {_fixed_delay = a;}
static int active_handler(const String &, Element *, void *,ErrorHandler *);
static int fixed_delay_handler(const String &, Element *, void *,ErrorHandler *);
static int debug_handler(const String &, Element *, void *,ErrorHandler *);
void add_handlers();
private:
//////////// variables : ///////////////////
bool _debug;
bool _verb_debug;
bool _active;
Timer _print_timer;
Timer _active_timer;
bool _print_error;
double _fixed_delay;
Timestamp _now;
// packet expiration
int alpha_ts; //per 1000
HashTable<IPAddress, HashTable<FormatedRoute, Timestamp> > _froute2delta;
HashTable<IPAddress, HashTable<FormatedRoute, uint32_t> > _froute2rate;
HashTable<IPAddress,Timestamp> _diff_route_delays;
HashTable<IPAddress,FormatedRoute> _route_max, _route_min;
HashTable<IPAddress,uint32_t> _route_max_proportion; // rate proportion of the route with max delay (per 1000)
HashTable<IPAddress,PacketTable*> _pktTables; //the table of the stored packets waiting to be pushed per source
HashTable<IPAddress,RouteTable*> _routeTables; //the table of the routes per seq id and source
HashTable<FormatedRoute, uint16_t> _last_seq; //table of last seq sent for each route
int _packets_received;
int _packets_sent_directly;
int _packets_sent_delayed;
int _packets_delayed_ooo;
HashTable<IPAddress, HashTable<uint16_t, Timestamp> > _expiration_time;
Timestamp _avg_waiting_time;
Timestamp _avg_waiting_time_ooo;
struct PacketTimerData{
DelayTcp* elmt;
IPAddress *src;
uint16_t seq;
};
void pushPackets(IPAddress,uint16_t,FormatedRoute);
void createPacketTimer(IPAddress const& src, uint16_t, Timestamp);
static void handleExpiryPacket(Timer*, void *); // callback function for timers
void expire_packet(PacketTimerData *); // called when timer expires
void reset();
};
CLICK_ENDDECLS
#endif

Event Timeline