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

📄 fromdump.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- mode: c++; c-basic-offset: 4 -*-#ifndef CLICK_FROMDUMP_HH#define CLICK_FROMDUMP_HH#include <click/element.hh>#include <click/task.hh>#include <click/notifier.hh>#include "fromfile.hh"CLICK_DECLSclass HandlerCall;/*=cFromDump(FILENAME [, I<keywords> TIMING, STOP, SAMPLE, FORCE_IP, START, START_AFTER, END, END_AFTER, INTERVAL, END_CALL, FILEPOS])=s analysisreads packets from a tcpdump(1) file=dReads packets from a file produced by `tcpdump -w FILENAME' or ToDump. Pushesthem out the output, and optionally stops the driver when there are no morepackets. If TIMING is true, then FromDump tries to maintain the timing of theoriginal packet stream. TIMING is false by default.FromDump also transparently reads gzip- and bzip2-compressed tcpdump files, ifyou have zcat(1) and bzcat(1) installed.Keyword arguments are:=over 8=item SAMPLEUnsigned real number between 0 and 1. FromDump will output each packet withprobability SAMPLE. Default is 1. FromDump uses fixed-point arithmetic, so theactual sampling probability may differ substantially from the requestedsampling probability. Use the C<sampling_prob> handler to find out the actualprobability.=item FORCE_IPBoolean. If true, then FromDump will emit only IP packets with their IP headerannotations correctly set. (If FromDump has two outputs, non-IP packets arepushed out on output 1; otherwise, they are dropped.) Default is false.=item STOPBoolean.  If true, then FromDump will ask the router to stop when it is donereading its tcpdump file (or the END time is reached).  Default is false.=item STARTAbsolute time in seconds since the epoch. FromDump will output packets withtimestamps after that time.=item START_AFTERArgument is relative time in seconds (or supply a suffix like `min', `h').FromDump will skip the first I<T> seconds in the log.=item ENDAbsolute time in seconds since the epoch. FromDump will stop when encounteringa packet with timestamp at or after that time.=item END_AFTERArgument is relative time in seconds (or supply a suffix like `min', `h').FromDump 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').FromDump 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<FromDump>.active false'.  END_CALL and STOPare mutually exclusive.=item TIMINGBoolean. Same as the TIMING argument.=item ACTIVEBoolean. If false, then FromDump will not emit packets (until the `C<active>'handler is written). Default is true.=item MMAPBoolean. If true, then FromDump will use mmap(2) to access the tcpdump file.This can result in slightly better performance on some machines. FromDump'sregular file discipline is pretty optimized, so the difference is often smallin practice. Default is true on most operating systems, but false on Linux.=item FILEPOSFile offset. If supplied, then FromDump will start emitting packets fromthis (uncompressed) file position. This is dangerous; there's no cheap wayto check whether you got the offset wrong, and if you did get it wrong,FromDump 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.=nBy default, `tcpdump -w FILENAME' dumps only the first 68 bytes ofeach packet. You probably want to run `tcpdump -w FILENAME -s 2000' or somesuch.FromDump sets packets' extra length annotations to any additional lengthrecorded in the dump.FromDump is a notifier signal, active when the element is active and the dumpcontains more packets.If FromDump uses mmap, then a corrupt file might cause Click to crash with asegmentation violation.=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 file's encapsulation type.=h filename read-onlyReturns the filename supplied to FromDump.=h filesize read-onlyReturns the length of the FromDump file, in bytes, or "-" if that lengthcannot be determined (because the file was compressed, for example).=h filepos read/writeReturns or sets FromDump'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.=aToDump, FromDevice.u, ToDevice.u, tcpdump(1), mmap(2), AggregateIPFlows,FromTcpdump */class FromDump : public Element { public:    FromDump();    ~FromDump();    const char *class_name() const		{ return "FromDump"; }    const char *processing() const		{ return "a/ah"; }    void *cast(const char *);    void notify_noutputs(int);    int configure(Vector<String> &, ErrorHandler *);    int initialize(ErrorHandler *);    void cleanup(CleanupStage);    void add_handlers();    FromDump *hotswap_element() const;    void take_state(Element *, ErrorHandler *);    bool run_task();    Packet *pull(int);    void set_active(bool);      private:    enum { BUFFER_SIZE = 32768, SAMPLING_SHIFT = 28 };    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 _extra_pkthdr_crap;    unsigned _sampling_prob;    int _minor_version;    int _linktype;    Timestamp _first_time;    Timestamp _last_time;    HandlerCall *_end_h;        Task _task;    ActiveNotifier _notifier;    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 + -