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

📄 aodv.h

📁 aodv program to simulate in glomosim simulator
💻 H
字号:
/* * GloMoSim is COPYRIGHTED software.  Release 2.02 of GloMoSim is available  * at no cost to educational users only. * * Commercial use of this software requires a separate license.  No cost, * evaluation licenses are available for such purposes; please contact * info@scalable-networks.com * * By obtaining copies of this and any other files that comprise GloMoSim2.02, * you, the Licensee, agree to abide by the following conditions and * understandings with respect to the copyrighted software: * * 1.Permission to use, copy, and modify this software and its documentation *   for education and non-commercial research purposes only is hereby granted *   to Licensee, provided that the copyright notice, the original author's *   names and unit identification, and this permission notice appear on all *   such copies, and that no charge be made for such copies. Any entity *   desiring permission to use this software for any commercial or *   non-educational research purposes should contact:  * *   Professor Rajive Bagrodia  *   University of California, Los Angeles  *   Department of Computer Science  *   Box 951596  *   3532 Boelter Hall  *   Los Angeles, CA 90095-1596  *   rajive@cs.ucla.edu * * 2.NO REPRESENTATIONS ARE MADE ABOUT THE SUITABILITY OF THE SOFTWARE FOR ANY *   PURPOSE. IT IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. * * 3.Neither the software developers, the Parallel Computing Lab, UCLA, or any *   affiliate of the UC system shall be liable for any damages suffered by *   Licensee from the use of this software. */// Use the latest version of Parsec if this line causes a compiler error./*  * Name: aodv.h * * First Implemented for version 3 by SJ Lee (sjlee@cs.ucla.edu) * Updated for AODV IETF Draft version 13 by Vrishali Wagle * (vrishali@cs.ucsb.edu) *  *//* NOTE: The parameter values follow the AODV Internet Draft Version 13     */#ifndef _AODV_H_#define _AODV_H_#include "ip.h"#include "main.h"#include "nwcommon.h"#define NODE_TRAVERSAL_TIME                       40 * MILLI_SECOND#define NET_DIAMETER                                     35#define ACTIVE_ROUTE_TIMEOUT	         3000 * MILLI_SECOND#define RREP_WAIT_TIME                                 3 * NODE_TRAVERSAL_TIME * NET_DIAMETER / 2#define BAD_LINK_LIFETIME                              2 * RREP_WAIT_TIME#define REV_ROUTE_LIFE                                  RREP_WAIT_TIME#define MY_ROUTE_TIMEOUT                           2 * ACTIVE_ROUTE_TIMEOUT#define RREQ_RETRIES                                      2#define TTL_START                                           1#define TTL_INCREMENT                                   2#define TTL_THRESHOLD                                   7#define BROADCAST_JITTER                              100 * MILLI_SECOND#define NET_DIAMETER	 	         35#define PATH_DISCOVERY_TIME                       2  *  NET_TRAVERSAL_TIME #define NET_TRAVERSAL_TIME	                         2 * NODE_TRAVERSAL_TIME * NET_DIAMETER#define RREQ_RETRIES	           	         2#define TIMEOUT_BUFFER                 	         2#define HELLO_INTERVAL	       	        1000 * MILLI_SECOND#define ALLOWED_HELLO_LOSS     	        3 #define K				       5 // used in calculation of DELETE_PERIOD function RoutingAodvGetDeletePeriod#define MAX_REPAIR_TTL		       0.3 * NET_DIAMETER#define LOCAL_ADD_TTL		       2 #define noGRATUITOUS 	#define noDESTINATION_ONLY#define dontWANT_RREP_ACK #define LOCAL_REPAIR    #define noHELLO_PACKETS  #define CBR_TRAFFIC  //This is because only the CBR code is modified to receive a destination unreachable message from the routing protocol. Consequently this implementation of AODV cannot be used with applications other than CBR. If you want to use with applications other than CBR, please modify the code for your application on the same lines.	 /* Packet Types */typedef enum {	DUMMY, /*Since AODV_RREQ=1,AODV_RREP=2 etc as per draft*/	AODV_RREQ,	AODV_RREP,	AODV_RERR,	AODV_RREP_ACK} AODV_PacketType;typedef struct{    AODV_PacketType pktType;    int bcastId;//the RREQid in draft version 13    NODE_ADDR destAddr;    int destSeq;    NODE_ADDR origAddr;    int origSeq;    NODE_ADDR lastAddr;    int hopCount;    BOOL gratuitousRREP; /*If set, Gratuitous RREP should be sent by intermediate node*/    BOOL destinationOnly; /*If set, indicates only the destination may respond to this RREQ*/    BOOL unknownSeqNo; /*If set, indicates destination sequence number i.e the destSeq field is unknown*/} AODV_RREQ_Packet;typedef struct{    AODV_PacketType pktType;    NODE_ADDR destAddr; /*Destination of the RREQ that initiates RREP*/    int destSeq;    NODE_ADDR origAddr;/*Originator of RREQ. the RREP is unicast to this address*/    int hopCount;    BOOL ackReqd;/*If true, Acknowledgement Required. The receiver of the RREP is expected to respond with a RREP-ACK message*/    clocktype lifetime;} AODV_RREP_Packet;typedef struct{    AODV_PacketType pktType;    NODE_ADDR senderAddr;        } AODV_RREP_ACK_Packet;typedef struct {  NODE_ADDR destinationAddress;  int destinationSequenceNumber; } AODV_AddressSequenceNumberPairType;#define AODV_MAX_RERR_DESTINATIONS 250typedef struct{    AODV_PacketType pktType;          // 1 byte    BOOL N;     unsigned char destinationCount;    AODV_AddressSequenceNumberPairType        destinationPairArray[AODV_MAX_RERR_DESTINATIONS];} AODV_RERR_Packet;typedef struct{   NODE_ADDR nextHop;   NODE_ADDR destAddr;   } AODV_LR_TimerInfo;//Information necessary for local repair timer typedef struct PLE /*Precursor List Entry*/{   NODE_ADDR precursor;   struct PLE *next;   } AODV_PL_Node;typedef struct{   AODV_PL_Node *head,*tail;   int size;   } AODV_PL;typedef struct RTE{    NODE_ADDR destAddr;    int destSeq;    BOOL destSeqValid; /*whether the above destination sequence number is valid*/    BOOL valid;    BOOL repairable;    BOOL beingRepaired;    int hopCount;    NODE_ADDR nextHop;    clocktype lifetime;    AODV_PL precursorList;        struct RTE *next;    } AODV_RT_Node;typedef struct{    AODV_RT_Node *head;    int size;} AODV_RT;typedef struct NTE{  NODE_ADDR nbrAddr; //Neighbor from which HELLO packet was received  clocktype lastHello; //The last time  a HELLO packet was received  clocktype lastPkt; //The last time ANY packet was received from that neighbor   struct NTE *next;} AODV_NT_Node;typedef struct{    AODV_NT_Node *head;    int size;} AODV_NT;/* The neighbor table contains ONLY those neighbors from which a HELLO packet has been received in the past DELETE_PERIOD and not all the neighbors */typedef struct RSE{    NODE_ADDR srcAddr;    int bcastId;    struct RSE *next;} AODV_RST_Node;typedef struct{    AODV_RST_Node *front;    AODV_RST_Node *rear;    int size;} AODV_RST;typedef struct FIFO{    NODE_ADDR destAddr;    clocktype timestamp;    Message *msg;    struct FIFO *next;} AODV_BUFFER_Node;typedef struct{    AODV_BUFFER_Node *head;    int size;} AODV_BUFFER;typedef struct SE{    NODE_ADDR destAddr;    int ttl;    int times;    struct SE *next;} AODV_SENT_Node;typedef struct{    AODV_SENT_Node *head;    int size;} AODV_SENT;typedef struct{  int numRequestSent;//All route requests originated or relayed  int numRequestOrig;  int numReplySent;//All route replies originated or relayed  int numReplySentAsDest;// route replies originated as the destination of the route  int numReplySentAsIn;//route replies originated as an intermediate node  int numGratuitousReplySent;  int numReplyAckSent;  int numRerrSent; //Rerrs sent/relayed  int numRerrNoNSent; //Rerrs sent without N bit i.e. link break  int numRerrNSent;   /*Number of RERRs sent with the N bit sent - local repair */  int numDataSent;        /* Data Sent as the source of the route */  int numDataTxed;  int numDataReceived;    /* Data Received as the destination of the route */  int numHops;  int numRoutes;  int numPacketsDropped;  int numDestUnrchSent; //Number of destination unreachable messages sent to upper layers  int numBrokenLinks;  int numHelloSent;  int numAttemptsLocalRepair;  int numSuccessfulLocalRepair;} AODV_Stats;typedef struct glomo_network_aodv_str {  AODV_RT routeTable;  AODV_NT nbrTable;  AODV_RST seenTable;  AODV_BUFFER buffer;  AODV_SENT sent;  AODV_Stats stats;  int seqNumber;  int bcastId;  clocktype lastbcast;  clocktype lastpkt;} GlomoRoutingAodv;void RoutingAodvInit(GlomoNode *node, GlomoRoutingAodv **aodvPtr, const GlomoNodeInput *nodeInput);void RoutingAodvFinalize(GlomoNode *node);void RoutingAodvHandleData(GlomoNode *node, Message *msg, NODE_ADDR destAddr);void RoutingAodvHandleRequest(GlomoNode *node, Message *msg, int ttl);void RoutingAodvHandleReply(GlomoNode *node, Message *msg, NODE_ADDR srcAddr, NODE_ADDR destAddr);void RoutingAodvHandleHello(GlomoNode *node, Message *msg, NODE_ADDR nbrAddr);void RoutingAodvHandleRouteError(GlomoNode *node, Message *msg, NODE_ADDR srcAddr);void RoutingAodvInitRouteTable(AODV_RT *routeTable);void RoutingAodvInitNbrTable(AODV_NT *nbrTable);void RoutingAodvInitSeenTable(AODV_RST *seenTable);void RoutingAodvInitBuffer(AODV_BUFFER *buffer);void RoutingAodvInitSent(AODV_SENT *sent);void RoutingAodvInitStats(GlomoNode *node);void RoutingAodvInitSeq(GlomoNode *node);void RoutingAodvInitBcastId(GlomoNode *node);NODE_ADDR RoutingAodvGetNextHop(NODE_ADDR destAddr, AODV_RT *routeTable);void RoutingAodvAddPrecursor(NODE_ADDR precursor,NODE_ADDR destAddr, AODV_RT* routeTable);int RoutingAodvGetBcastId(GlomoNode *node);int RoutingAodvGetSeq(NODE_ADDR destAddr, AODV_RT *routeTable);int RoutingAodvGetMySeq(GlomoNode *node);void RoutingAodvIncreaseSeq(GlomoNode *node);int RoutingAodvGetHopCount(NODE_ADDR destAddr, AODV_RT *routeTable);void RoutingAodvIncreaseTtl(NODE_ADDR destAddr, AODV_SENT *sent);int RoutingAodvGetTtl(NODE_ADDR destAddr, AODV_SENT *sent);int RoutingAodvGetTimes(NODE_ADDR destAddr, AODV_SENT *sent);void RoutingAodvUpdateLifetime(NODE_ADDR destAddr, AODV_RT *routeTable);clocktype RoutingAodvGetLifetime(NODE_ADDR destAddr, AODV_RT *routeTable);Message *RoutingAodvGetBufferedPacket(NODE_ADDR destAddr, AODV_BUFFER *buffer);void RoutingAodvGetPrecursors(GlomoNode *node, NODE_ADDR destAddr,AODV_PL* precursorList);BOOL RoutingAodvCheckRouteExist(NODE_ADDR destAddr, AODV_RT *routeTable);BOOL RoutingAodvCheckRouteEntryExist(NODE_ADDR destAddr, AODV_RT *routeTable);BOOL RoutingAodvIfSeqValid(NODE_ADDR destAddr,AODV_RT *routeTable);BOOL RoutingAodvLookupSeenTable(NODE_ADDR srcAddr, int bcastId, AODV_RST *seenTable);BOOL RoutingAodvLookupBuffer(NODE_ADDR destAddr, AODV_BUFFER *buffer);BOOL RoutingAodvCheckSent(NODE_ADDR destAddr, AODV_SENT *sent);BOOL RoutingAodvIfRouteInactive(NODE_ADDR destAddr,AODV_RT* routeTable);BOOL RoutingAodvCheckBeingRepaired(NODE_ADDR destAddr,AODV_RT* routeTable);BOOL RoutingAodvCheckRepairable(NODE_ADDR destAddr,AODV_RT* routeTable);BOOL RoutingAodvCheckPrecursorList(NODE_ADDR precursor, AODV_PL_Node *head);BOOL RoutingAodvIfMePartOfActiveRoute(GlomoNode *node);void RoutingAodvIncreaseTimes(NODE_ADDR destAddr, AODV_SENT *sent);void RoutingAodvActivateRoute(NODE_ADDR destAddr, AODV_RT *routeTable);BOOL RoutingAodvCheckNbrExist(GlomoNode *node, NODE_ADDR nbrAddr);void RoutingAodvResetRepairableSetBeingRepairedAndIncSeq(NODE_ADDR destAddr, AODV_RT *routeTable);void RoutingAodvResetBeingRepaired(NODE_ADDR destAddr, AODV_RT *routeTable);void RoutingAodvInsertNbrTable(GlomoNode *node, NODE_ADDR nbrAddr);void RoutingAodvDeleteNbrTable(GlomoNode *node, NODE_ADDR nbrAddr);void RoutingAodvReplaceInsertRouteTable(GlomoNode *node, NODE_ADDR destAddr, int destSeq, BOOL destSeqValid, BOOL valid, int hopCount, NODE_ADDR nextHop,	clocktype lifetime);void RoutingAodvDeleteRouteTable(GlomoNode *node,NODE_ADDR destAddr);static void RoutingAodvInsertSeenTable(GlomoNode *node, NODE_ADDR srcAddr, int bcastId, AODV_RST *seenTable);void RoutingAodvDeleteSeenTable(AODV_RST *seenTable);static void RoutingAodvInsertBuffer(Message* msg, NODE_ADDR destAddr, AODV_BUFFER* buffer);BOOL RoutingAodvDeleteBuffer(NODE_ADDR destAddr, AODV_BUFFER *buffer);static void RoutingAodvInsertSent(NODE_ADDR destAddr, int ttl, AODV_SENT *sent);void RoutingAodvDeleteSent(NODE_ADDR destAddr, AODV_SENT *sent);void RoutingAodvUpdateLastPacketTime(GlomoNode *node, NODE_ADDR nbrAddr); //Updates the last time any packet was received from a neighbor in neighbor tablevoid RoutingAodvUpdateLastHelloTime(GlomoNode *node, NODE_ADDR nbrAddr); //updates the last time a HELLO packet was received from a neighbor in neighbor table  void RoutingAodvHandleProtocolPacket(GlomoNode *node, Message *msg, NODE_ADDR srcAddr, NODE_ADDR destAddr, int ttl);void RoutingAodvHandleProtocolEvent(GlomoNode *node, Message *msg);void RoutingAodvHandleRouteTimeout(GlomoNode *node,NODE_ADDR destAddr);void RoutingAodvRouterFunction(GlomoNode *node,Message *msg,NODE_ADDR destAddr,  BOOL *packetWasRouted);void RoutingAodvPacketDropNotificationHandler( GlomoNode *node, const Message* msg, const NODE_ADDR nextHopAddress);void RoutingAodvCheckLossOfNeighbor(GlomoNode *node, NODE_ADDR nbrAddr);void RoutingAodvSetTimer(GlomoNode *node, long eventType, NODE_ADDR destAddr, clocktype delay);void RoutingAodvInitiateRREQ(GlomoNode *node, NODE_ADDR destAddr);void RoutingAodvRetryRREQ(GlomoNode *node, NODE_ADDR destAddr);void RoutingAodvTransmitData(GlomoNode *node, Message *msg, NODE_ADDR destAddr);void RoutingAodvRelayRREQ(GlomoNode *node, Message *msg, int ttl);void RoutingAodvInitiateRREP(GlomoNode *node, Message *msg);void RoutingAodvInitiateRREPbyIN(GlomoNode *node, Message *msg);void RoutingAodvInitiateGratuitousRREP(GlomoNode *node, Message *msg);void RoutingAodvRelayRREP(GlomoNode *node, Message *msg, NODE_ADDR destAddr);void RoutingAodvInitiateRREPACK(GlomoNode *node, Message *msg, NODE_ADDR srcAddr);void RoutingAodvStartLocalRepair(GlomoNode *node, NODE_ADDR origAddr, NODE_ADDR destAddr);void RoutingAodvInitiateRERROnLinkBreak(GlomoNode *node, NODE_ADDR destAddr);void SendRouteErrorPacket(GlomoNode* node, const AODV_RERR_Packet* rerrPacket,AODV_PL *precursorList);void RoutingAodvDisplayPrecursors(AODV_PL_Node *head);void RoutingAodvDisplayRouteTable(GlomoNode *node);void RoutingAodvDisplayNbrTable(GlomoNode *node);void RoutingAodvInitiateHELLO(GlomoNode *node);void RoutingAodvInactivateRoutesAndGetDestinations(GlomoNode* node, AODV_RT* routeTable, NODE_ADDR nextHop, AODV_AddressSequenceNumberPairType destinationPairs[], int maxNumberDestinationPairs, int* numberDestinations,  AODV_PL* precursorList);void RoutingAodvInactivateRoutesInLocalRepair(GlomoNode *node, NODE_ADDR nextHop, NODE_ADDR destAddr);clocktype RoutingAodvGetLastPacketTime(GlomoNode *node, NODE_ADDR nbrAddr);clocktype RoutingAodvGetRingTraversalTime(int ttl);clocktype RoutingAodvGetMinimalLifetime(int hopCount);clocktype RoutingAodvGetDeletePeriod();clocktype RoutingAodvGetMyRouteTimeout(GlomoNode *node);#endif /* _AODV_H_ */

⌨️ 快捷键说明

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