📄 bcast.h
字号:
// bcast.h: interface for the BCAST class.
//Here I defined a simple route protole, only broacast the
//message to the adjacent nodes, no matter what the message it is
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_BCAST_H__DDF69B08_7B7E_4AB5_928D_67EDEAE55A8D__INCLUDED_)
#define AFX_BCAST_H__DDF69B08_7B7E_4AB5_928D_67EDEAE55A8D__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "omnetpp.h"
#include "costants.h"
#include "log.h"
//this class is used to collect statistics data
//during the simulation run
class PartialStat: public cObject
{
public:
PartialStat(double,double);
~PartialStat();
//partial sums
double latencySum;
double throughSum;
int samples;
};
//collect the statistics of the protocol
class Statistics : public cObject
{
public:
Statistics();
~Statistics();
//array to store the per-hop
//statistics
cArray hopsV;
int hopsSum;
int sentCtrlPkt;
int sentDataPkt;
int deliveredDataMsg;
int sendDataMsg;
//hopV upper bount
int maxHop;
void collect(cMessage*,double);
};
//class that store the pakets waitink for a
//to get to a destination
/*修改此类是为了存储需要路由层转发的数据 ,等同于MAC层的CBUFFER*/
class WaitingPkt : public cObject
{
public:
//address of the notde that the RREQ
//is searching a route for
int dest;
//self message that make the RREQ to be
//re-sended or make the message buffer to be flushed
cMessage* deleteEvent;
//counter of RREQ sent toward the same destination
int trial;
//counter of the pakets that are waiting
int pktNum;
int pktSize;
//reqId of the RREQ sent
int reqId;
WaitingPkt();
~WaitingPkt();
};
/* 类BCAST仅仅是将数据报进行打包转发,接受到的数据上传到应用层*/
class BCAST: public cSimpleModule
{
//Macro that contains the costructor,destructor
//and other Omnett++ stuff
Module_Class_Members(BCAST,cSimpleModule,0)
virtual ~BCAST();
private:
//send HELLO trigger
cMessage* helloEvent;
//seqence number of the mobile host
//used to prevent message loops
int sequenceNumber;
//routing table
cQueue routeTab;
//buffer for the pakets waiting
//for a route
cQueue pktBuffer;
//list of neighbours that are out of range for
//the node's tx range
cQueue blackList;
//cMessage* copyMessage(cMessage* );
cMessage* generateBCASTmsg(cMessage* msg);
/* 结构拷贝 */
cMessage* copyMessage(cMessage* msg);
//send to lower levels to broadcast to all the nb
void broadcast(cMessage *);
Statistics statistics;
public:
virtual void initialize();
virtual void handleMessage(cMessage *msg);
virtual void finish();
};
#endif // !defined(AFX_BCAST_H__DDF69B08_7B7E_4AB5_928D_67EDEAE55A8D__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -