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

📄 fromnlanrdump.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_FROMNLANRDUMP_HH#define CLICK_FROMNLANRDUMP_HH#include <click/element.hh>#include <click/task.hh>#include <clicknet/tcp.h>#include "elements/userlevel/fromfile.hh"CLICK_DECLSclass HandlerCall;/*=cFromNLANRDump(FILENAME [, I<KEYWORDS>])=s analysisreads packets from an NLANR file=dReads IP packets from a file in a format used for NLANR traces: either FR,FR+, or TSH. Pushes them out the output, and optionally stops the driver whenthere are no more packets.FromNLANRDump also transparently reads gzip- and bzip2-compressed files, ifyou have zcat(1) and bzcat(1) installed.Keyword arguments are:=over 8=item FORMATString.  Should be either 'fr', 'fr+', 'tsh', or 'guess'.  Default is 'guess'.=item STOPBoolean.  If true, then FromNLANRDump 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 FromNLANRDump will not emit packets (until the`C<active>' handler is written). Default is true.=item FORCE_IPBoolean. This argument is ignored; it's here for compatibility with FromDumpand the like. FromNLANRDump behaves as if FORCE_IP was set to true.=item STARTAbsolute time in seconds since the epoch. FromNLANRDump will output packets withtimestamps after that time.=item START_AFTERArgument is relative time in seconds (or supply a suffix like `min', `h').FromNLANRDump will skip the first I<T> seconds in the log.=item ENDAbsolute time in seconds since the epoch. FromNLANRDump 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').FromNLANRDump 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').FromNLANRDump 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<FromNLANRDump>.active false'.  END_CALL andSTOP are mutually exclusive.=item SAMPLEUnsigned real number between 0 and 1. FromNLANRDump will output each packet withprobability SAMPLE. Default is 1. FromNLANRDump 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 FromNLANRDump tries to maintain the inter-packet timingof the original packet stream. False by default.=item MMAPBoolean. If true, then FromNLANRDump will use mmap(2) to access the tcpdumpfile. This can result in slightly better performance on some machines.FromNLANRDump's regular file discipline is pretty optimized, so the differenceis often small in practice. Default is true on most operating systems, butfalse on Linux.=item FILEPOSFile offset. If supplied, then FromNLANRDump will start emitting packets fromthis (uncompressed) file position. This is dangerous; if you get the offsetwrong, FromNLANRDump will emit garbage.=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.=nIn TSH dumps, FromNLANRDump sets packets' link annotations to the link numberstored 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 "IP".=h filename read-onlyReturns the filename supplied to FromNLANRDump.=h filesize read-onlyReturns the length of the FromNLANRDump file, in bytes, or "-" if that lengthcannot be determined (because the file was compressed, for example).=h filepos read-onlyReturns FromNLANRDump's position in the (uncompressed) file, in bytes.=h packet_filepos read-onlyReturns the (uncompressed) file position of the last packet emitted, in bytes.This handler is useful for elements like AggregateIPFlows that can recordstatistics about portions of a trace; with packet_filepos, they can noteexactly where the relevant portion begins.=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 FromNLANRDump : public Element { public:    FromNLANRDump();    ~FromNLANRDump();    const char *class_name() const		{ return "FromNLANRDump"; }    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:    enum { C_FR, C_FRPLUS, C_TSH };    struct FRCell {	uint32_t timestamp_sec;	uint32_t timestamp_usec;	uint32_t ip_src;	uint32_t ip_dst;	uint16_t ip_len;	uint8_t ip_p;	uint8_t th_flags;	uint16_t sport;	uint16_t dport;	enum { SIZE = 24 };    };    struct FRPlusCell {	uint32_t timestamp_sec;	uint32_t timestamp_usec;	click_ip iph;	click_tcp tcph;		// last 4 bytes left off	enum { SIZE = 44 };    };    struct TSHCell {	uint32_t timestamp_sec;	uint32_t timestamp_usec; // upper 8 bits are interface #	click_ip iph;	click_tcp tcph;		// last 4 bytes left off	enum { SIZE = 44 };    };        static const uint32_t BUFFER_SIZE = 32768;    static const int SAMPLING_SHIFT = 28;    FromFile _ff;    Packet *_packet;        bool _timing : 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 _format;    int _cell_size;    Timestamp _first_time;    Timestamp _last_time;    HandlerCall *_end_h;        Task _task;    Timestamp _time_offset;    off_t _packet_filepos;    bool read_packet(ErrorHandler *);    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 + -