资源简介
里面包含九种常用的移动模型代码分析,可以直接使用。是c++编写生成场景文件在ns2中运行。
代码片段和文件信息
/******************************************************************************
* File Name: torus.c
* Purpose: random waypoint model placed on a boundless torus
* Author: Jeff Boleng
* Date Created:
*
* Edited 12 July 2006 by Jon Petty:
* Changed seed code to rand((int)time(NULL) + (int)getpid())
*
* Copyright (C) 2004 Toilers Research Group -- Colorado School of Mines
*
* Please see COPYRIGHT.TXT and LICENSE.TXT for copyright and license
* details.
******************************************************************************/
#include
#include
#include
#include
#include
#define true 1
#define false 0
#define numberSamples 1000
int main(int argc char *argv[])
{
double pi = 2.0*asin(1.0);
double twoPi = 2.0*pi;
double maxX=0.0 maxY=0.0;
double endTime=0.0;
double speedMean=0.0 speedDelta=0.0;
double pauseMean=0.0 pauseDelta=0.0;
double travelMean=0.0 travelDelta=0.0;
int moving = false;
double speed = 0.0;
double direction = 0.0;
double travelTime = 0.0;
double pauseTime = 0.0;
double xLoc = 0.0;
double yLoc = 0.0;
double xOld = 0.0;
double yOld = 0.0;
double speedLow speedRange;
double pauseLow pauseRange;
double travelLow travelRange;
double interval;
double curtime = 0.0;
int wrap = false;
if (argc == 10)
{
maxX = atof(argv[1]);
maxY = atof(argv[2]);
endTime = atof(argv[3]);
speedMean = atof(argv[4]);
speedDelta = atof(argv[5]);
pauseMean = atof(argv[6]);
pauseDelta = atof(argv[7]);
travelMean = atof(argv[8]);
travelDelta = atof(argv[9]);
fprintf(stdout “#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n“);
fprintf(stdout “#\tmaxX = %9.2f\n“ maxX);
fprintf(stdout “#\tmaxY = %9.2f\n“ maxY);
fprintf(stdout “#\tendTime = %9.2f\n“ endTime);
fprintf(stdout “#\tspeedMean = %9.2f\n“ speedMean);
fprintf(stdout “#\tspeedDelta = %9.2f\n“ speedDelta);
fprintf(stdout “#\tpauseMean = %9.2f\n“ pauseMean);
fprintf(stdout “#\tpauseDelta = %9.2f\n“ pauseDelta);
fprintf(stdout “#\ttravelMean = %9.2f\n“ travelMean);
fprintf(stdout “#\ttravelDelta = %9.2f\n“ travelDelta);
fprintf(stdout “#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n“);
} else {
fprintf(stdout “Usage: torus \n“);
fprintf(stdout “ \n“);
fprintf(stdout “ \n“);
fprintf(stdout “ \n“);
return -1;
}
/* this is calculated to get at least numberSamples samples on the longest
path across the simulation area at maximum speed */
interval = ((sqrt(maxX*maxX + maxY*maxY))/(speedMean+speedDelta))/numberSamples;
srand((int)time(NULL) + (int)getpid());
speedLow = speedMean-speedDelta;
pauseLow = pauseMean-pauseDelta;
travelLow = travelMean-travelDelta;
speedRange = 2*speedDelta;
pauseRange = 2*pauseDelta;
travelRange = 2*
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 295366 2008-04-28 21:21 9种\A Survey of Mobility Models for Ad Hoc Network Research(分析了大量的移动模型).pdf
文件 240 2004-08-26 05:58 9种\boundless simulation area\makefile
文件 666 2004-07-10 06:11 9种\boundless simulation area\README
文件 5733 2006-07-13 02:11 9种\boundless simulation area\torus.c
文件 15376 2006-07-13 03:43 9种\boundless simulation area\torus2
文件 4812 2006-07-13 02:14 9种\boundless simulation area\torus2.c
文件 20084 2006-07-13 02:15 9种\col-line\col-line.c
文件 149 2004-07-10 06:12 9种\col-line\makefile
文件 377 2004-08-26 06:48 9种\col-line\README
文件 19717 2006-07-13 02:16 9种\col-perp\col-perp.c
文件 149 2004-07-12 09:50 9种\col-perp\makefile
文件 774 2004-08-26 06:43 9种\col-perp\README
文件 2436 2004-09-21 12:15 9种\COPYRIGHT.TXT
文件 4124 2006-07-13 03:13 9种\gaussmarkov\gauss.c
文件 117 2004-07-12 09:57 9种\gaussmarkov\makefile
文件 337 2004-08-26 06:49 9种\gaussmarkov\README
文件 15119 2004-08-26 05:42 9种\LICENSE.TXT
文件 181 2004-07-12 10:01 9种\probrandwalk\makefile
文件 5577 2006-07-13 02:20 9种\probrandwalk\probrandwalk.c
文件 562 2004-08-26 06:56 9种\probrandwalk\README
文件 147 2004-07-10 06:09 9种\randdir\makefile
文件 8650 2006-07-13 02:21 9种\randdir\randdir.c
文件 602 2004-08-26 07:00 9种\randdir\README
文件 149 2004-07-12 10:05 9种\randwalk\makefile
文件 11912 2006-07-13 02:22 9种\randwalk\randwalk.c
文件 573 2004-08-26 06:58 9种\randwalk\README
文件 134 2004-07-12 10:07 9种\randway\makefile
文件 6362 2006-07-13 02:23 9种\randway\mobgen.c
文件 286 2004-07-12 10:10 9种\randway\README
文件 3510 2004-09-21 12:22 9种\README
............此处省略18个文件信息
- 上一篇:动态规划—最短编辑问题—非常详细分析以及代码
- 下一篇:c++往年试卷杭电
评论
共有 条评论