Page MenuHomec4science

order.hh
No OneTemporary

File Metadata

Created
Wed, Jul 16, 18:32

order.hh

#ifndef CLICK_ORDER_HH
#define CLICK_ORDER_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 <stdio.h>
//#include <stdlib.h>
#include "routinglinks.hh"
//For debug_output:
#ifdef CLICK_USERLEVEL
# include <stdarg.h>
#endif
CLICK_DECLS
class RoutingLinks;
// hashtable for the pointers of the packets waiting in the buffer for each src
// hashtable for the last sequences seen for each Formatted route
typedef HashTable<FormatedRoute, uint16_t> SeqFormRoute;
// if we have not received any packet from a specific source for more than <source_lifetime_s> seconds, all the data for the source are deleted
/*
* class Order:
* Click element in charge of filtering traffic for this destination
*/
class Order : public Element {
public:
Order();
~Order();
//This is to return _notifier
void *cast(const char *);
const char *class_name() const { return "Order"; }
const char *port_count() const { return "1/1-2"; }
//push input 0 : packets to re-order
//push output 0 : re-ordered packets to deliver
//push output 1: NACKS
const char *processing() const { return "h/h"; }
int configure(Vector<String> &, ErrorHandler *);
int initialize(ErrorHandler *);
void set_rtl(RoutingLinks *);
void push(int port, Packet*);
void notify_invalid_route(FormatedRoute,IPAddress);
void run_timer(Timer*);
void set_active(bool active) {_active=active;}
void set_debug(bool debug) {_debug=debug;}
void set_verb_debug(bool debug) {_verb_debug=debug;}
void set_debug_nack(bool debug) {_debug_nack=debug;}
void set_packet_timeout(int arg) {_packet_lifetime_ms=arg;}
void set_route_timeout(int arg) {_route_lifetime_ms=arg;}
void set_nack_freq(int arg) {_with_nack_freq=arg;}
void set_debug_explore(bool b) {_debug_explore=b;}
static int active_handler(const String &, Element *, void *,ErrorHandler *);
static int bool_handler(const String &, Element *, void *,ErrorHandler *);
static int reset_handler(const String &, Element *, void *,ErrorHandler *);
static int int_handler(const String &, Element *, void *,ErrorHandler *);
void add_handlers();
private:
//////////// variables : ///////////////////
ActiveNotifier _notifier;
bool _debug;
bool _debug_nack;
bool _debug_explore;
bool _verb_debug;
bool _active;
bool _strip_empower;
RoutingLinks *_rtl;
Timer _expire_timer_s;
Timer _packet_timeout_timer;
Timer _active_timer;
Timer _nack_timer;
int _packet_lifetime_ms;
int _route_lifetime_ms;
int _source_lifetime_s;
int _print_stats_freq;
int _max_num_routes;
uint32_t _dropped;
int _sent_timeout;
int _nacks_sent;
bool _delayed_reordering;
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)
int _packets_sent_delayed;
int _expired_not_sent;
int _with_nack_freq;
HashTable<IPAddress, HashTable<uint16_t, Timestamp> > _missed_packets;
HashTable<FormatedRoute,FormatedRoute> _reversed_routes;
int _missed_packets_int;
HashTable<IPAddress, uint16_t> _last_seq_checked;
int _caught_missed_packet;
int _saved_packets;
int _received_packets;
int _received_explore;
int _sent_explore;
int _sent_explore_timeout;
int _sent_explore_error;
// to push packets after some time
bool _timeout_packets;
HashTable<IPAddress, uint16_t> _packet_2period_ago;
HashTable<IPAddress, uint16_t> _packet_1period_ago;
int alpha_ts; //per 1000
// HashTable<IPAddress, HashTable<FormatedRoute, Timestamp> > _froute2delta;
// HashTable<IPAddress, HashTable<FormatedRoute, uint32_t> > _froute2rate;
uint16_t _current_arrived_seq;
// HashTable<IPAddress,Timestamp> _waiting_time;
// HashTable<IPAddress,Timestamp> _expiration_time;
struct TimerData{
Order* order;
IPAddress * src;
};
HashTable<IPAddress,uint16_t> _seqTable; //the table of the last sequence number seen per source
HashTable<IPAddress,uint16_t> _seqTableTimer; //the table of the last sequence number seen per source, stored every 5 sec to check if some src becomes inactive
HashTable<IPAddress,PacketTable*> _pktTables; //the table of the stored packets waiting to be pushed per source
HashTable<IPAddress,SeqFormRoute*> _SeqFormRouteTables; //the table of the last seen sequence per formatted route
HashTable<IPAddress,SeqFormRoute*> _SeqFormRouteTablesTemp; //the table of the last seen sequence per formatted route before the source timer expired last time(used to check if a route is too slow)
HashTable<IPAddress,Timer*> _timersTable; //the table of the timers per source, to use later maybe to wait when a new source is added for new routes (some hundreds of ms)
//HashTable<IPAddress,bool> _timer_firedTable; //the table of bool variables that indicate if the timers are fired per source
HashTable<IPAddress,bool> _newsrcTable; // the table that indicates whether a src is new, so that we wait for some time until all the routes have sent some packet
HashTable<FormatedRoute,Timestamp> _froute2ts; // table with timestamps of when was the route last seen
HashTable<IPAddress,Timestamp> _src2ts; // table with timestamps of when was the src last seen
static void handleExpiry(Timer*, void *); // callback function for timers
void expire(const IPAddress & src,TimerData *); // called when timer expires
uint16_t getCurrentSeqNum(IPAddress const& src, uint16_t seq = 1);
void update_route(FormatedRoute froute, IPAddress const& src, uint16_t seq, Packet *);
void createTimer(IPAddress const& src);
void updateTimer(IPAddress const& src);
void remove_routes(IPAddress);
uint32_t pushOldPackets(IPAddress const& src, uint16_t const seq, bool);
Packet *delete_routing_header(Packet*);
void reset();
struct PacketTimerData{
Order* elmt;
IPAddress *src;
uint16_t seq;
};
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
};
CLICK_ENDDECLS
#endif

Event Timeline