Examples/DpdkBridge/main.cpp
/**
 * Extract and print traffic stats from a device
 */
Extract and print traffic stats from a device
Extract and print traffic stats from a device
void printStats(pcpp::DpdkDevice* device)
{
	pcpp::DpdkDevice::DpdkDeviceStats stats;
	device->getStatistics(stats);
	std::cout << std::endl <<"Statistics for port " << device->getDeviceId() << ":" << std::endl;
	std::vector<std::string> columnNames;
	columnNames.push_back(" ");
	columnNames.push_back("Total Packets");
	columnNames.push_back("Packets/sec");
	columnNames.push_back("Total Bytes");
	columnNames.push_back("Bytes/sec");
	std::vector<int> columnLengths;
	columnLengths.push_back(10);
	columnLengths.push_back(15);
	columnLengths.push_back(15);
	columnLengths.push_back(15);
	columnLengths.push_back(15);
	pcpp::TablePrinter printer(columnNames, columnLengths);
	std::stringstream totalRx;
	totalRx << "rx" << "|" << stats.aggregatedRxStats.packets << "|" << stats.aggregatedRxStats.packetsPerSec << "|" << stats.aggregatedRxStats.bytes << "|" << stats.aggregatedRxStats.bytesPerSec;
	printer.printRow(totalRx.str(), '|');
	std::stringstream totalTx;
	totalTx << "tx" << "|" << stats.aggregatedTxStats.packets << "|" << stats.aggregatedTxStats.packetsPerSec << "|" << stats.aggregatedTxStats.bytes << "|" << stats.aggregatedTxStats.bytesPerSec;
	printer.printRow(totalTx.str(), '|');
}
void printStats ( pcpp :: DpdkDevice * device ) { pcpp :: DpdkDevice :: DpdkDeviceStats stats ; device -> getStatistics ( stats ) ; std :: cout << std :: endl << " " << device -> getDeviceId ( ) << " " << std :: endl ; std :: vector < std :: string > columnNames ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; columnNames . push_back ( " " ) ; std :: vector < int > columnLengths ; columnLengths . push_back ( 10 ) ; columnLengths . push_back ( 15 ) ; columnLengths . push_back ( 15 ) ; columnLengths . push_back ( 15 ) ; columnLengths . push_back ( 15 ) ; pcpp :: TablePrinter printer ( columnNames , columnLengths ) ; std :: stringstream totalRx ; totalRx << " " << " " << stats . aggregatedRxStats . packets << " " << stats . aggregatedRxStats . packetsPerSec << " " << stats . aggregatedRxStats . bytes << " " << stats . aggregatedRxStats . bytesPerSec ; printer . printRow ( totalRx . str ( ) , ' ' ) ; std :: stringstream totalTx ; totalTx << " " << " " << stats . aggregatedTxStats . packets << " " << stats . aggregatedTxStats . packetsPerSec << " " << stats . aggregatedTxStats . bytes << " " << stats . aggregatedTxStats . bytesPerSec ; printer . printRow ( totalTx . str ( ) , ' ' ) ; }
Extract and print traffic stats from a device
Extract and print traffic stats from a device