📄 transmittedqueue.hh
字号:
#ifndef TRANSMITTEDQUEUE_HH#define TRANSMITTEDQUEUE_HHCLICK_DECLS/* * =c * TransmittedQueue () * =s Wifi, Wireless Routing * stores transmitted packets and decodes received packets * =d * It's a collection of storage, one per neighbour and two-hop neighbour, * but they are managed slightly differently but with overlaps * packets are mostly meant for decoding, but some would be used for retransmission * * 'queue' is probably a misnomer * Input 0: packets forwarded by the router -> clone and add to the appropriate queue * Input 1: packets for decoding * Output 1: decoded packets for normal processing (push) * Output 0: the packet just added to the queue (push) */#include<click/element.hh>//#include<elements/standard/simplequeue.hh>#include<click/bighashmap.hh>#include<click/timer.hh>#include<click/packet.hh>#include <click/ipaddress.hh>#include <click/string.hh>#include "scrambler.hh"class TransmittedQueue : public Element, public Scrambler { public: TransmittedQueue(); ~TransmittedQueue(); const char *class_name() const { return "TransmittedQueue"; } const char *processing() const { return PUSH;} void *cast(const char *); int configure(Vector<String> &conf, ErrorHandler *); int initialize(ErrorHandler *); void run_timer(); void add_handlers(); static String stats(Element *, void *); static int static_clear(const String &arg, Element *e, void *, ErrorHandler *errh); void push(int port, Packet *); //Packet* pull(int port); //void add_await_ack_entry(uint32_t, uint32_t, uint32_t); //void process_ack(); // *****signature list incomplete void reset(); // for statistics int _decoded; // counts how many packets have been decoded int _added; // how many packets have been added to the storage int _removed; // how many packets have been removed from the storage int _overheard; // how many encoded packets overheard that's not for me int _undecodable; // packets that cannot be decoded due to missing matching packets int _expired; // packets removed due to timeout int _dupe; // duplicate encoded packets received int _unacked; // number of packets awaiting acks int _retxed; // number of packets retransmitted (inc. retx of the same packets) class PacketEntry { public: // these are keys for the two levels of hashmaps in _queues below uint32_t _nb; // the ip address of the next-hop or two-hop neighbour uint16_t _seq; // the seq number of the corresponding packet uint32_t _src; // the src ip address of the packet PacketEntry (uint32_t nb, uint16_t seq, uint32_t src) : _nb(nb), _seq(seq), _src(src) {} }; private: // ip address IPAddress _ip; // -- for storage // key is "src IP" + "packet seq number", value is a point to the packet typedef HashMap<String, Packet*> Per2hopNbQ; // key is two-hop neighbour's IPaddress, value is the transmitted queue for it typedef HashMap<IPAddress, Per2hopNbQ*> TxQueues; TxQueues _queues; // note: since ack is added to encoded packets, the queues above will also hold // packets that do not have a next2hop, so again the names might be misleading // the structures are the same though. // ---------------- // -- for ack/retransmit // sometimes it's necessary to reference the above packets according to the next hop // so a similar structure to hold PacketEntry info // key is "src IP" + "packet seq number", value is a point to the PacketEntry // so that we can reference the packet eventually typedef HashMap<String, PacketEntry*> NbEntries; // key is next hop IPaddress, value is the nb entries typedef HashMap<IPAddress, NbEntries*> AckEntries; AckEntries _await_acks; // ---------------- // a vector of vectors to keep track of packets to be expunged // the size of the top-level vector is the timeout //Vector<Packet*> _decoded_packets; // -- for packet removal // timeout to expunge packets, in milliseconds int _timeout; // granularity of timeouts, in milliseconds int _granularity; typedef Vector<PacketEntry*> PerUnitEntries; // a vector of vectors to keep track of which packets were received at what time // the index of the top level vector indicates how many 'units' (50 millisecond for now) // have passed since the start of the record Vector<PerUnitEntries*> _removal_entries; // the time the earliest packets were stored int _start_time; Timer _timer; void clear_entries(PerUnitEntries *);};CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -