Aloha.ned文件

//Aloha网络由主机组成,这些主机通过纯Aloha或时隙Aloha协议
network Aloha
{parameters://这里的参数都是aloha的int numHosts;  // number of hosts主机数double txRate @unit(bps);  // transmission rate传输速率double slotTime @unit(ms);  // zero means no slots (pure Aloha)时隙@display("bgi=background/terrain,s;bgb=1000,1000");//显示字符串的bgi标签指定整个网络的背景图像submodules:server: Server; //server继承自Server这个模块//host继承自Host,个数为numHosts,并给host的两个参数赋值//左边的txRate和slotTime是host.ned中的,右边的txRate和slotTime是parameters中定义的host[numHosts]: Host {txRate = txRate;slotTime = slotTime;}
}

Host.ned文件

//定义简单或复合模块
//ALOHAnet网络中的一台计算机。A computer in the ALOHAnet network.
simple Host
{parameters:@signal[state](type="long");@statistic[radioState](source="state";title="Radio state";enum="IDLE=0,TRANSMIT=1";record=vector);//enum表示信号的状态:IDLE空闲或TRANSMIT发送double txRate @unit(bps);          // transmission rate传输速率//用volatile定义的变量会在程序外被改变,每次都必须从内存中读取,而不能重复使用放在cache或寄存器中的备份volatile int pkLenBits @unit(b);   // packet length in bits数据包长度volatile double iaTime @unit(s);   // packet interarrival time包间隔时间double slotTime @unit(s);          // zero means no slots (pure Aloha)时隙,值为0表示不分槽double x @unit(m);                 // the x coordinate of the host主机的x坐标double y @unit(m);                 // the y coordinate of the host主机的y坐标double idleAnimationSpeed;         // used when there is no packet being transmitted当没有数据包被传输时使用double transmissionEdgeAnimationSpeed; // used when the propagation of a first or last bit is visible当第一位或最后一位的传播可见时使用double midTransmissionAnimationSpeed; // used during transmission在传输过程中使用bool controlAnimationSpeed = default(true);@display("i=device/pc_s");//显示图片
}

Host.h文件

class Host : public cSimpleModule//Host是从cSimpleModule派生来的
{private:// parameterssimtime_t radioDelay;//信号延时时间double txRate;//双精度//在运行时NED文件中声明的模块参数用cPar类表示,并调用cModule的par成员函数访问cPar *iaTime;//包时间,由模块定义的传输进来cPar *pkLenBits;//包长度simtime_t slotTime;bool isSlotted;//布尔,判断是否在时隙中// state variables, event pointers etccModule *server;//模块cMessage *endTxEvent;//消息,停止传输时间enum { IDLE = 0, TRANSMIT = 1 } state;//枚举simsignal_t stateSignal;//信号,当前状态int pkCounter;//记录数据包数量package counter// position on the canvas, unit is m在画布上的位置,单位是mdouble x, y;// speed of light in m/s光速(m/s)const double propagationSpeed = 299792458.0;// animation parameters动画参数const double ringMaxRadius = 2000; // in mconst double circlesMaxRadius = 1000; // in mdouble idleAnimationSpeed;double transmissionEdgeAnimationSpeed;double midtransmissionAnimationSpeed;//被mutable修饰,那么它就可以突破const的限制,在被const修饰的函数里面也能被修改// figures and animation state图形和动画状态cPacket *lastPacket = nullptr; // a copy of the last sent message, needed for animation动画所需的上次发送消息的副本mutable cRingFigure *transmissionRing = nullptr; // shows the last packet显示最后一个数据包mutable std::vector<cOvalFigure *> transmissionCircles; // ripples inside the packet ring包环内的波纹
//public部分声明构造函数和析构函数public:Host();virtual ~Host();
//protected部分声明虚函数protected:virtual void initialize() override;//初始化函数virtual void handleMessage(cMessage *msg) override;//处理函数virtual void refreshDisplay() const override;simtime_t getNextTransmissionTime();//获得下一次传输时间函数
};}; //namespace#endif

Host.cc文件

#include <algorithm>//提供迭代器的非成员模板函数
#include "Host.h"
namespace aloha {Define_Module(Host);Host::Host()//初始化调用,空
{endTxEvent = nullptr;
}Host::~Host()//结束时调用
{delete lastPacket;cancelAndDelete(endTxEvent);
}void Host::initialize()
{//registerSignal()方法以信号名称作为参数,并返回相应的simsignal_t值stateSignal = registerSignal("state");//从模块中取数据“state”server = getModuleByPath("server");//通过路径查找server模块的路径if (!server)//判断server是否存在throw cRuntimeError("server not found");//抛出一个错误中止程序//用par()函数从模块中读取初始化模块参数值txRate = par("txRate");iaTime = &par("iaTime");pkLenBits = &par("pkLenBits");slotTime = par("slotTime");isSlotted = slotTime > 0;WATCH(slotTime);//WATCH宏可以在Tkenv仿真界面中查看变量WATCH(isSlotted);endTxEvent = new cMessage("send/endTx");state = IDLE;//空闲emit(stateSignal, state);//当前信道的状态为空就可以发送消息,emit()接受一个自消息信号和数据pkCounter = 0;//包计数为0WATCH((int&)state);//(int &)y告诉编译器将y看成int对待(内存里的数据不做任何转换),(int*)是强制转换成整型指针WATCH(pkCounter);x = par("x").doubleValue();y = par("y").doubleValue();double serverX = server->par("x").doubleValue();double serverY = server->par("y").doubleValue();idleAnimationSpeed = par("idleAnimationSpeed");transmissionEdgeAnimationSpeed = par("transmissionEdgeAnimationSpeed");midtransmissionAnimationSpeed = par("midTransmissionAnimationSpeed");double dist = std::sqrt((x-serverX) * (x-serverX) + (y-serverY) * (y-serverY));//使用标准库中的函数或者对象都要用std来限定radioDelay = dist / propagationSpeed;//cDisplayString的setTagArg()方法可以用来更新文本//p位置,b形状大小,i图形,is图形大小,i2小图标,r显示半径,t显示文本,tt提示getDisplayString().setTagArg("p", 0, x);getDisplayString().setTagArg("p", 1, y);scheduleAt(getNextTransmissionTime(), endTxEvent);
}//信息处理函数
void Host::handleMessage(cMessage *msg)
{ASSERT(msg == endTxEvent);//ASSERT判断msg是否为endTxEvent,声明msg就是endTxEvent//画布由CcVasueC++类表示。可以使用cModule的getCanvas()方法访问模块的默认画布。一个顶层子模块可以通过下面的一行获得网络画布,在画布上设置此节点,使用setAnimationSpeed方法显示//使用画布指针,可以检查它包含的配置文件、添加新配置文件、操作现有配置文件等。getParentModule()->getCanvas()->setAnimationSpeed(transmissionEdgeAnimationSpeed, this);if (state == IDLE) {//如果信道状态为空闲,产生一个分包,设置该分包的大小,计算发送该分包所需的时间,用sendDirect()函数发送该分组到server模块//再用scheduleAt()调度下一个事件endTxEvent,发送时间为当前仿真时间+传输持续时间// generate packet and schedule timer when it ends在数据包结束时生成数据包并安排计时器char pkname[40];sprintf(pkname, "pk-%d-#%d", getId(), pkCounter++);//节点ID和包的数量EV << "generating packet " << pkname << endl;state = TRANSMIT;//改变state状态为TRANSMITemit(stateSignal, state);//发出信道忙的信息//设置包信息cPacket *pk = new cPacket(pkname);//产生pk分包pk->setBitLength(pkLenBits->intValue());//包长度simtime_t duration = pk->getBitLength() / txRate;//包间隔时间=长度/传输速率//sendDirect实现了无线信道发送sendDirect(pk, radioDelay, duration, server->gate("in"));//传输包pk通过延时radioDelay需要发这么长时间duration到sever模块的输入门inscheduleAt(simTime()+duration, endTxEvent);//自消息表示消息发送结束// let visualization code know about the new packet让可视化代码知道新数据包if (transmissionRing != nullptr) {delete lastPacket;lastPacket = pk->dup();}}//如果当前处于繁忙状态,那么一旦接收到endTxEvent消息,那么表明传输结束,此时信道空闲,那么就调度下一个事件else if (state == TRANSMIT) {// endTxEvent indicates end of transmission,endTxEvent表示传输结束state = IDLE;emit(stateSignal, state);// schedule next sending在下一次传输的时候发送一个自消息scheduleAt(getNextTransmissionTime(), endTxEvent);}else {throw cRuntimeError("invalid state");}
}//获取下次传输时间函数
simtime_t Host::getNextTransmissionTime()
{//下一次传输的时间t为当前仿真时间+分组到达间隔时间simtime_t t = simTime() + iaTime->doubleValue();//如果是纯aloha,那么返回t;如果是时隙aloha,那么返回下一个时隙的起始时刻if (!isSlotted)//如果时隙为0,直接返回treturn t;else//如果不为0加上时隙时间// align time of next transmission to a slot boundaryreturn slotTime * ceil(t/slotTime);//ceil为向上舍入函数
}void Host::refreshDisplay() const
{cCanvas *canvas = getParentModule()->getCanvas();const int numCircles = 20;const double circleLineWidth = 10;// create figures on our first invocation在第一次调用时创建图形,如果没有传输波形图,就创建一个圆环内部填色,创建20个圆环用边框填色if (!transmissionRing) {auto color = cFigure::GOOD_DARK_COLORS[getId() % cFigure::NUM_GOOD_DARK_COLORS];//除了公共的red,green,blue成员和一个三参数构造函数以方便初始化,struct还具有基于字符串的构造函数和str()函数。//string表单接受各种符号:HTML颜色(#rrggbb)、类似符号中的HSB颜色(@hhssbb)和英语颜色名称(更准确地说,SVG和X11颜色名称)。但是,不需要直接使用颜色。//基本颜色(黑色、白色、灰色、红色、绿色、蓝色、黄色、青色、洋红)以及精心选择的深色和浅色集合,适用于例如图表绘制,在GOOD_dark_colors[]和GOOD_light colors[]数组中,//为方便起见,每种颜色的数量以NUM_GOOD_DARK_colors和NUM_GOOD_LIGHT_colors常量表示)。transmissionRing = new cRingFigure(("Host" + std::to_string(getIndex()) + "Ring").c_str());transmissionRing->setOutlined(false);//图形标志transmissionRing->setFillColor(color);//填充颜色transmissionRing->setFillOpacity(0.25);//不透明度transmissionRing->setFilled(true);//是否填充transmissionRing->setVisible(false);//可见性标志transmissionRing->setZIndex(-1);//Z索引canvas->addFigure(transmissionRing);for (int i = 0; i < numCircles; ++i) {auto circle = new cOvalFigure(("Host" + std::to_string(getIndex()) + "Circle" + std::to_string(i)).c_str());circle->setFilled(false);circle->setLineColor(color);circle->setLineOpacity(0.75);circle->setLineWidth(circleLineWidth);circle->setZoomLineWidth(true);circle->setVisible(false);circle->setZIndex(-0.5);transmissionCircles.push_back(circle);//函数将一个新的元素加到vector的最后面,位置为当前最后一个元素的下一个元素canvas->addFigure(circle);}}if (lastPacket) {// update transmission ring and circles更新传动环和传动环if (transmissionRing->getAssociatedObject() != lastPacket) {transmissionRing->setAssociatedObject(lastPacket);for (auto c : transmissionCircles)c->setAssociatedObject(lastPacket);}simtime_t now = simTime();simtime_t frontTravelTime = now - lastPacket->getSendingTime();//前行程时间=当前时间-返回发送/计划消息的时间simtime_t backTravelTime = now - (lastPacket->getSendingTime() + lastPacket->getDuration());//后行程时间=当前时间-(返回发送/计划消息的时间+返回数据包发送后的传输持续时间)// conversion from time to distance in m using speed使用速度从时间到距离的转换(单位:m)//.dbl()转换为双精度double frontRadius = std::min(ringMaxRadius, frontTravelTime.dbl() * propagationSpeed);//前半径=min(环的最大半径,时间*速度)double backRadius = backTravelTime.dbl() * propagationSpeed;//后半径=时间*速度double circleRadiusIncrement = circlesMaxRadius / numCircles;//圆半径增量=圆最大半径/圆圈数量// update transmission ring geometry and visibility/opacity更新传输环几何结构和可见性/不透明度double opacity = 1.0;//如果后半径大于环最大半径if (backRadius > ringMaxRadius) {transmissionRing->setVisible(false);transmissionRing->setAssociatedObject(nullptr);}else {transmissionRing->setVisible(true);transmissionRing->setBounds(cFigure::Rectangle(x - frontRadius, y - frontRadius, 2*frontRadius, 2*frontRadius));transmissionRing->setInnerRadius(std::max(0.0, std::min(ringMaxRadius, backRadius)));if (backRadius > 0)opacity = std::max(0.0, 1.0 - backRadius / circlesMaxRadius);}transmissionRing->setLineOpacity(opacity);//设置轮廓参数transmissionRing->setFillOpacity(opacity/5);//设置填充参数// update transmission circles geometry and visibility/opacity更新传输圆的几何图形和可见性/不透明度double radius0 = std::fmod(frontTravelTime.dbl() * propagationSpeed, circleRadiusIncrement);//返回x/y的浮点余数;如果需要,将进行单位转换for (int i = 0; i < (int)transmissionCircles.size(); ++i) {//size()是getVectorSize()的别名,size()成员函数返回最大索引加一。double circleRadius = std::min(ringMaxRadius, radius0 + i * circleRadiusIncrement);if (circleRadius < frontRadius - circleRadiusIncrement/2 && circleRadius > backRadius + circleLineWidth/2) {transmissionCircles[i]->setVisible(true);transmissionCircles[i]->setBounds(cFigure::Rectangle(x - circleRadius, y - circleRadius, 2*circleRadius, 2*circleRadius));transmissionCircles[i]->setLineOpacity(std::max(0.0, 0.2 - 0.2 * (circleRadius / circlesMaxRadius)));}elsetransmissionCircles[i]->setVisible(false);}// compute animation speeddouble animSpeed = idleAnimationSpeed;if ((frontRadius >= 0 && frontRadius < circlesMaxRadius) || (backRadius >= 0 && backRadius < circlesMaxRadius))animSpeed = transmissionEdgeAnimationSpeed;if (frontRadius > circlesMaxRadius && backRadius < 0)animSpeed = midtransmissionAnimationSpeed;canvas->setAnimationSpeed(animSpeed, this);}else {// hide transmission rings, update animation speed隐藏传输环,更新动画速度if (transmissionRing->getAssociatedObject() != nullptr) {transmissionRing->setVisible(false);transmissionRing->setAssociatedObject(nullptr);for (auto c : transmissionCircles) {c->setVisible(false);c->setAssociatedObject(nullptr);}canvas->setAnimationSpeed(idleAnimationSpeed, this);}}// update host appearance (color and text)//更新主机外观(颜色和文本)getDisplayString().setTagArg("t", 2, "#808000");//修改节点颜色为黄色if (state == IDLE) {getDisplayString().setTagArg("i", 1, "");getDisplayString().setTagArg("t", 0, "");}else if (state == TRANSMIT) {getDisplayString().setTagArg("i", 1, "yellow");getDisplayString().setTagArg("t", 0, "TRANSMIT");}
}}; //namespace

Server.ned文件

//ALOHAnet网络中的中央计算机。
// The central computer in the ALOHAnet network.
//
simple Server
{parameters://信号相关定义,加@指属性配置@display("i=device/antennatower_l");//显示字符串指定服务器的图标//每一个新帧到达服务器时,其数值增加,如果最后信道变得空闲,那么值变为0@signal[receiveBegin](type="long");  // increases with each new frame arriving to the server and drops to 0 if the channel becomes finally idle//用于成功接收数据帧:1表示接收的开始,0表示接收的结束@signal[receive](type="long");  // for successful receptions (non-collisions): 1 at the start of the reception, 0 at the end of the reception//碰撞开始时冲突帧数量@signal[collision](type="long"); // the number of collided frames at the beginning of the collision period//碰撞结束时最后的碰撞帧长度@signal[collisionLength](type="simtime_t");  // the length of the last collision period at the end of the collision period@signal[channelState](type="long");double x @unit(m); // the x coordinate of the serverdouble y @unit(m); // the y coordinate of the serverdouble animationHoldTimeOnCollision @unit(s) = default(0s); // in animation time//@statistic属性的键值有:source(数据输入)record(包含一系列的记录模式,记录模式定义如何记录source)title(名称)unit(单位)interpolationmode(定于如何插入信号值)enum(定义各种整型信号值的符号名称)@statistic[serverChannelState](source="channelState";title="Channel state";enum="IDLE=0,TRANSMISSION=1,COLLISION=2";record=vector);@statistic[receiveBegin](source="receiveBegin"; record=vector?; interpolationmode=sample-hold; title="receive begin");@statistic[channelUtilization](source="timeavg(receive)"; record=last; interpolationmode=linear; title="channel utilization");@statistic[collisionMultiplicity](source=collision; record=vector?,histogram; title="collision multiplicity");@statistic[collisionLength](record=vector?,histogram,mean,sum,max; title="collision length");@statistic[receivedFrames](source="sum(receive)"; record=last; title="received frames");@statistic[collidedFrames](source="sum(collision)"; record=last; title="collided frames");gates:input in @directIn;//声明用于接受通过sendDirect()函数发送的消息的门
}

Server.h文件

#ifndef __ALOHA_SERVER_H_
#define __ALOHA_SERVER_H_#include <omnetpp.h>using namespace omnetpp;namespace aloha {/*** Aloha server; see NED file for more info.*/
class Server : public cSimpleModule
{private:// state variables, event pointersbool channelBusy;cMessage *endRxEvent;long currentCollisionNumFrames;long receiveCounter;simtime_t recvStartTime;enum { IDLE = 0, TRANSMISSION = 1, COLLISION = 2 };simsignal_t channelStateSignal;// statisticssimsignal_t receiveBeginSignal;simsignal_t receiveSignal;simsignal_t collisionLengthSignal;simsignal_t collisionSignal;public:Server();virtual ~Server();protected:virtual void initialize() override;virtual void handleMessage(cMessage *msg) override;virtual void finish() override;virtual void refreshDisplay() const override;
};}; //namespace#endif

Server.cc文件

//server模块用于检查碰撞和计算统计量
//#include "Server.h"namespace aloha {Define_Module(Server);Server::Server()
{endRxEvent = nullptr;
}Server::~Server()
{cancelAndDelete(endRxEvent);
}void Server::initialize()
{//初始化生成endTxEvent消息,设置信道状态为空闲,设置输入门在接收的起始时刻接收消息,当前的接收的帧为0,当前的冲突帧的数量为0//registerSignal()方法以信号名称作为参数,并返回相应的simsignal_t值channelStateSignal = registerSignal("channelState");endRxEvent = new cMessage("end-reception");channelBusy = false;emit(channelStateSignal, IDLE);gate("in")->setDeliverOnReceptionStart(true);currentCollisionNumFrames = 0;receiveCounter = 0;WATCH(currentCollisionNumFrames);//用registerSignal()来注册信号receiveBeginSignal = registerSignal("receiveBegin");receiveSignal = registerSignal("receive");collisionSignal = registerSignal("collision");collisionLengthSignal = registerSignal("collisionLength");//用emit()来发射信号emit(receiveSignal, 0L);emit(receiveBeginSignal, 0L);//设置坐标getDisplayString().setTagArg("p", 0, par("x").doubleValue());getDisplayString().setTagArg("p", 1, par("y").doubleValue());
}void Server::handleMessage(cMessage *msg)
{//如果接收到消息为endRxEvent,则表示server已经接收来自Host的消息,设置信道为IDLE,即空闲状态;if (msg == endRxEvent) {EV << "reception finished\n";channelBusy = false;emit(channelStateSignal, IDLE);// update statistics//更新统计数据,即从接受开始到接收结束需要花费的时间simtime_t dt = simTime() - recvStartTime;//计算接收的时间//判断当前是否有冲突,如果当前的冲突帧数量为0,那么表示不同时间戳的recvStartTime参数封装cTimestampedValue类的存储到变量tmp中,然后用emit发射出去,接收完成后再发射receiveSignalif (currentCollisionNumFrames == 0) {// start of reception at recvStartTime//若无冲突,则设定时间戳为接受开始时间,并在接收信道设定接收时间起止//要发出具有不同时间戳的值,需要填充包含(timestamp,value)对的对象,并使用emit(simsignal_t,cObject*)方法发出。//这个类称为cTimestampedValue,它只是有两个名为time和value的公共数据成员,类型为simtime_t和double。//在recvStartTime时刻开始接收,cTimestampedValue类的tmp变量表示不同时间戳的recvStartTime参数,值为1,为long类型cTimestampedValue tmp(recvStartTime, 1l);emit(receiveSignal, &tmp);// end of reception nowemit(receiveSignal, 0);}//如果recvStartTime时刻帧冲突,那么把带有不同时间戳的当前冲突帧数量封装到cTimestampedValue类的存储到变量tmp中,然后用emit发射出去,并发射当前冲突帧的数量else {//若有冲突,则设定时间戳为冲突信号个数,并在接受信道设定接受起止时间,// start of collision at recvStartTimecTimestampedValue tmp(recvStartTime, currentCollisionNumFrames);emit(collisionSignal, &tmp);emit(collisionLengthSignal, dt);}//给各参数清零,重新设置冲突帧数量和接收帧数量,并发送接收开始信号currentCollisionNumFrames = 0;receiveCounter = 0;emit(receiveBeginSignal, receiveCounter);}//如果接收信号不是结束信号,即此时接收没有完成,将此时的消息强制转换为分组的指针,并声明接受分组开始了,接收完成的时间为当前仿真时间+传输分组的持续时间,然后发射开始接收信号else {cPacket *pkt = check_and_cast<cPacket *>(msg);//强制转换ASSERT(pkt->isReceptionStart());//判断信号是否开始接受simtime_t endReceptionTime = simTime() + pkt->getDuration();//计算结束接收时间emit(receiveBeginSignal, ++receiveCounter);//设定接收开始信道//判断信道是否忙,若信道空闲,表示此时能够发送消息,那么Host开始发送消息,信道处于繁忙状态,server开始接收,此时在endReceptionTime时刻调度endRxEvent事件if (!channelBusy) {//设定开始接收时间为当前时间,信道为忙EV << "started receiving\n";recvStartTime = simTime();channelBusy = true;//设定信道状态为TRANSIMISSION,传输状态emit(channelStateSignal, TRANSMISSION);//发送结束接收信号的时间scheduleAt(endReceptionTime, endRxEvent);}//若信道忙,则发生冲突,如果当前的冲撞数量帧为0,那么会有两个分组发生冲撞,否则是当前冲撞总数+1else {EV << "another frame arrived while receiving -- collision!\n";emit(channelStateSignal, COLLISION);//设定信道状态为COLLISION,冲突状态//计算冲突包数量,此处包含了当前正在传输的包和冲突包,故初值为2.if (currentCollisionNumFrames == 0)currentCollisionNumFrames = 2;elsecurrentCollisionNumFrames++;//若终止传输时间大于endRxEvent的时间,则取消endRxEvent,重新设置发送时间//如果分组接收完成时间大于调度endRxEvent的仿真时间,那么取消调度的endRxEvent事件,重新再endReceptionTime时刻调度endRxEvent事件if (endReceptionTime > endRxEvent->getArrivalTime()) {cancelEvent(endRxEvent);scheduleAt(endReceptionTime, endRxEvent);}// update network graphics更新此时的server图标if (hasGUI()) {char buf[32];sprintf(buf, "Collision! (%ld frames)", currentCollisionNumFrames);bubble(buf);getParentModule()->getCanvas()->holdSimulationFor(par("animationHoldTimeOnCollision"));}}//信道繁忙,删除分组channelBusy = true;delete pkt;}
}void Server::refreshDisplay() const
{//信道空闲,在server图标右上方添加"status/off"图标,文本为空if (!channelBusy) {getDisplayString().setTagArg("i2", 0, "status/off");getDisplayString().setTagArg("t", 0, "");}//冲撞为0,更新server图标,图标变为黄色,文本为"RECEIVE",文本颜色为橄榄绿else if (currentCollisionNumFrames == 0) {getDisplayString().setTagArg("i2", 0, "status/yellow");getDisplayString().setTagArg("t", 0, "RECEIVE");getDisplayString().setTagArg("t", 2, "#808000");}//其他时间,设置server图标为红色。文本为"COLLISION"栗色else {getDisplayString().setTagArg("i2", 0, "status/red");getDisplayString().setTagArg("t", 0, "COLLISION");getDisplayString().setTagArg("t", 2, "#800000");}
}//finish()用于记录统计量,此处记录duration
void Server::finish()
{EV << "duration: " << simTime() << endl;recordScalar("duration", simTime());//记录标量,生成在omnetpp.sca中
}}; //namespace

omnetpp.ini文件

[General]
network = Aloha
#debug-on-errors = true
#record-eventlog = true#对aloha.ned中的参数赋值
Aloha.numHosts = 20
Aloha.slotTime = 0s    # no slots
Aloha.txRate = 9.6kbps
Aloha.host[*].pkLenBits = 952b
#=119 bytes, so that (with +1 byte guard) slotTime is a nice round number/=119字节,因此(带+1字节保护)slotTime是一个很好的整数
#host后用*号表示所有的Host模块
#exponetial(a)从平均值为a的指数分布中得出的数字**.x = uniform(0m, 1000m)
**.y = uniform(0m, 1000m)
**.animationHoldTimeOnCollision = 0s
**.idleAnimationSpeed = 1
**.transmissionEdgeAnimationSpeed = 1e-6
**.midTransmissionAnimationSpeed = 1e-1[Config PureAloha1]
description = "pure Aloha, overloaded"
# too frequent transmissions result in high collision rate and low channel utilization
#过于频繁的传输会导致高冲突率和低信道利用率
Aloha.host[*].iaTime = exponential(2s)[Config PureAloha2]
description = "pure Aloha, optimal load"
# near optimal load, channel utilization is near theoretical maximum 1/2e
#接近最佳负载时,信道利用率接近理论最大值1/2e
Aloha.host[*].iaTime = exponential(6s)[Config PureAloha3]
description = "pure Aloha, low traffic"
# very low traffic results in channel being idle most of the time
#非常低的流量导致信道大部分时间处于空闲状态
Aloha.host[*].iaTime = exponential(30s)#分组生成频率函数中的信道利用率
[Config PureAlohaExperiment]
description = "Channel utilization in the function of packet generation frequency"
repeat = 2
sim-time-limit = 90min
#**.vector-recording = false
Aloha.numHosts = ${numHosts=10,15,20}
Aloha.host[*].iaTime = exponential(${iaMean=1,2,3,4,5..9 step 2}s)[Config SlottedAloha1]
description = "slotted Aloha, overloaded"
# slotTime = pkLen/txRate = 960/9600 = 0.1s
Aloha.slotTime = 100ms
# too frequent transmissions result in high collision rate and low channel utilization
Aloha.host[*].iaTime = exponential(0.5s)[Config SlottedAloha2]
description = "slotted Aloha, optimal load"
# slotTime = pkLen/txRate = 960/9600 = 0.1s
Aloha.slotTime = 100ms
# near optimal load, channel utilization is near theoretical maximum 1/e
Aloha.host[*].iaTime = exponential(2s)[Config SlottedAloha3]
description = "slotted Aloha, low traffic"
# slotTime = pkLen/txRate = 960/9600 = 0.1s
Aloha.slotTime = 100ms
# very low traffic results in channel being idle most of the time
Aloha.host[*].iaTime = exponential(20s)

omnet++Aloha案例解析相关推荐

  1. 《用于物联网的Arduino项目开发:实用案例解析》—— 3.4 小结

    本节书摘来自华章出版社<用于物联网的Arduino项目开发:实用案例解析>一 书中的第3章,第3.4节,作者[美]安德尔·杰韦德(Adeel Javed),更多章节内容可以访问云栖社区&q ...

  2. 【许晓笛】 EOS智能合约案例解析(1)

    详解 EOS 智能合约的 hpp 文件 为了帮助大家熟悉 EOS 智能合约,EOS 官方提供了一个代币(资产)智能合约 Demo -- eosio.token.eosio.token 智能合约目前还不 ...

  3. 福利继续:赠书《Spring Cloud微服务-全栈技术与案例解析》

    <Spring Cloud微服务-全栈技术与案例解析> 在互联网时代,互联网产品的最大特点就是需要快速发布新功能,支持高并发和大数据.传统的架构已经慢慢不能支撑互联网业务的发展,这时候微服 ...

  4. 转盘抽奖php,使用PHP实现转盘抽奖算法案例解析

    这次给大家带来使用PHP实现转盘抽奖算法案例解析,使用PHP实现转盘抽奖算法的注意事项有哪些,下面就是实战案例,一起来看一下. 流程: 1.拼装奖项数组 2.计算概率 3.返回中奖情况 代码如下: 中 ...

  5. Database之SQL:SQL之over partition by开窗函数的简介、使用方法(求各班级内各自排名/求各班级内第一名/求各班级内分数递增和等案例解析)之详细攻略

    Database之SQL:SQL之over partition by开窗函数的简介.使用方法(求各班级内各自排名/求各班级内第一名/求各班级内分数递增和等案例解析)之详细攻略 目录 over part ...

  6. auto-sklearn案例解析二

    度量函数-metrics auto-sklearn的度量函数是对sklearn度量函数的封装,我们即可以使用autosklearn已经封装好的metrics函数,也可以使用autosklearn的me ...

  7. python查找字符串关键词_Python字符串查找基本操作案例解析

    本篇文章小编给大家分享一下Python字符串查找基本操作案例解析,文章介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看. 字符串查找基本操作主要分为三个关键词:fi ...

  8. 刘子佼 mysql 下载_MySQL数据管理之备份恢复案例解析 23讲 Mysql备份恢复实战 视频教程...

    课程名称:MySQL数据管理之备份恢复案例解析 23讲 Mysql备份恢复实战课程简介: 课程独家解析MySQL 5.6最新特性,课程讲师刘子佼讲课风格幽默,善于与人沟通,善于组建和协调团队攻克技术难 ...

  9. OOAD实践之路——真实案例解析OO理论与实践(二、第一项任务:特性列表)

    查看本系列全部文章: <OOA&D实践之路--真实案例解析OO理论与实践>索引贴 第一份说明       当这个项目开始时,我们得到的关于我们要做的系统的唯一说明是一页Word文档 ...

最新文章

  1. Ubuntu 14.04使用命令行安装VirtualBox
  2. 这项技术是谷歌AI的New Sexy:利于隐私、节能环保,目前最大挑战是布道阐释
  3. python一个图画两条曲线_用python建立两个Y轴的XY曲线图方法
  4. Linux内存管理之一 分段与分页
  5. Spring Boot中@ConfigurationProperties与@PropertySource的基本使用(读取指定的properties文件)
  6. 自学python单片机编程-作为一个硬件工程师,你该学学Python了
  7. Vue.js 与 Webpack externals 的使用
  8. spring cloud互联网分布式微服务云平台规划分析--spring cloud服务监控中心
  9. 初学者学习数据库的三个方向
  10. 用数字万用表测量电阻-2/4/6线制测量
  11. 垃圾分类-特别是有害垃圾
  12. 视频转成gif动图怎么操作?仅需三步在线完成视频转gif
  13. 建筑群子系统的设计步骤
  14. 本地化 A NOTE 桌面便签软件 ---最佳开源软件之一
  15. GDPR(欧盟通用数据保护条例)基础知识
  16. ROS TF 常用接口函数
  17. 考研数学:秩为1的矩阵的特征值分析
  18. Java语言基础详细讲解
  19. 基金操作术语与收益术语
  20. 机器学习之Python使用KNN算法进行电影类型预测

热门文章

  1. C语言编译能否被七整除,C++编程判断一个整数能否被3、5、7整除的几种方法
  2. 大数据技术原理与应用 概念、存储、处理、分析和应用(林子雨)——第八章 Hadoop再探讨
  3. Codeblocks 17.12安装教程
  4. matlab 高速公路,基于Matlab的高速公路路面状况分类评价
  5. 基于Java毕业设计学生选拔系统源码+系统+mysql+lw文档+部署软件
  6. 如何从excel的多行中随机选出n行
  7. @font-face用法超详细讲解
  8. 视频格式转化(将MP4格式转换成ogg格式)
  9. CATIA批量导入导出数据到EXCEL
  10. CSS渐变字体、镂空字体、input框提示信息颜色、给图片加上内阴影、3/4圆