MANET Simulator developing diary

     Framework of this simulator has already developed after 2 weeks' effort.

     The basic of the simulator is the "BaseDef.h" shown as follow:

#ifndef _BASE_DEF_H_
#define _BASE_DEF_H_
#include <cstdlib>

// --------------------------------------- A. Variables ------------------------------------------
// MN's transmission range.
const int MN_TR = 1;  // Variable parameter.

// SIR parameters.
const double SIR_ACTIVE_TIME = 100;

// Nodes' number.
const int MN_NUM = 1080;

// Node's velocity.
const double MN_VELOCITY = 10;

// ------------------------------------------ B. NS Running settings ----------------------------------------
// Simulator's speed ratio.
const unsigned int NS_SPEED_RATIO = 5;

// Simulator parameters.
const unsigned int NS_LOGICAL_LAST_TIME = 500;
const unsigned int NS_SIMUL_LAST_TIME =(int) (NS_LOGICAL_LAST_TIME/NS_SPEED_RATIO);
const unsigned int NS_TOLERATE_DELAY = 70;

// Topology parameters.
const double TOPO_MIN_X = 0.0;
const double TOPO_MIN_Y = 0.0;
const double TOPO_WIDTH = 600.0;
const double TOPO_HEIGHT = 600.0;

// Simulator's deviation parameters.
const double PI = 3.1415926;
const double SPACE_DEVIATION = 0.6;

// ------------------------------------------ C. NS LogFile recording switches ----------------------------------------
const bool IS_COUT_OPEN = true;
const bool IS_RUNLOG_OPEN = false;
const bool IS_FWLOG_OPEN = false;
const bool IS_LOCLOG_OPEN = false;
const bool IS_SIRLOG_OPEN = false;

// ---------------------------------------- D. Basic #defines ---------------------------------------------
// Basic operation.
#define _in
#define _out
#define SAFELY_DELETE_PTR( pX ) \
{ \
if ( NULL != pX )\
{ \
delete pX; \
pX = NULL; \
} \
}

#endif

// BaseDef.h :~

   From it, we see that in section A, we set 4 significant variable parameters, they are the base parameter of my MANETSimulator. In section B, there're several important settings about the NS(Network Simulator) running, e.g., the const UINT NS_SPEED_RATIO, it controls the speed ratio of the NS. At the beginning, I did not consider this speed ratio of NS, however, the original edition of MANETSimulator runs in the logical time slot, as you know, it is even slower than the real time. It is normal that I need 5 minuts or more to run every round of simulation. We can not tolerate the so slow effectiveness. So, the speed ratio NS_SPEED_RATIO is introduced at last, to control the speed of NS, and let NS runs in a fast logical time, at last, the consumption of running time is reduced much.

   But, if I use this speed ratio, I need adjust the value of MNode's velocity when I get the MN's velocity, as shown as follow:

double MNode::GetVelocity()
{
return m_dVelocity*NS_SPEED_RATIO;  // !! Adjust the velocity
}

   In section C, I utilize 4 parameters as the LogFiles' recording switches to contol the printing of trace data. It is convenient so much.

   And in the last section D, those are 3 basic macros of operating code, and they are so easy but practical.

Davy_H

2011-03-27

猜你喜欢

转载自blog.csdn.net/DavyHwang/article/details/7397738