📄 codingmanager.hh
字号:
#ifndef CODINGMANAGER_HH#define CODINGMANAGER_HH/* * =c * CodingManager() * =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 <click/etheraddress.hh>#include <click/ipaddress.hh>#include <click/timer.hh>#include "xorheader_general.hh"#include "guessmanager.hh"#include "listenmanager.hh"#include "sendmanager.hh"#include "aliastable.hh"#include "common.hh"class CodingManager : public SimpleQueue { public: CodingManager(); ~CodingManager(); /* // const char *class_name() const { return "CodingManager"; } //const char *processing() const { return PUSH_TO_PULL; } // shouldn't be necessary // void *cast(const char *); static int enable_coding(const String &arg, Element *e, void *, ErrorHandler *errh); */ void set_enable_coding(bool ea) {_enable_coding = ea;} // 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); bool _fix_enc_dst; EtherAddress _enc_dst; void add_virtual(Packet*); WritablePacket* find_coding_candidates(int, int *, int *); typedef Vector<PacketState*> CodedPktList; struct CodedPktFilter { CodedPktList _coded_pkts; CodedPktFilter(CodedPktList *codedpktlist) { CodedPktList::iterator x = codedpktlist->begin(); while (x < codedpktlist->begin()) { _coded_pkts.push_back((*x)); x++; } } bool operator()(const Packet *p) { struct click_ether *eth_p = (click_ether *)p->data(); EtherAddress dst = EtherAddress(eth_p->ether_dhost); const struct click_ip *ip_h = p->ip_header(); IPAddress src = IPAddress(ip_h->ip_src); uint16_t ipid = ntohs(ip_h->ip_id); PacketState *ps = new PacketState(dst, src, ipid); CodedPktList::iterator x = _coded_pkts.begin(); while (x < _coded_pkts.end()) { if ((*(*x)) == (*ps)) { return true; } } return false; } }; struct SrcIdfilter { const IPAddress _src; uint16_t _ipid; SrcIdfilter(IPAddress src, uint16_t ipid) : _src(src), _ipid(ipid) {} bool operator()(const Packet *p) { const struct click_ip *ip_h = p->ip_header(); if ((IPAddress(ip_h->ip_src) == _src) && (ntohs(ip_h->ip_id) == _ipid)) return true; return false; } }; uint32_t _missed_coding_opp;protected: typedef Vector<Packet *> CodedActualPkts; uint16_t _enc_ethtype; IPAddress _myip; AliasTable *_aliases; GuessManager *_guess_mgr; SimpleQueue _tbuf; ListenManager *_listenmgr; SendManager *_sendmgr; bool _enable_coding; double _dec_prob_thresh; WritablePacket* combine_actual_pkts(CodedActualPkts*, int *, int); uint32_t get_qsize(EtherAddress); // variables for maintaining statisticsprivate: typedef Vector<PacketState*> NbrQueue; typedef HashMap<EtherAddress, NbrQueue*> NbrQueueMap; typedef Vector<EtherAddress> NbrList; uint32_t _ack_pk_len; NbrQueue _queue; NbrQueueMap _dtpk_map; NbrQueueMap _ackpk_map; uint8_t _max_coded_pkts; int find_position(PacketState*); bool is_coding_worthy(CodedPktList*, PacketState*); WritablePacket* combine_pkts(CodedPktList*, int *); void flush_queues(CodedPktList*); void del_pkt(PacketState*); WritablePacket* copy_pkt(Packet*); void log_tcpqsize(); //checking coding, can be deleted later /* void check_coding(Packet*, CodedActualPkts *); bool do_decoding(Packet *p_orig, uint8_t alias, CodedActualPkts *); WritablePacket* finish_decode(WritablePacket *dec, int idx); void xor_decode(WritablePacket *enc, Packet *pkt, int idx); void set_ip_cksum(WritablePacket*); */};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -