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

📄 topo_gen.hh

📁 topo_gen基于NS2的场景自动生成软件源代码
💻 HH
字号:
//// topo_gen.hh   : Emstar topology generation include file// author           : Fabio Silva//// Copyright (C) 2000-2005 by the University of Southern California// $Id: topo_gen.hh,v 1.2 2005/05/10 04:12:06 fstann Exp $//// This program is free software; you can redistribute it and/or// modify it under the terms of the GNU General Public License,// version 2, as published by the Free Software Foundation.//// This program is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the// GNU General Public License for more details.//// You should have received a copy of the GNU General Public License along// with this program; if not, write to the Free Software Foundation, Inc.,// 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.//// #include <iostream.h>#include <iostream>#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <string.h>#include <math.h>#include <sys/time.h>#include <netinet/in.h>#include <list>#include "tools.hh"using std::list;// User Defined Constants#define CUSTOM_FILTER_NAME "rrd"#define COMMUNICATION_RANGE 11.5#define EXPERIMENT_RUN_MINUTES 31#define EXPERIMENT_RUN_SECONDS 0#define SIM_RADIO_MODEL "norm_noise"#define SIM_RADIO_POWER 2// User Defined Locations of EmSim runtab files#define TPP_DEFAULT_TAB "../link/diffusion/tppdefaulttab.run"#define TPP_SOURCE_TAB "../link/diffusion/tppsourcetab.run"#define TPP_SINK_TAB "../link/diffusion/tppsinktab.run"#define TPP_CUSTOM_DEFAULT_TAB "../link/diffusion/tppcustomdefaulttab.run"#define TPP_CUSTOM_SOURCE_TAB "../link/diffusion/tppcustomsourcetab.run"#define TPP_CUSTOM_SINK_TAB "../link/diffusion/tppcustomsinktab.run"#define OPP_DEFAULT_TAB "../link/diffusion/oppdefaulttab.run"#define OPP_SOURCE_TAB "../link/diffusion/oppsourcetab.run"#define OPP_SINK_TAB "../link/diffusion/oppsinktab.run"#define OPP_CUSTOM_DEFAULT_TAB "../link/diffusion/oppcustomdefaulttab.run"#define OPP_CUSTOM_SOURCE_TAB "../link/diffusion/oppcustomsourcetab.run"#define OPP_CUSTOM_SINK_TAB "../link/diffusion/oppcustomsinktab.run"#define PUSH_DEFAULT_TAB "../link/diffusion/pushdefaulttab.run"#define PUSH_SOURCE_TAB "../link/diffusion/pushsourcetab.run"#define PUSH_SINK_TAB "../link/diffusion/pushsinktab.run"#define PUSH_CUSTOM_DEFAULT_TAB "../link/diffusion/pushcustomdefaulttab.run"#define PUSH_CUSTOM_SOURCE_TAB "../link/diffusion/pushcustomsourcetab.run"#define PUSH_CUSTOM_SINK_TAB "../link/diffusion/pushcustomsinktab.run"// Define Modes#define PUSH 1#define OPP  2#define TPP  3// Define Positions#define RANDOM 0#define DIAGONAL 1#define CLUSTERED_SINKS 2#define CLUSTERED_SOURCES 4// Configuration constraints#define MIN_X 1#define MAX_X 1000#define MIN_Y 1#define MAX_Y 1000#define MIN_NODES 1#define MAX_NODES 100#define MIN_MODE 1#define MAX_MODE 3#define MIN_POS 1#define MAX_POS 5#define MIN_SINKS MIN_NODES#define MAX_SINKS MAX_NODES - 1#define MIN_SOURCES MIN_NODES#define MAX_SOURCES MAX_NODES - 1#define MIN_SEND_RATE 1#define MAX_SEND_RATE 500class NodeInfo{public:  int node_id_;  double node_x_;  double node_y_;  NodeInfo(int node_id, double node_x, double node_y) :    node_id_(node_id), node_x_(node_x), node_y_(node_y)  {  };};typedef list<NodeInfo *> NodeList;typedef list<int> TopoList;class CostInfo{public:  int node_id_;  int cost_;  CostInfo(int node_id, int cost) : node_id_(node_id), cost_(cost) {};};typedef list<CostInfo *> CostList;class TopoGen{public:  TopoGen(int argc, char **argv);  void doIt();private:  long seed_;  int mode_;  int position_;  int user_position_;  int size_x_;  int size_y_;  int number_of_sinks_;  int number_of_sources_;  int number_of_nodes_;  int number_of_runs_;  int send_rate_;  float send_lambda_;  bool use_custom_filter_;  bool equalize_events_;  bool gen_topo_files_;  bool gen_ns2_files_;  bool test_only_;  bool filenames_with_send_rate_;  char *output_filename_;  // Particular locations in the region  double a_x_;  double a_y_;  double b_x_;  double b_y_;  double a_min_x_;  double a_max_x_;  double a_min_y_;  double a_max_y_;  double b_min_x_;  double b_max_x_;  double b_min_y_;  double b_max_y_;  NodeList nodes_;  NodeList sinks_;  NodeList sources_;  NodeList topology_;  TopoList connected_;  // Node placement functions  void createNodes();  bool pickRandomSinks();  bool pickRandomSources();  bool pickRandomNodes(NodeList *destination_list, int num_nodes);  bool pickClusteredSinks(double x, double y);  bool pickClusteredSources(double x, double y);  bool pickClusteredNodes(NodeList *destination_list, int num_nodes,			  double x, double y);  // Parameter configuration  void parseCommandLine(int argc, char **argv);  void usage(char *s);  void initialize();  // TopoGen configuration generation functions  bool isConnected(TopoList *topology_list, int node_id);  void checkConnected(int node_id);  bool checkConfig();  void statsConfig();  int statsNode(int32_t node_id);  void printConfig();  void printTrafficFile();  // Node state management  int findClosest(double x, double y);  NodeInfo *findNode(NodeList *nodes, int id);  bool deleteNode(int id);};

⌨️ 快捷键说明

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