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

📄 pnc_standard.cc

📁 ns2.31下的UWB(Ultra WideBand)实现
💻 CC
字号:
#include "pnc_standard.h"#include "WiMedia_defs.h"PNCStandard::PNCStandard(PNC* pnc) {	pnc_ = pnc;	flow_count_ = 0;	superframe_size_ = 0;	// Set the superframe size to MAC153_FirstGTS_Guard_Time_	current_util_ = 0;}/*PNCStandard::~PNCStandard(){}*/void PNCStandard::StartBeaconing(BeaconTimer2 *beaconTimer) {	OnBeaconTimer(beaconTimer);}void PNCStandard::OnBeaconTimer(BeaconTimer2 *beaconTimer) {	pnc_->StartPolling(superframe_size_, beaconTimer);}bool PNCStandard::RequestGTS(int dev_id, int flowid, int duration, const char* traffic_type, const char* ack_type) {	if((current_util_ + duration) > MAX_SUPERFRAME_SIZE) {		return false;	}	current_util_ += duration;	current_util_ += pnc_->macmib_->GuardTime;	PNCFlowInfo &fi = pnc_->flow_info_[flow_count_];	fi.flow_id_ = flowid;	fi.dev_id_ = dev_id;	fi.util_ = duration;	fi.alloc_ = duration;		// Dapeng Debug	if(strcmp(traffic_type, "Traffic_NRT") == 0)		fi.traffic_type_ = Traffic_NRT;	else if (strcmp(traffic_type, "Traffic_CFT") == 0)		fi.traffic_type_ = Traffic_CFT;	else if (strcmp(traffic_type, "Traffic_CBR") == 0)		fi.traffic_type_ = Traffic_CBR;	else if (strcmp(traffic_type, "Traffic_MPEG") == 0)                fi.traffic_type_ = Traffic_MPEG;	if(strcmp(ack_type, "NoACK") == 0)		fi.ack_type_ = ACK_None;	else if(strcmp(ack_type, "ImmediateACK") == 0)		fi.ack_type_ = ACK_Immediate;	else if(strcmp(ack_type, "DelayedACK") == 0)		fi.ack_type_ = ACK_Delayed;	else {		exit(1);	}	++ flow_count_;	pnc_->flow_count_ = flow_count_;		int beacon_size = pnc_->mac_->TotalLen_Header() + 2 + flow_count_ * 6;	int beacon_time = pnc_->macmib_->AFirstGTSGap + pnc_->mac_->usec(pnc_->mac_->TxTime_Bytes(beacon_size));	superframe_size_ = beacon_time + current_util_;	return false;} // End of RequestGTSint PNCStandard::ExecuteCommand(int argc, const char* const* argv){	if(argc == 8) {		if(strcmp(argv[2], "request-gts") == 0) {			int index = atoi(argv[3]);			int flowid = atoi(argv[4]);			int duration = atoi(argv[5]);			RequestGTS(index, flowid, duration, argv[6], argv[7]);			return TCL_OK;		}	}	return TCL_ERROR;}void PNCStandard::ProcessPacket(Packet *p) {	// Nothing to be done here.}void PNCStandard::PrintTitle() {	printf("Scheduler: WRR\n");}

⌨️ 快捷键说明

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