//=========================================================================== // @(#) $Name: $ // @(#) $Id: ArtsAsMatrixAggregator.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 _ARTSASMATRIXAGGREGATOR_HH_ #define _ARTSASMATRIXAGGREGATOR_HH_ #include #include #include "ArtsAsMatrix.hh" class ArtsAsMatrixKeyValue { public: bool operator < (const ArtsAsMatrixKeyValue keyValue) const; bool operator == (const ArtsAsMatrixKeyValue keyValue) const; uint16_t srcAs; uint16_t dstAs; }; //--------------------------------------------------------------------------- // class ArtsAsMatrixAggregator //--------------------------------------------------------------------------- // This class is used to aggregate AS matrix objects in the time // domain. //--------------------------------------------------------------------------- class ArtsAsMatrixAggregator { public: typedef struct { uint64_t Pkts; uint64_t Bytes; } counter_t; //------------------------------------------------------------------------- // ArtsAsMatrixAggregator(const Arts & arts) //......................................................................... // construct from an Arts object. //------------------------------------------------------------------------- ArtsAsMatrixAggregator(const Arts & arts); //------------------------------------------------------------------------- // void Add(const Arts & arts) //......................................................................... // Add the contents of an Arts object. The input Arts object must be // an AS matrix object. The effect here is to add any new AS matrix // entries and add to the counters for existing AS matrix entries. //------------------------------------------------------------------------- void Add(const Arts & arts); //------------------------------------------------------------------------- // ArtsAsMatrix *ConvertToArtsAsMatrix() const //......................................................................... // Return an ArtsAsMatrix object (dynamically allocated) containing // the aggregate data. The caller is responsible for calling delete() // on the returned ArtsAsMatrix pointer. //------------------------------------------------------------------------- ArtsAsMatrix *ConvertToArtsAsMatrix() const; //------------------------------------------------------------------------- // vector > * // TopSourcesByBytes(uint16_t numSources) //......................................................................... // Returns a vector of ArtsAsMatrixEntry containing the top numSources // source AS numbers and their corresponding pkt/byte counters. Note // that instead of adding to our type space, we use the // ArtsAsMatrixEntry class. In the returned vector, the Dst() // for each ArtsAsMatrixEntry will always be 0 since we're adding up // data to every destination AS for each source AS. // // This member is what lets us easily pick out the top N source ASes // 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 ASes. //------------------------------------------------------------------------- vector *TopSourcesByBytes(uint16_t numDests); //------------------------------------------------------------------------- // vector * // TopDestinationsByBytes(uint16_t numSources) //......................................................................... // Returns a vector of ArtsAsMatrixEntry containing the top numDests // destination AS numbers and their corresponding pkt/byte counters. // Note that instead of adding to our type space, we use the // ArtsAsMatrixEntry class. In the returned vector, the Src() // for each ArtsAsMatrixEntry will always be 0 since we're adding up // traffic from every source AS for each destination AS. // // This member is what lets us easily pick out the top N destination // ASes 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 ASes. //------------------------------------------------------------------------- vector *TopDestinationsByBytes(uint16_t numSources); //------------------------------------------------------------------------- // uint64_t TotalPkts() const //......................................................................... // Returns the sum of all packets in the ArtsAsMatrixAggregator // object. This is the sum of all packets for all contained AS // matrix entries. //------------------------------------------------------------------------- uint64_t TotalPkts() const; //------------------------------------------------------------------------- // uint64_t TotalBytes() const //......................................................................... // Returns the sum of all bytes in the ArtsAsMatrixAggregator // object. This is the sum of all bytes for all contained AS // matrix entries. //------------------------------------------------------------------------- uint64_t TotalBytes() const; private: ArtsHeader _header; vector _attributes; map > _asCounters; uint64_t _totalPkts; uint64_t _totalBytes; }; #endif // _ARTSASMATRIXAGGREGATOR_HH_