//=========================================================================== // @(#) $Name: $ // @(#) $Id: ArtsPortMatrixAggregator.hh,v 1.1.1.1 2000/03/29 22:53:59 kkeys Exp $ //=========================================================================== // CAIDA Copyright Notice // // By accessing this software, arts++, you are duly informed // of and agree to be bound by the conditions described below in this // notice: // // This software product, arts++, is developed by Daniel W. McRobb, and // copyrighted(C) 1998 by the University of California, San Diego // (UCSD), with all rights reserved. UCSD administers the CAIDA grant, // NCR-9711092, under which part of this code was developed. // // There is no charge for arts++ software. You can redistribute it // and/or modify it under the terms of the GNU General Public License, // v. 2 dated June 1991 which is incorporated by reference herein. // arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use // of it will not infringe on any third party's intellectual property // rights. // // You should have received a copy of the GNU GPL along with arts++. // Copies can also be obtained from: // // http://www.gnu.org/copyleft/gpl.html // // or by writing to: // // University of California, San Diego // // SDSC/CAIDA // 9500 Gilman Dr., MS-0505 // La Jolla, CA 92093 - 0505 USA // // Or contact: // // info@caida.org //=========================================================================== #ifndef _ARTSPORTMATRIXAGGREGATOR_HH_ #define _ARTSPORTMATRIXAGGREGATOR_HH_ #include #include #include "ArtsPortMatrix.hh" #include "ArtsSelectedPortTable.hh" class ArtsPortMatrixKeyValue { public: bool operator < (const ArtsPortMatrixKeyValue keyValue) const; bool operator == (const ArtsPortMatrixKeyValue keyValue) const; uint16_t srcPort; uint16_t dstPort; }; //--------------------------------------------------------------------------- // class ArtsPortMatrixAggregator //--------------------------------------------------------------------------- // This class is used to aggregate port matrix objects in the time // domain. //--------------------------------------------------------------------------- class ArtsPortMatrixAggregator { public: typedef struct { uint64_t Pkts; uint64_t Bytes; } counter_t; //------------------------------------------------------------------------- // ArtsPortMatrixAggregator(const Arts & arts) //......................................................................... // construct from an Arts object. //------------------------------------------------------------------------- ArtsPortMatrixAggregator(const Arts & arts); //------------------------------------------------------------------------- // void Add(const Arts & arts) //......................................................................... // Add the contents of an Arts object. The input Arts object must be // a port matrix object. The effect here is to add any new port matrix // entries and add to the counters for existing port matrix entries. //------------------------------------------------------------------------- void Add(const Arts & arts); //------------------------------------------------------------------------- // ArtsPortMatrix *ConvertToArtsPortMatrix() const //......................................................................... // Return an ArtsPortMatrix object (dynamically allocated) containing // the aggregate data. The caller is responsible for calling delete() // on the returned ArtsPortMatrix pointer. //------------------------------------------------------------------------- ArtsPortMatrix *ConvertToArtsPortMatrix() const; //------------------------------------------------------------------------- // uint16_t PickPort(const ArtsPortMatrixKeyValue & portmKey, // const ArtsPortChooser & portChooser) const //......................................................................... // Given an ArtsPortMatrixKeyValue and an ArtsPortChooser, return the // chosen port number. This returns the lower of the source and // destination port numbers in ArtsPortMatrixKeyValue that qualifies // the criteria in portChooser, or 0 if neither port meets the // portChooser criteria. //------------------------------------------------------------------------- uint16_t PickPort(const ArtsPortMatrixKeyValue & portmKey, const ArtsPortChooser & portChooser) const; //------------------------------------------------------------------------- // ArtsSelectedPortTable * // ConvertToArtsSelectedPortTable(const ArtsPortChooser & portChooser) const //......................................................................... // Returns an ArtsSelectedPortTable object (dynamically allocated) // containing the aggregate data. The returned object will be a // ArtsSelectedPortTable with data organized according to portChooser. // Port matrix entries which match portChooser criteria will get their // own table entries, all others will get lumped into port 0, and // we don't duplicate data. // The caller is responsible for calling delete() on the returned // ArtsSelectedPortTable object. //------------------------------------------------------------------------- ArtsSelectedPortTable * ConvertToArtsSelectedPortTable(const ArtsPortChooser & portChooser) const; //------------------------------------------------------------------------- // vector > * // TopSourcesByBytes(uint16_t numSources) //......................................................................... // Returns a vector of ArtsPortMatrixEntry containing the top numSources // source port numbers and their corresponding pkt/byte counters. Note // that instead of adding to our type space, we use the // ArtsPortMatrixEntry class. In the returned vector, the Dst() // for each ArtsPortMatrixEntry will always be 0 since we're adding up // data to every destination port for each source port. // // This member is what lets us easily pick out the top N source ports // in an aggregate object, usually so we can then go back over the // time-series data and create a stacked bar chart of bits/sec vs. // time for each of the top N source ports. //------------------------------------------------------------------------- vector *TopSourcesByBytes(uint16_t numDests); //------------------------------------------------------------------------- // vector * // TopDestinationsByBytes(uint16_t numSources) //......................................................................... // Returns a vector of ArtsPortMatrixEntry containing the top numDests // destination port numbers and their corresponding pkt/byte counters. // Note that instead of adding to our type space, we use the // ArtsPortMatrixEntry class. In the returned vector, the Src() // for each ArtsPortMatrixEntry will always be 0 since we're adding up // traffic from every source port for each destination port. // // This member is what lets us easily pick out the top N destination // ports in an aggregate object, usually so we can then go back over the // time-series data and create a stacked bar chart of bits/sec vs. // time for each of the top N destination ports. //------------------------------------------------------------------------- vector *TopDestinationsByBytes(uint16_t numSources); //------------------------------------------------------------------------- // uint64_t TotalPkts() const //......................................................................... // Returns the sum of all packets in the ArtsPortMatrixAggregator // object. This is the sum of all packets for all contained port // matrix entries. //------------------------------------------------------------------------- uint64_t TotalPkts() const; //------------------------------------------------------------------------- // uint64_t TotalBytes() const //......................................................................... // Returns the sum of all bytes in the ArtsPortMatrixAggregator // object. This is the sum of all bytes for all contained port // matrix entries. //------------------------------------------------------------------------- uint64_t TotalBytes() const; private: ArtsHeader _header; vector _attributes; map > _portCounters; uint64_t _totalPkts; uint64_t _totalBytes; }; #endif // _ARTSPORTMATRIXAGGREGATOR_HH_