Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
arc.h
Package: arc.rar [view]
Upload User: rubber
Upload Date: 2018-02-13
Package Size: 87k
Code Size: 11k
Category:
Communication-Mobile
Development Platform:
Tcl-Tk
- #ifndef __arc_h__
- #define __arc_h__
- //#include <agent.h>
- //#include <packet.h>
- //#include <sys/types.h>
- //#include <cmu/list.h>
- //#include <scheduler.h>
- #include <cmu-trace.h>
- #include <priqueue.h>
- #include <arc/arc_rtable.h>
- #include <arc/arc_rqueue.h>
- #include <classifier/classifier-port.h>
- /*
- Allows local repair of routes.
- Local repair does not always work correct! Don't use it for now.
- */
- //#define ARC_LOCAL_REPAIR
- /*
- Allows ARC to use link-layer (802.11) feedback in determining when
- links are up/down.
- */
- #define ARC_LINK_LAYER_DETECTION
- /*
- Causes ARC to apply a "smoothing" function to the link layer feedback
- that is generated by 802.11. In essence, it requires that RT_MAX_ERROR
- errors occurs within a window of RT_MAX_ERROR_TIME before the link
- is considered bad.
- */
- #define ARC_USE_LL_METRIC
- /*
- Only applies if ARC_USE_LL_METRIC is defined.
- Causes ARC to apply omniscient knowledge to the feedback received
- from 802.11. This may be flawed, because it does not account for
- congestion.
- */
- //#define ARC_USE_GOD_FEEDBACK
- //My modification************************************************************//
- /*
- To run simulations with different gateway discovery methods:
- 1. PROACTIVE GATEWAY DISCOVERY METHOD
- * Type "Agent/ARC set gw_discovery 0" before the creation of the nodes in
- * your Tcl file.
- 2. HYBRID GATEWAY DISCOVERY METHOD
- * Type "Agent/ARC set gw_discovery 1" before the creation of the nodes in
- * your Tcl file.
- 3. REACTIVE GATEWAY DISCOVERY METHOD
- * Type "Agent/ARC set gw_discovery 2" before the creation of the nodes in
- * your Tcl file.
- */
- //#define DEQUE_AFTER_RREP_I
- //***************************************************************************//
- class ARC;
- #define ACTIVE_ROUTE_TIMEOUT 10 // seconds
- #define BCAST_ID_SAVE 6 // seconds
- #define MY_ROUTE_TIMEOUT 10 // seconds
- // Should be set by the user using best guess (conservative)
- #define NETWORK_DIAMETER 30 // hops
- // This should be somewhat related to arp timeout
- #define NODE_TRAVERSAL_TIME 0.03 // seconds (used in PerHopTime)
- #define REV_ROUTE_LIFE 6 // seconds
- // No. of times to do network-wide search before timing out for
- // MAX_RREQ_TIMEOUT sec.
- #define RREQ_RETRIES 2 // times
- // Various constants used for the expanding ring search
- #define TTL_START 1
- #define TTL_INCREMENT 2
- #define TTL_THRESHOLD 7
- // The followings are used for the forward() function. Controls pacing.
- #define DELAY 1.0 // random delay - used for rebroadcasting RREQs
- #define NO_DELAY -1.0 // no delay
- // think it should be 30 ms
- #define ARP_DELAY 0.01 // fixed delay to keep arp happy
- //My modification************************************************************//
- /*
- The address of the default route is defined to -10.
- All the gateways in the MANET have a common address ALL_MANET_GW_MULTICAST.
- */
- #define DEFAULT -10
- #define ALL_MANET_GW_MULTICAST -20
- #define GWINFO_LIFETIME 10 // seconds
- #define RREQ_I_RETRIES 4 // times
- #define ADVERTISEMENT_ZONE 3 // hops, used for hybrid gw discovery
- #define ADVERTISEMENT_INTERVAL 5 // seconds, used for hybrid & proactive
- //***************************************************************************//
- // timeout after doing network-wide search RREQ_RETRIES times
- #define MAX_RREQ_TIMEOUT 10.0 // seconds
- // Must be larger than the time difference between a node propagates a route
- // request and gets the route reply back.
- //#define RREP_WAIT_TIME (3 * NODE_TRAVERSAL_TIME * NETWORK_DIAMETER) // ms
- //#define RREP_WAIT_TIME (2 * REV_ROUTE_LIFE) // seconds
- #define RREP_WAIT_TIME 1.0 // seconds
- #define LOCAL_REPAIR_WAIT_TIME 0.15 // seconds
- #define ID_NOT_FOUND 0x00
- #define ID_FOUND 0x01
- //#define INFINITY 0xff
- #define HELLO_INTERVAL 1 // second
- #define ALLOWED_HELLO_LOSS 3 // packets
- #define BAD_LINK_LIFETIME 3 // seconds
- #define MaxHelloInterval (1.25 * HELLO_INTERVAL)
- #define MinHelloInterval (0.75 * HELLO_INTERVAL)
- /* =====================================================================
- Timers (Broadcast ID, Hello, Neighbor Cache, Route Cache)
- ===================================================================== */
- class BroadcastTimer : public Handler {
- public:
- BroadcastTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- class HelloTimer : public Handler {
- public:
- HelloTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- class NeighborTimer : public Handler {
- public:
- NeighborTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- class RouteCacheTimer : public Handler {
- public:
- RouteCacheTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- class LocalRepairTimer : public Handler {
- public:
- LocalRepairTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- //My modification************************************************************//
- /*
- Implementing proactive and hybrid gateway discovery...
- */
- class AdvertisementTimer : public Handler {
- public:
- AdvertisementTimer(ARC* a) : agent(a) {}
- void handle(Event*);
- private:
- ARC *agent;
- Event intr;
- };
- //***************************************************************************//
- /* =====================================================================
- Broadcast ID Cache
- ===================================================================== */
- class BroadcastID {
- friend class ARC;
- public:
- BroadcastID(nsaddr_t i, u_int32_t b) { src = i; id = b; }
- protected:
- LIST_ENTRY(BroadcastID) link;
- nsaddr_t src;
- u_int32_t id;
- double expire; // now + BCAST_ID_SAVE s
- };
- LIST_HEAD(arc_bcache, BroadcastID);
- /* =====================================================================
- The Routing Agent
- ===================================================================== */
- class ARC: public Agent {
- /*
- * make some friends first
- */
- friend class arc_rt_entry;
- friend class BroadcastTimer;
- friend class HelloTimer;
- friend class NeighborTimer;
- friend class RouteCacheTimer;
- friend class LocalRepairTimer;
- //My modification***************************************//
- /*
- Implementing proactive and hybrid gateway discovery...
- */
- friend class AdvertisementTimer;
- //******************************************************//
- public:
- ARC(nsaddr_t id);
- void recv(Packet *p, Handler *);
- protected:
- int command(int, const char *const *);
- int initialized() { return 1 && target_; }
- /*
- * Route Table Management
- */
- void rt_resolve(Packet *p);
- void rt_update(arc_rt_entry *rt, u_int32_t seqnum,
- u_int16_t metric, nsaddr_t nexthop,
- double expire_time);
- void rt_down(arc_rt_entry *rt);
- void local_rt_repair(arc_rt_entry *rt, Packet *p);
- //My modification**********************************************************//
- void print_routing_table();
- arc_rt_entry* find_send_entry(arc_rt_entry *rt);
- arc_rt_entry* find_fn_entry(void);
- //*************************************************************************//
- public:
- void rt_ll_failed(Packet *p);
- void handle_link_failure(nsaddr_t id);
- protected:
- void rt_purge(void);
- void enque(arc_rt_entry *rt, Packet *p);
- Packet* deque(arc_rt_entry *rt);
- /*
- * Neighbor Management
- */
- void nb_insert(nsaddr_t id);
- ARC_Neighbor* nb_lookup(nsaddr_t id);
- void nb_delete(nsaddr_t id);
- void nb_purge(void);
- /*
- * Broadcast ID Management
- */
- void id_insert(nsaddr_t id, u_int32_t bid);
- bool id_lookup(nsaddr_t id, u_int32_t bid);
- void id_purge(void);
- /*
- * Packet TX Routines
- */
- void forward(arc_rt_entry *rt, Packet *p, double delay);
- void sendHello(void);
- //My modification**********************************************************//
- /*
- Added a field for flags to be able to distinguish between ordinary
- RREQ/RREP and RREQ_I/RREP_I.
- */
- void sendRequest(nsaddr_t dst, u_int8_t flag);
- void sendReply(nsaddr_t ipdst, u_int32_t hop_count,
- nsaddr_t rpdst, u_int32_t rpseq,
- u_int32_t lifetime, double timestamp,
- u_int8_t flag);
- /*
- Implementing proactive and hybrid gateway discovery...
- */
- void sendAdvertisement(int ttl);
- //*************************************************************************//
- void sendError(Packet *p, bool jitter = true);
- /*
- * Packet RX Routines
- */
- void recvAODV(Packet *p);
- void recvHello(Packet *p);
- void recvRequest(Packet *p);
- void recvReply(Packet *p);
- void recvError(Packet *p);
- //My modification**********************************************************//
- /*
- Implementing proactive gateway discovery...
- */
- void recvAdvertisement(Packet *p);
- //*************************************************************************//
- /*
- * History management
- */
- double PerHopTime(arc_rt_entry *rt);
- nsaddr_t index; // IP Address of this node
- u_int32_t seqno; // Sequence Number
- int bid; // Broadcast ID
- //My modification**********************************************************//
- /*
- Implementing proactive and hybrid gateway discovery...
- */
- int gw_discovery;
- int ad_bid; //Broadcast ID for advertisemens from GW
- //*************************************************************************//
- arc_rtable rthead; // routing table
- arc_ncache nbhead; // Neighbor Cache
- arc_bcache bihead; // Broadcast ID Cache
- /*
- * Timers
- */
- BroadcastTimer btimer;
- HelloTimer htimer;
- NeighborTimer ntimer;
- RouteCacheTimer rtimer;
- LocalRepairTimer lrtimer;
- //My modification****************************************//
- /*
- Implementing proactive and hybrid gateway discovery...
- */
- AdvertisementTimer adtimer;
- //*******************************************************//
- /*
- * Routing Table
- */
- arc_rtable rtable;
- /*
- * A "drop-front" queue used by the routing layer to buffer
- * packets to which it does not have a route.
- */
- arc_rqueue rqueue;
- /*
- * 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;
- //My modification**********************************************************//
- /*
- A pointer to a mobile node to be able to use base_stn() and
- set_base_stn(int addr) in mobilenode.h.
- */
- MobileNode *thisnode;
- //*************************************************************************//
- /*
- * Logging stuff
- */
- void log_link_del(nsaddr_t dst);
- void log_link_broke(Packet *p);
- void log_link_kept(nsaddr_t dst);
- /* for passing packets up to agents */
- PortClassifier *dmux_;
- };
- #endif /* __arc_h__ */