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

📄 cbrpagent.h

📁 ns2.1b5版本中cbrp碼
💻 H
字号:
/* cbrp.h */#ifndef cbrp_h_#define cbrp_h_#include <agent.h>#include <ip.h>#include <delay.h>#include <scheduler.h>#include <queue.h>#include <trace.h>#include "config.h"#include "scheduler.h"#include "queue.h"#include <cmu/arp.h>#include <cmu/ll.h>#include <cmu/mac.h>#include <cmu/priqueue.h>//cbrp's request table, route cache implementation are all from DSR. //:) thanks david!#include <cmu/dsr/path.h>#include <cmu/dsr/routecache.h>#include <cmu/dsr/requesttable.h>#include "cbrp_packet.h"#include "ntable.h"typedef double Time;typedef unsigned int uint;#define MAX_QUEUE_LENGTH 5#define ROUTER_PORT      0xff/* The below set of constants are taken from DSR's implementation, I think they work fine */#define BUFFER_CHECK 0.03       // seconds between buffer checks#define RREQ_JITTER 0.010       // seconds to jitter broadcast route requests#define SEND_TIMEOUT 30.0       // # seconds a packet can live in sendbuf#define SEND_BUF_SIZE 64#define RTREP_HOLDOFF_SIZE 10#define GRAT_ROUTE_ERROR 0class CBRP_Agent;class NeighborTablePeriodicHandler;class NeighborTableTimeoutHandler;class NeighborTableCFormationHandler;class ntable_ent;class adjtable_ent;class nexthop_ent;struct CBRP_RtRepHoldoff {     // Taken from DSR's implementation  ID requestor;  ID requested_dest;  int best_length;  int our_length;};struct CBRP_SendBufEntry {  Time t;                       // insertion time  CBRP_Packet p;}; class CBRP_SendBufferTimer : public TimerHandler {   //Taken from DSR's implementationpublic:  CBRP_SendBufferTimer(CBRP_Agent *a) : TimerHandler() { a_ = a;}  void expire(Event *e);protected:  CBRP_Agent *a_;};class CBRP_Agent : public Tap, public Agent {friend class NeighborTable;friend class NeighborTablePeriodicHandler;friend class NeighborTableTimeoutHandler;friend class NeighborTableCFormationHandler;friend class NeighborTableCContentionHandler;friend class CBRP_SendBufferTimer;public:    CBRP_Agent();    virtual int command(int argc, const char * const * argv);    virtual void recv(Packet *, Handler* callback = 0);    void Terminate(void);    void lost_link(Packet *p);    static int no_of_clusters_ ;   // Jinyang It prints out how many clusters that have been formed in total     void tap(const Packet *p);  protected:    void process_cluster_update(Packet * p);    void forwardSRPacket(Packet *);    void startUp();    void trace(char* fmt, ...);    void tracepkt(Packet *, double, int, const char *);        Trace *logtarget;       // Trace Target    PriQueue *ll_queue;       // link level output queue    int myaddr_;              // My address...    int be_random_;    NeighborTable *ntable;      // Randomness/MAC/logging parameters  used in DSR's implementation    int use_mac_;    int verbose_;    int trace_wst_;   private:    int off_mac_;    int off_ll_;    int off_ip_;    int off_cbrp_;    ID net_id, MAC_id;            // our IP addr and MAC addr    NsObject *ll;                 // our link layer output    PriQueue *ifq;                // output interface queue    /******** internal state ********/    CBRP_SendBufferTimer send_buf_timer;    CBRP_SendBufEntry send_buf[SEND_BUF_SIZE];    RequestTable request_table;    RouteCache *route_cache;    int route_request_num;        // number for our next route_request    //below codes r inherited from DSR for dealing with route errors    bool route_error_held; // are we holding a rt err to propagate?    ID err_from, err_to;   // data from the last route err sent to us    Time route_error_data_time; // time err data was filled in    void handlePktWithoutSR(CBRP_Packet& p, bool retry);    void handlePacketReceipt(CBRP_Packet& p);    void handleForwarding(CBRP_Packet& p);    void handleRREQ(CBRP_Packet &p);    int handleRREP(CBRP_Packet &p);    bool ignoreRouteRequestp(CBRP_Packet& p);    void sendOutPacketWithRoute(CBRP_Packet& p, bool fresh, Time delay = 0.0);    void sendOutRtReq(CBRP_Packet &p, int max_prop = MAX_SR_LEN);    void getRouteForPacket(CBRP_Packet &p, bool retry);    void acceptRREP(CBRP_Packet &p);    void returnSrcRouteToRequestor(CBRP_Packet &p);    bool replyFromRouteCache(CBRP_Packet &p);    void processBrokenRouteError(CBRP_Packet& p);    void xmitFailed(Packet *pkt);    void undeliverablePkt(Packet *p, int mine);    void dropSendBuff(CBRP_Packet &p);    void stickPacketInSendBuffer(CBRP_Packet& p);    void sendBufferCheck();    void sendRouteShortening(CBRP_Packet &p, int heard_at, int xmit_at);    void BroadcastRREQ(CBRP_Packet &p);    int UnicastRREQ(CBRP_Packet &p, int nextcluster);    void fillCBRPPath(Path &path, hdr_cbrp *&cbrph);     void testinit();    friend void CBRP_XmitFailureCallback(Packet *pkt, void *data);    friend int CBRP_FilterFailure(Packet *p, void *data);};#endif

⌨️ 快捷键说明

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