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

📄 ll-nodeb.cc

📁 对ns2软件进行UMTS扩展
💻 CC
📖 第 1 页 / 共 4 页
字号:
/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- *//* By Pablo Martin and Paula Ballester, * Strathclyde University, Glasgow. * June, 2003.*//* Copyright (c) 2003 Strathclyde University of Glasgow, Scotland. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code and binary code must contain * the above copyright notice, this list of conditions and the following * disclaimer. * * 2. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed at Strathclyde University of * Glasgow, Scotland. * * 3. The name of the University may not be used to endorse or promote * products derived from this software without specific prior written * permission. * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software * is provided "as is" without express or implied warranty of any kind.*/#include "packet.h"#include "delay.h"#include "mobilenode.h"#include "address.h"#include "arp.h"#include "queue.h"#include "cmu-trace.h"#include "mac-umts-nodeb.h"#include "ll-nodeb.h"#include "rlc-umts.h"#include <address.h>/******************************** Timers *********************************/void AppsNodebTimer::start(double time){	Scheduler &s = Scheduler::instance();	assert(busy_ == 0);	busy_ = 1;	paused_ = 0;	stime = s.clock();	rtime = time;	assert(rtime >= 0.0);	s.schedule(this, &intr, rtime);}void AppsNodebTimer::stop(void){	Scheduler &s = Scheduler::instance();	if(paused_ == 0)		s.cancel(&intr);	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;}void AppsNodebTimer::handle(Event *e){	Scheduler &s = Scheduler::instance();	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;	ll->RemoveFlowHandler(src_, dest_, size_, flow_);}////////////////////////// TNodebList Implementation ///////////////////////////////////////TNodebList:: ~TNodebList(){ TimerNodebPtr temp = Head;  CurrentPtr = Head;  while(CurrentPtr != NULL)  {CurrentPtr = CurrentPtr->Next;   delete temp;   temp=CurrentPtr;  }}void TNodebList::AddANode(nsaddr_t src, nsaddr_t dest, int size, int flow){Tail->Next = new AppsNodebTimer(ll); Tail=Tail->Next; Tail->src_ = src; Tail->dest_ = dest; Tail->size_ = size; Tail->flow_ = flow; return;}TimerNodebPtr TNodebList::Previous(TimerNodebPtr index){TimerNodebPtr temp=Head; if(index==Head) //special case, index IS the head :)  { return Head;  } while(temp->Next != index) { temp=temp->Next; } return temp;}void TNodebList::DeleteANode(TimerNodebPtr corpse){ TimerNodebPtr temp;  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}void TNodebList::DeleteANode(nsaddr_t src, int flow){ TimerNodebPtr temp, corpse;  corpse = GetNode(src, flow);  corpse->stop();  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}TimerNodebPtr TNodebList::GetNode(nsaddr_t src, int flow){ TimerNodebPtr t=Head;  while (t!=NULL){  	if ((t->flow_==flow) && (t->src_==src)){		return t;  	}  	t=t->Next;  }  return NULL;}void TNodebList::start(nsaddr_t src, int flow, double time){ TimerNodebPtr corpse;  corpse = GetNode(src, flow);  corpse->stop();  corpse->start(time);  return;}void TNodebList::stop(nsaddr_t src, int flow){ TimerNodebPtr corpse;  corpse = GetNode(src, flow);  corpse->stop();  return;}///////////////////////////////////////////////////////////////////////////////////////void ReleaseUETimer::start(double time){	Scheduler &s = Scheduler::instance();	assert(busy_ == 0);	busy_ = 1;	paused_ = 0;	stime = s.clock();	rtime = time;	assert(rtime >= 0.0);	s.schedule(this, &intr, rtime);}void ReleaseUETimer::stop(){	Scheduler &s = Scheduler::instance();	assert(busy_);	if(paused_ == 0)		s.cancel(&intr);	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;}void ReleaseUETimer::handle(Event *e){	busy_ = 0;	paused_ = 0;	stime = 0.0;	rtime = 0.0;	ll->RemoveUEHandler(addr_);}////////////////////////// RTNodebList Implementation ///////////////////////////////////////RTNodebList:: ~RTNodebList(){ RTimerNodebPtr temp = Head;  CurrentPtr = Head;  while(CurrentPtr != NULL)  {CurrentPtr = CurrentPtr->Next;   delete temp;   temp=CurrentPtr;  }}void RTNodebList::AddANode(int addr){Tail->Next = new ReleaseUETimer(ll); Tail=Tail->Next; Tail->addr_ = addr; return;}RTimerNodebPtr RTNodebList::Previous(RTimerNodebPtr index){RTimerNodebPtr temp=Head; if(index==Head) //special case, index IS the head :)  { return Head;  } while(temp->Next != index) { temp=temp->Next; } return temp;}void RTNodebList::DeleteANode(RTimerNodebPtr corpse){ RTimerNodebPtr temp;  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}void RTNodebList::DeleteANode(int addr){ RTimerNodebPtr temp, corpse;  corpse = GetNode(addr);  corpse->stop();  if(corpse == Head) //case 1 corpse = Head   {temp=Head;    Head=Head->Next;    delete temp;   }  else if(corpse == Tail) //case 2 corpse is at the end  { temp=Previous(corpse);    temp->Next=NULL;    delete corpse;    Tail=temp;  }  else //case 3 corpse is in middle somewhere  {temp=Previous(corpse);   temp->Next=corpse->Next;   delete corpse;  }  CurrentPtr=Head; //Reset the class tempptr}RTimerNodebPtr RTNodebList::GetNode(int addr){ RTimerNodebPtr t=Head;  while (t!=NULL){  	if (t->addr_==addr){		return t;  	}  	t=t->Next;  }  return NULL;}void RTNodebList::start(int addr, double time){ RTimerNodebPtr corpse;  corpse = GetNode(addr);  corpse->stop();  corpse->start(time);  return;}void RTNodebList::stop(int addr){ RTimerNodebPtr corpse;  corpse = GetNode(addr);  corpse->stop();  return;}///////////////////////////// Class LLNodeb ///////////////////////////////////// TCL classstatic class LLNodebClass : public TclClass {public:	LLNodebClass() : TclClass("LL/Nodeb") {}	TclObject* create(int, const char*const*) {		return (new LLNodeb);	}} class_llNodeb;// static structuresstruct location LLNodeb::registry_[MAX_NUM_NODES] = {0};int LLNodeb::verbose_ = {0};// constructorLLNodeb::LLNodeb() : LL(), phy_(0), rlc_(0), ifq_(0){	int i, j;	bind("verbose_", &verbose_);	for (i=0; i<MAX_NUM_NODES; i++) {		registry_[i].ue_ = -1;		registry_[i].nodeb_ = -1;	}	for (i=0; i<MAX_NUM_UE; i++) {		ue_info_[i].ipaddr_ = -1;		ue_info_[i].phyaddr_ = -1;		ue_info_[i].dltempsf_ = -1;		ue_info_[i].dlsf_ = -1;		ue_info_[i].dlfreq_ = -1;		ue_info_[i].dltotalr_ = 0;	}	refused = new linked_list;	flows_ = new FlowList;	removeflow_ = new TNodebList(this);	remove_ = new RTNodebList(this);	fl_= new PacketQueue();	for (i=0; i< MAX_NUM_FREQ; i++) {		dl_sftree[i] = new tree(512);	}}int LLNodeb::command(int argc, const char*const* argv){	Tcl& tcl = Tcl::instance();	if (argc == 3) {		if (strcmp(argv[1], "phy") == 0) {			phy_ = (PhyUmtsNodeb*) TclObject::lookup(argv[2]);                        assert(phy_);			phy_->tti() = ifq_->tti();			mac_->tti() = ifq_->tti();			return (TCL_OK);		}		if (strcmp(argv[1], "ifq") == 0) {			ifq_ = (BsFCQueue*) TclObject::lookup(argv[2]);                        assert(ifq_);			return (TCL_OK);		}		if (strcmp(argv[1], "rlc") == 0) {			rlc_ = (RlcUmtsNodeb*) TclObject::lookup(argv[2]);                        assert(rlc_);			return (TCL_OK);		}	}	else if (argc == 2) {		if (strcmp(argv[1], "phy") == 0) {			tcl.resultf("%s", phy_->name());			return (TCL_OK);		}		if (strcmp(argv[1], "ifq") == 0) {			tcl.resultf("%s", ifq_->name());			return (TCL_OK);		}		if (strcmp(argv[1], "on") == 0) {			MobileNode * node_ = (MobileNode*)(phy_->netif_->node());			ip_nodeb_ = node_->address();			rlc_->ip_nodeb() = ip_nodeb_;			ifq_->ip_nodeb_ = ip_nodeb_;			phy_->ip_nodeb_ = ip_nodeb_;			return (TCL_OK);		}		if (strcmp(argv[1], "rlc") == 0) {			tcl.resultf("%s", rlc_->name());

⌨️ 快捷键说明

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