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

📄 layerinfo.h

📁 模拟器提供了一个简单易用的平台
💻 H
字号:
/************************************************** *  File: layerinfo.h  Author: Suman Banerjee <suman@cs.umd.edu>  Date: July 31, 2001  Terms: GPL  NICE implementation in myns  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. * **************************************************/#ifndef _LAYERINFO_H_#define _LAYERINFO_H_#include <linked-list.h>#include <agent.h>#include <timer.h>#include <constants.h>#include "app-packet.h"extern NamedConstant const_join_query_timeout;extern NamedConstant const_cluster_refresh_msg_timeout;extern NamedConstant const_cluster_refresh_check_timeout;extern NamedConstant const_higher_layer_ping_response_timeout;extern NamedConstant const_higher_layer_ping_interval_timeout;#define CONST_JOIN_QUERY_TIMEOUT (const_join_query_timeout.getval().u.d)#define CONST_CLUSTER_REFRESH_MSG_TIMEOUT (const_cluster_refresh_msg_timeout.getval().u.d)#define CONST_CLUSTER_REFRESH_CHECK_TIMEOUT (const_cluster_refresh_check_timeout.getval().u.d)#define CONST_HIGHER_LAYER_PING_RESPONSE_TIMEOUT (const_higher_layer_ping_response_timeout.getval().u.d)#define CONST_HIGHER_LAYER_PING_INTERVAL_TIMEOUT (const_higher_layer_ping_interval_timeout.getval().u.d)// #define CONST_JOIN_QUERY_TIMEOUT 2.0// #define CONST_CLUSTER_REFRESH_MSG_TIMEOUT 2.0// #define CONST_CLUSTER_REFRESH_CHECK_TIMEOUT 4.0// #define CONST_HIGHER_LAYER_PING_RESPONSE_TIMEOUT 2.0// #define CONST_HIGHER_LAYER_PING_INTERVAL_TIMEOUT 10.0#define MAX_LAYERS	10class LayerInfo;class ClusterRefreshMsgTimer : public Timer {public :  Agent *a;  LayerInfo *l;  ClusterRefreshMsgTimer (void) : Timer () { a = NULL; l = NULL;};  void EventHandler (void);};class ClusterRefreshCheckTimer : public Timer {public :  Agent *a;  LayerInfo *l;  ClusterRefreshCheckTimer (void) : Timer () { a = NULL; l = NULL;};  void EventHandler (void);};struct AgentDistInfo {  AgentInfo ag;  double dist;};class LayerAgentInfo {public :  AgentInfo ag;  LayerInfo * lower_layer;  double dist; /* Dist of this agent from me */  bool refresh;  int agent_dist_arr_count; /* Number of members in the array below */  AgentDistInfo * agent_dist_arr;  bool valid_tmp; /* A temp valid bit used to test validity of members */  LayerAgentInfo (int Aid, int Nid) {    ag.agent_id = Aid;    ag.node_id = Nid;    lower_layer = NULL;    dist = -1.0;    agent_dist_arr_count = 0;    agent_dist_arr = NULL;    refresh = true;  };  ~LayerAgentInfo (void);  void refresh_agent (AppPacket *ap);};class bseAgent;class coopAgent;class LayerInfo {public :  int lid;  LinkedList<LayerAgentInfo *, int> ag_list; /* All agents in the cluster */  LayerAgentInfo * root;  bool me_in_layer; /* Whether I am part of this layer */  // SimpleTree<LayerAgentInfo *> cluster_tree; /* This is the cluster tree */  // void * me_pos; /* This is the POS field in the above cluster tree structure */  bool delay_root_xfer; /* If I am the root, then I cannot do root transfer in the                         * next cluster refresh check */  ClusterRefreshMsgTimer cr_msgt;  ClusterRefreshCheckTimer cr_chkt;  LayerInfo (void);      /* Default constructor */  LayerInfo (int Lid, Agent * A);  ~LayerInfo (void);  int AddExtraMembersFromAltRootPacket (AppPacket * ap);  void MakeEmpty (void);  void RemoveAgents (void);  bool AddClusterMember (LayerAgentInfo *a);  bool AddClusterRoot (LayerAgentInfo *a);  bool DeleteClusterMember (LayerAgentInfo *a);  LayerAgentInfo * FindClusterMember (int aid);  LayerAgentInfo ** CreateLayerAgentInfoArray (void);  bool AddToLayerCluster (LayerAgentInfo *a);};double * create_cost_matrix (int self_aid, int self_nid, LayerAgentInfo ** ag_arr, int ag_arr_count);double * delete_agent_from_cost_matrix (double * in_cost, LayerAgentInfo ** ag_arr, int in_count, int aid, int nid);#endif

⌨️ 快捷键说明

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