⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fromdagdump.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_FROMDAGDUMP_HH#define CLICK_FROMDAGDUMP_HH#include <click/element.hh>#include <click/task.hh>#include "elements/userlevel/fromfile.hh"CLICK_DECLSclass HandlerCall;/*=cFromDAGDump(FILENAME [, I<KEYWORDS>])=s analysisreads packets from a DAG/ERF file=dReads packets from a file in ERF format, produced by the University ofWaikato's DAG tools. Pushes them out the output, and optionally stops thedriver when there are no more packets.FromDAGDump also transparently reads gzip- and bzip2-compressed files, if youhave zcat(1) and bzcat(1) installed.Keyword arguments are:=over 8=item STOPBoolean.  If true, then FromDAGDump will ask the router to stop when it isdone reading its file (or the END time is reached).  Default is false.=item ACTIVEBoolean. If false, then FromDAGDump will not emit packets (until the`C<active>' handler is written). Default is true.=item FORCE_IPBoolean. If true, then FromDAGDump will emit only IP packets with their IPheader annotations correctly set. (If FromDAGDump has two outputs, non-IPpackets are pushed out on output 1; otherwise, they are dropped.) Default isfalse.=item STARTAbsolute time in seconds since the epoch. FromDAGDump will output packets withtimestamps after that time.=item START_AFTERArgument is relative time in seconds (or supply a suffix like `min', `h').FromDAGDump will skip the first I<T> seconds in the log.=item ENDAbsolute time in seconds since the epoch. FromDAGDump will stop whenencountering a packet with timestamp at or after that time.=item END_AFTERArgument is relative time in seconds (or supply a suffix like `min', `h').FromDAGDump will stop at the first packet whose timestamp is at least I<T>seconds after the first timestamp in the log.=item INTERVALArgument is relative time in seconds (or supply a suffix like `min', `h').FromDAGDump will stop at the first packet whose timestamp is at least I<T>seconds after the first packet output.=item END_CALLSpecify a handler to call once the end time is reached, or the dump runs outof packets.  This defaults to 'I<FromDAGDump>.active false'.  END_CALL andSTOP are mutually exclusive.=item SAMPLEUnsigned real number between 0 and 1. FromDAGDump will output each packet withprobability SAMPLE. Default is 1. FromDAGDump uses fixed-point arithmetic, sothe actual sampling probability may differ substantially from the requestedsampling probability. Use the C<sampling_prob> handler to find out the actualprobability.=item TIMINGBoolean. If true, then FromDAGDump tries to maintain the inter-packet timingof the original packet stream. False by default.=item ENCAPLegacy encapsulation type ("IP", "ATM", "SUNATM", "ETHER", "PPP", or"PPP_HDLC").  New-style ERF dumps contain an explicit encapsulation type oneach packet; you should not provide an ENCAP option for new-style ERF dumps.Legacy-format dumps don't contain any encapsulation information, however, soyou should supply an encapsulation type explicitly (or FromDAGDump will assumeENCAP type "ATM").=item MMAPBoolean. If true, then FromDAGDump will use mmap(2) to access the tcpdumpfile. This can result in slightly better performance on some machines.FromDAGDump's regular file discipline is pretty optimized, so the differenceis often small in practice. Default is true on most operating systems, butfalse on Linux.=backYou can supply at most one of START and START_AFTER, and at most one of END,END_AFTER, and INTERVAL.Only available in user-level processes.=nFromDAGDump sets packets' extra length annotations to any additional lengthrecorded in the dump.=h sampling_prob read-onlyReturns the sampling probability (see the SAMPLE keyword argument).=h active read/writeValue is a Boolean.=h encap read-onlyReturns the previous packet's encapsulation type.=h filename read-onlyReturns the filename supplied to FromDAGDump.=h filesize read-onlyReturns the length of the FromDAGDump file, in bytes, or "-" if that lengthcannot be determined (because the file was compressed, for example).=h filepos read-onlyReturns FromDAGDump's position in the (uncompressed) file, in bytes.=h extend_interval write-onlyText is a time interval. If END_TIME or one of its cousins was specified, thenwriting to this handler extends END_TIME by that many seconds. Also, ACTIVE isset to true.=aFromDump, ToDump, mmap(2) */class FromDAGDump : public Element { public:    FromDAGDump();    ~FromDAGDump();    const char *class_name() const		{ return "FromDAGDump"; }    const char *processing() const		{ return "a/ah"; }    void notify_noutputs(int);    int configure(Vector<String> &, ErrorHandler *);    int initialize(ErrorHandler *);    void cleanup(CleanupStage);    void add_handlers();    bool run_task();    Packet *pull(int);    void set_active(bool);      private:    struct DAGPosCell {	uint32_t hdlc;	uint8_t payload[44];    };    struct DAGEthernetCell {	uint8_t offset;	uint8_t padding;	uint8_t ether_dhost[6];	uint8_t ether_shost[6];	uint16_t ether_type;	uint8_t payload[32];    };    struct DAGATMCell {	uint32_t header;	uint8_t payload[44];    };    struct DAGAAL5Cell {	uint32_t header;	uint8_t payload[44];    };    struct DAGCell {	uint64_t timestamp;	uint8_t type;	uint8_t flags;	uint16_t rlen;	uint16_t lctr;	uint16_t wlen;	union {	    DAGPosCell pos;	    DAGEthernetCell ether;	    DAGATMCell atm;	    DAGAAL5Cell aal5;	} u;	enum { HEADER_SIZE = 16, CELL_SIZE = 64 };	enum { TYPE_LEGACY = 0, TYPE_HDLC_POS = 1, TYPE_ETH = 2, TYPE_ATM = 3,	       TYPE_AAL5 = 4, TYPE_MAX = TYPE_AAL5 };    };        static const uint32_t BUFFER_SIZE = 32768;    static const int SAMPLING_SHIFT = 28;    static const int dagtype2linktype[];    FromFile _ff;    Packet *_packet;    bool _swapped : 1;    bool _timing : 1;    bool _force_ip : 1;    bool _have_first_time : 1;    bool _have_last_time : 1;    bool _have_any_times : 1;    bool _first_time_relative : 1;    bool _last_time_relative : 1;    bool _last_time_interval : 1;    bool _active;    unsigned _sampling_prob;    int _linktype;    int _base_linktype;    Timestamp _first_time;    Timestamp _last_time;    HandlerCall *_end_h;        Task _task;    Timestamp _time_offset;    bool read_packet(ErrorHandler *);    void stamp_to_time(uint64_t, Timestamp &) const;    void prepare_times(const Timestamp &);    static String read_handler(Element *, void *);    static int write_handler(const String &, Element *, void *, ErrorHandler *);    };CLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -