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

📄 app-packet.h

📁 模拟器提供了一个简单易用的平台
💻 H
字号:
/************************************************** *  File: app-packet.h  Author: Suman Banerjee <suman@cs.umd.edu>  Date: 15th March, 2001  Terms: GPL  Narada 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 _APP_PACKET_H_#define _APP_PACKET_H_#include <stdlib.h>#include <packet.h>#include <agent.h>#include <constants.h>#define MAX_RET_NBRS 10#define MAXMMARRAYSIZE 600extern NamedConstant maxmeshmembers;#define MAXMESHMEMBERS (maxmeshmembers.getval().u.i)enum AppPacketSubType {  PING_RP,  PING_RP_RESPONSE,  MESH_NEIGHBOR_SETUP_REQUEST,  MESH_NEIGHBOR_SETUP_RESPONSE,  MESH_NEIGHBOR_REFRESH,	  //sri's code  MESH_LINK_ADD,  MESH_LINK_ADD_RESPONSE,  MESH_LINK_DROP,  MESH_RT_EXCHANGE,  DATA  //};struct ping_rp_pkt {  int seek_nbr_cnt;  // ping_rp_pkt (int s) { seek_nbr_cnt = s;}};struct PacketAgentInfo {  int agent_id;  int node_id;};struct ping_rp_response_pkt {   int ret_nbr_cnt;   PacketAgentInfo ret_nbrs[MAX_RET_NBRS];};struct mesh_neighbor_setup_req_pkt {};struct mesh_neighbor_setup_resp_pkt {  bool accept;};struct mesh_neighbor_refresh_pkt {  int neighbor_seq_no;  bool is_alive;  PacketAgentInfo origin;  int origin_seq_no;};//sri's codestruct mesh_rt_exchange_pkt {/*  bool valid[MAXMMARRAYSIZE];   int pathlen[MAXMMARRAYSIZE];   struct AgentInfo *path[MAXMMARRAYSIZE];   double cost[MAXMMARRAYSIZE]; */  bool * valid;   int * pathlen;   struct AgentInfo ** path;   double * cost; };struct data_pkt {    long seq_no;   int src_agent_id;   int src_node_id; }; //class AppPacket : public Packet {public :  AppPacketSubType st;  union {    ping_rp_pkt ping_p;    ping_rp_response_pkt pingresp_p;    mesh_neighbor_setup_req_pkt meshneighborsetupreq_p;    mesh_neighbor_setup_resp_pkt meshneighborsetupresp_p;    mesh_neighbor_refresh_pkt meshrefresh_p;    // sri's code    mesh_rt_exchange_pkt meshrt_p;     data_pkt data_p;   //  } u;  AppPacket (AppPacketSubType St) : Packet() { t = PACKET_APP; st = St; };    ~AppPacket (void) {      switch (st) {          case MESH_RT_EXCHANGE:                 for(int i = 0; i < MAXMESHMEMBERS; i++)           if ((u.meshrt_p.valid[i]) && (u.meshrt_p.pathlen[i] > 1))             free(u.meshrt_p.path[i]);                delete[] u.meshrt_p.path;        delete[] u.meshrt_p.valid;        delete[] u.meshrt_p.pathlen;         delete[] u.meshrt_p.cost;        break;       case MESH_LINK_ADD_RESPONSE:                 for(int i = 0; i < MAXMESHMEMBERS; i++)           if ((u.meshrt_p.valid[i]) && (u.meshrt_p.pathlen[i] > 1))             free(u.meshrt_p.path[i]);                delete[] u.meshrt_p.path;        delete[] u.meshrt_p.valid;        delete[] u.meshrt_p.pathlen;         delete[] u.meshrt_p.cost;        break;       default:        break;     }  }  };#endif

⌨️ 快捷键说明

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