swarm.h
来自「采用蚂蚁算法实现ad hoc网络路由协议,平台为ns2」· C头文件 代码 · 共 97 行
H
97 行
#ifndef __swarm_h__#define __swarm_h__#include <priqueue.h>#include <cmu-trace.h>#include <map>#include <string>#include <sstream>#include <iostream>#include <swarm/swarm_rtable.h>#define CURRENT_TIME Scheduler::instance().clock()class hdr_swarm;class SWARM:public Tap, public Agent{ friend class hdr_swarm; friend class SwarmEnvironment; public: SWARM(nsaddr_t id); //methods to handle network events void recv(Packet * p, Handler *); void rt_ll_failed(Packet * p); void handle_link_failure(nsaddr_t id); void tap(const Packet * p); void log(string &s); protected: int command(int, const char *const *); int initialized() { return 1 && target_; } SwarmEnvironment env; // methods the agent can use to transport itself void receivePacketLocally(Packet * p); void sendPacket(Packet * p, double delay); /* * A mechanism for logging the contents of the routing * table. */ Trace *logtarget; /* * A pointer to the network interface queue that sits * between the "classifier" and the "link layer". */ PriQueue *ifqueue; Mac *mac_; public: // PROTOCOL SETTINGS static double COST_MAX; static double DECAY_PER_SECOND; static double BROADCAST_RETRANSMIT_JITTER; static double UNICAST_RETRANSMIT_JITTER; static double PROBABILITY_HISTORY; static int PROBABILITY_SAMPLES; static double CONFIDENCE_FROM_RECEIVE; static double RECEIVE_SIGNIFICANCE; static double MAX_PACKET_RECEIVE_RATE; static double CONGESTION_PROBABILITY_EXPONENTIAL; static double CONGESTION_PROBABILITY_WEIGHT; static double IMPROVEMENT_FOR_RESEND; static double UNICAST_SUCCESS_REWARD; static double UNICAST_FAIL_REWARD; static double MINIMUM_REWARD; static double BROADCAST_REWARD; static double TEMPERATURE; static unsigned int NUMBER_OF_SEQNOS_TO_STORE; static unsigned int MAXIMUM_RECEIVES_WITHOUT_SEND; static double HOLDOFF_FOR_PROACTIVE_SEND; static double ROUTE_TIMEOUT; static bool DEBUG;};#endif /* __swarm_h__ */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?