📄 scramblequeue.hh
字号:
#ifndef SCRAMBLEQUEUE_HH#define SCRAMBLEQUEUE_HHCLICK_DECLS/* * =c * ScrambleQueue() * =s * in addition to doing what a FullNotifyQueue does, it looks for 'matching' packets and xor's them * =d * * while enqueueing a packet, the queue checks for 'matching' packets - * those whose src/dest are the reverse of each other - and xor's them to be * a new packet for broadcast * * are we supposed to explain the configuration parameter here? * ***********************/#include <click/element.hh>// #include <elements/standard/fullnotequeue.hh>#include <elements/standard/simplequeue.hh>#include <click/bighashmap.hh>#include <click/notifier.hh>#include "xorer.hh"#include "sendmanager.hh"#include "xorheader.hh"#include "recvmanager.hh"#include "listenmanager.hh"#include "ackheader.hh"#include "recpheader.hh"#include "codingmanager.hh"#include <click/etheraddress.hh>#include <click/ipaddress.hh>#include <click/timer.hh>class ScrambleQueue : public CodingManager, public Xorer { public: ScrambleQueue(); ~ScrambleQueue(); const char *class_name() const { return "ScrambleQueue"; } //const char *processing() const { return PUSH_TO_PULL; } // shouldn't be necessary void *cast(const char *); int configure(Vector<String>&, ErrorHandler *); void add_handlers(); int initialize(ErrorHandler*); static String stats(Element *, void *); static int static_clear(const String &arg, Element *e, void *, ErrorHandler *errh); static int enable_coding(const String &arg, Element *e, void *, ErrorHandler *errh); // static int use_bcast(const String &arg, Element *e, void *, ErrorHandler *errh); static int set_enc_dst(const String &arg, Element *e, void *, ErrorHandler *errh); Packet *find_xor_candidate(Packet *); Packet *pull(int); //basically inherit the method definition from parent class void push(int port, Packet *); //void extra_push(int port, Packet *); typedef HashMap<String, int> FlowCounter; FlowCounter _npackets; // number of packets for each (prev, next) neighbor pair FlowCounter _nrexmits; // number of rexmits per neighbor pair FlowCounter _nencoded; // number of encoded packets per neighbor pair FlowCounter _nunencoded; // number of unencoded packets per neighbor pair int _pulls; // number of pulls the queue has received unsigned int _avdepth; // average depth to look into the queue for an encoded packet int _pushes; // number of packets ever processed by the queue int _onlyack; // number of xmissions with only acks int _onlydata; // number of xmissions with only data int _nxorattempts; // number of times find_xor_candidate is called int _totencodedpkts; // number of packets encoded int _totunencodedpkts; // number of packets sent unencoded int _totrexmitpkts; // number of retransmitted packets int _totencodedbytes; // number of encoded bytes int _totunencodedbytes; // number of bytes sent unencoded int _totrexmitbytes; // number of retransmitted bytes // bool _scramble_enabled; // whether encoding is enabled // bool _use_bcast; // whether to set encoded packets to broadcast address // EtherAddress _enc_dst; // the dest ethernet address for encoded packets void wakeup_if_needed(); /* void register_next_rexmit_wakeup(uint32_t); */ void run_timer(); private: uint16_t _ack_ethtype; // the ethertype for packets with ack header- a bit of hack uint16_t _recp_ethtype; // the ethertype for packets with reception header- a bit of hack uint16_t _nothing_ethtype; EtherAddress _myea; // My ethernet address.// IPAddress _myip; // IP address // keep track of global sequence number to assign, clobber IP ID // because can't rely on it to be unique uint16_t _gseq; // keep track of next sequence number to assign per neighbor typedef HashMap<EtherAddress, uint16_t> NbSeq; NbSeq _nbseq; // SendManager *_sendmgr; RecvManager* _recvmgr; //static unsigned char empty_addr[] = { 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; // when converted, default of _enc_dst WritablePacket *combine(Packet*, Packet *); WritablePacket* add_header(WritablePacket*, Packet*, int, int); WritablePacket* handle_rexmits(int, uint32_t); WritablePacket* handle_new_xmits(int, uint32_t); void check_packet(Packet*); // packet size related stuff uint32_t _max_ack_size; uint32_t _max_recp_size; // timer related stuff uint32_t _min_timer_interval; uint32_t _next_ack_time; uint32_t _next_rexmit_time; uint32_t _next_recp_time; uint32_t _next_time_to_fire; uint32_t _last_time_fired; // queue related stuff uint32_t _fair_queue_thresh; void register_wakeup(); void update_timer(); Timer _timer; ActiveNotifier _empty_note; ActiveNotifier _full_note; enum { SLEEPINESS_TRIGGER = 9 }; int _sleepiness; int _useless_pulls;};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -