"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/netviz/port_histogram.h" (19 Feb 2021, 1393 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "port_histogram.h" see the Fossies "Dox" file reference documentation.

    1 /**
    2  * port_histogram.h: 
    3  * Show packets received vs port
    4  *
    5  * This source file is public domain, as it is not based on the original tcpflow.
    6  *
    7  * Author: Michael Shick <mike@shick.in>
    8  *
    9  */
   10 
   11 #ifndef PORT_HISTOGRAM_H
   12 #define PORT_HISTOGRAM_H
   13 
   14 class port_histogram {
   15 public:
   16     port_histogram() :
   17         port_counts(), data_bytes_ingested(0), buckets(), buckets_dirty(true) {}
   18 
   19     class port_count {
   20     public:
   21         port_count(uint16_t port_, uint64_t count_) :
   22             port(port_), count(count_) {}
   23         uint16_t port;
   24         uint64_t count;
   25     };
   26     //typedef uint16_t port_t;
   27 
   28     class descending_counts {
   29     public:
   30         bool operator()(const port_count &a, const port_count &b);
   31     };
   32 
   33     void increment(uint16_t port, uint64_t delta);
   34     const port_count &at(size_t index);
   35     size_t size();
   36     uint64_t ingest_count() const;
   37 
   38     typedef std::vector<port_count> port_count_vector;
   39 
   40     port_count_vector::const_iterator begin();
   41     port_count_vector::const_iterator end();
   42     port_count_vector::const_reverse_iterator rbegin();
   43     port_count_vector::const_reverse_iterator rend();
   44 
   45     static const size_t bucket_count;
   46 
   47 private:
   48     typedef std::map<in_port_t, uint64_t> port_counts_t;
   49     port_counts_t port_counts;
   50     uint64_t data_bytes_ingested;
   51     std::vector<port_count> buckets;
   52     bool buckets_dirty;
   53 
   54     void refresh_buckets();
   55 };
   56 
   57 #endif