⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utility.cc

📁 clustering for ns-2 simulation
💻 CC
字号:

/**
 * Copyright (c) 2006 Michele Mastrogiovanni.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 */
 
#include <iostream>
#include "Utility.h"

using namespace std;

void 
Utility::dump() {
	//
	// Stampa del debug di una simulazione:
	//
	// IDNodo
	//		Bytes / Messaggi trasmessi UNICAST.
	//      Bytes / Messaggi trasmessi BROADCAST.
	//      Bytes / Messaggi ricevuti UNICAST.
	//      Bytes / Messaggi ricevuti BROADCAST.
	//      Durata Livello.
	//      EnergiaConsumata.
	//
	// PacchettiPersiALivelloFisico 
	// BytesPersiALivelloFisico
	// NumeroClusters   Cluster1 ... ClusterM
	//
	cout << algorithm << " ";
	
	time = 0;
	energy = 0;
	
	for (NodeList::iterator node = getNodes().begin(); node != getNodes().end(); node++) {
		// IDNodo
		cout << (*node) << " ";
		
		// Bytes / Messaggi trasmessi UNICAST
		cout << getTransmitted(*node, true, true) << " ";
		cout << getTransmitted(*node, false, true) << " ";
		
		// Bytes / Messaggi trasmessi BROADCAST
		cout << getTransmitted(*node, true, false) << " ";
		cout << getTransmitted(*node, false, false) << " ";
		
		// Bytes / Messaggi ricevuti UNICAST
		cout << getReceived(*node, true, true) << " ";
		cout << getReceived(*node, false, true) << " ";
		
		// Bytes / Messaggi ricevuti BROADCAST
		cout << getReceived(*node, true, false) << " ";
		cout << getReceived(*node, false, false) << " ";
		
		// Tempo di creazione del backbone
		cout << getTimeConsumption(*node) << " ";
		
		// Energia consumata
		cout << getEnergyConsumption(*node) << " ";
		
		time += getTimeConsumption(*node);
		energy += getEnergyConsumption(*node);
		
	}   
	
	// double physicPackets = (packetsTransmit / getNodes().size());
	// double physicBytes = (bytesTransmit / getNodes().size());
	
	// Pacchetti / Bytes trasmessi a livello fisico (in totale)
	cout << packetsTransmit << " " << bytesTransmit << " ";
	// cout << physicPackets << " " << physicBytes << " ";
	
	// Clusters
	cout << getNodes().size() << " ";
	int clusters = 0;
	int notClusters = 0;
	for (NodeList::iterator node = getNodes().begin(); node != getNodes().end(); node++) {
		cout << (*node) << " " << getClusterHead(*node) << " ";
		if (getClusterHead(*node) == (*node))
			clusters++;
		else
			notClusters++;
//		else if (getClusterHead(*node) != -1)
//			notClusters++;
	}
	
	time /= getNodes().size();
	energy /= getNodes().size();

	cerr << algorithm << endl;
	cerr << "\t- " << getNodes().size() << " nodes" << endl;
	cerr << "\t- ";
	if (clusters > 0)
		cerr << "Cluster: " << clusters << "/" << (clusters + notClusters) << endl;
	else
		cerr << "Cluster: No One" << endl;
	cerr << "\t- Avg. Time: " << time << endl;
	cerr << "\t- Avg. Energy: " << energy << endl;
	cerr << "\t- Overhead: " << bytesTransmit << endl;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -