//=========================================================================== // @(#) $Name: $ // @(#) $Id: ArtsPortTableData.hh,v 1.1.1.1 2000/03/29 22:53:58 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 _ARTSPORTTABLEDATA_HH_ #define _ARTSPORTTABLEDATA_HH_ extern "C" { #include #include "caida_t.h" } #include #include "ArtsPortTableEntry.hh" //--------------------------------------------------------------------------- // class ArtsPortTableData //--------------------------------------------------------------------------- // This class encapsulates the data portion of an ARTS port table object. // It contains a vector of ports entries, each of which contains a // port number plus packet and byte counters for traffic using the // port. //--------------------------------------------------------------------------- class ArtsPortTableData { public: //------------------------------------------------------------------------- // ArtsPortTableData() //......................................................................... // constructor //------------------------------------------------------------------------- ArtsPortTableData(); //------------------------------------------------------------------------- // ~ArtsPortTableData() //......................................................................... // destructor //------------------------------------------------------------------------- ~ArtsPortTableData(); //------------------------------------------------------------------------- // uint16_t SampleInterval() const //......................................................................... // Returns the sampling ratio, indicating the 1:N packet sampling // used to obtain the port data. Normally this value is 1, meaning // we're working with complete data sets (for example, from Cisco // flow-export). //------------------------------------------------------------------------- uint16_t SampleInterval() const; //------------------------------------------------------------------------- // uint16_t SampleInterval(uint16_t sampleInterval) //......................................................................... // Sets and returns the sampling ratio, indicating the 1:N packet // sampling used to obtain the port data. Normally this value is // 1, meaning we're working with complete data sets (for example, // from Cisco flow-export). //------------------------------------------------------------------------- uint16_t SampleInterval(uint16_t sampleInterval); //------------------------------------------------------------------------- // uint64_t TotalPkts() const //......................................................................... // Returns the total packets of traffic in the ArtsPortTableData // object. The total is the sum of all traffic for all ports // contained in the object. //------------------------------------------------------------------------- uint64_t TotalPkts() const; //------------------------------------------------------------------------- // uint64_t TotalPkts(uint64_t totalPkts) //......................................................................... // Sets and returns the total packets of traffic in the // ArtsPortTableData object. The total is the sum of all traffic for // all ports contained in the object. //------------------------------------------------------------------------- uint64_t TotalPkts(uint64_t totalPkts); //------------------------------------------------------------------------- // uint64_t TotalBytes() const //......................................................................... // Returns the total bytes of traffic in the ArtsPortTableData // object. The total is the sum of all traffic for all ports // contained in the object. //------------------------------------------------------------------------- uint64_t TotalBytes() const; //------------------------------------------------------------------------- // uint64_t TotalBytes(uint64_t totalBytes) //......................................................................... // Sets and returns the total bytes of traffic in the // ArtsPortTableData object. The total is the sum of all traffic for // all ports contained in the object. //------------------------------------------------------------------------- uint64_t TotalBytes(uint64_t totalBytes); //------------------------------------------------------------------------- // vector & PortEntries() const //......................................................................... // Returns a reference to the port entries contained in the object. //------------------------------------------------------------------------- vector & PortEntries() const; //------------------------------------------------------------------------- // void SortEntriesByBytes() //......................................................................... // Sorts the port table entries by their total bytes (InBytes() + // OutBytes()). //------------------------------------------------------------------------- void SortEntriesByBytes(); //------------------------------------------------------------------------- // void SortEntriesByPkts() //......................................................................... // Sorts the port table entries by their total packets (InPkts() + // OutPkts()). //------------------------------------------------------------------------- void SortEntriesByPkts(); //------------------------------------------------------------------------- // uint32_t ComputeLength(uint8_t version = 0) const //......................................................................... // Calculates the bytes required to store the ArtsPortTableData object // in a file. //------------------------------------------------------------------------- uint32_t ComputeLength(uint8_t version = 0) const; //------------------------------------------------------------------------- // uint32_t Length(uint8_t version = 0) const //......................................................................... // Returns the bytes required to store the ArtsPortTableData object // in a file. //------------------------------------------------------------------------- uint32_t Length(uint8_t version = 0) const; //------------------------------------------------------------------------- // istream& read(istream& is, uint8_t version = 0) //......................................................................... // Reads the contents of an ArtsPortTableData from an istream. // Returns the istream. //------------------------------------------------------------------------- istream& read(istream& is, uint8_t version = 0); //------------------------------------------------------------------------- // int read(int fd, uint8_t version = 0) //......................................................................... // Reads the contents of an ArtsPortTableData from a file descriptor. // Returns the number of bytes read if successful, else returns -1. //------------------------------------------------------------------------- int read(int fd, uint8_t version = 0); //------------------------------------------------------------------------- // ostream& write(ostream& os, uint8_t version = 0) const //......................................................................... // Writes the contents of an ArtsPortTableData to an ostream. // Returns the ostream. //------------------------------------------------------------------------- ostream& write(ostream& os, uint8_t version = 0) const; //------------------------------------------------------------------------- // int write(int fd, uint8_t version = 0) const //......................................................................... // Writes the contents of an ArtsPortTableData to a file descriptor. // Returns the number of bytes written if ssccessful, else returns // -1. //------------------------------------------------------------------------- int write(int fd, uint8_t version = 0) const; //------------------------------------------------------------------------- // ArtsPortTableData & // operator = (const ArtsPortTableData & artsPortTableData) //......................................................................... // Overloaded '=' operator for assigning one ArtsPortTableData object // to another. //------------------------------------------------------------------------- ArtsPortTableData & operator = (const ArtsPortTableData & artsPortTableData); //------------------------------------------------------------------------- // friend ostream& operator << (ostream& os, // const ArtsPortTableData & artsPortTableData) //......................................................................... // Overloaded ostream '<<' operator to dump the contents of an // ArtsPortTableData object to an ostream in a human-readable // form. Returns the ostream. //------------------------------------------------------------------------- friend ostream& operator << (ostream& os, const ArtsPortTableData & artsPortTableData); private: uint16_t _sampleInterval; uint64_t _totpkts; uint64_t _totbytes; mutable vector _portEntries; mutable uint32_t _length; }; #endif // _ARTSPORTTABLEDATA_HH_