-- Running position-based routing protocols in 3D environment for NS-2 -- -- Code verified for ns-2.35 version -- (Document rev. 1.0, March 2, 2017) Note: when compiling ns-allinone-2.35 on Ubuntu, you could get a compilation error like in the following: ------------------------------------------------------------------ linkstate/ls.h:137:58: error: ‘erase’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] void eraseAll() { erase(baseMap::begin(), baseMap::end()); } ^ linkstate/ls.h:137:58: note: declarations in dependent base ‘std::map, std::allocator > >’ are not found by unqualified lookup linkstate/ls.h:137:58: note: use ‘this->erase’ instead make: *** [linkstate/ls.o] Error 1 Ns make failed! ------------------------------------------------------------------ To solve the problem you have e to edit the line number 137 of "/ns-allinone-2.35/ns-2.35/linkstate/ls.h" from: - void eraseAll() { erase(baseMap::begin(), baseMap::end()); } to - void eraseAll() { this->erase(baseMap::begin(), baseMap::end()); } and your ns-2 installation will be successful. -- Step 1 -- 3D environment: install M2ANET patch following the instructions placed in the directory "M2ANET". Verify if you have a working 3D environment running the test included. -- Step 2 -- Copy the directory "geo" in your ns2 install directory, specifically in "/ns-allinone-2.35/ns-2.35/" -- Step 3 -- There are some changes you need to do in order to integrate the new code inside the simulator. Go to "/ns-2.35/common/packet.h" and find the definition of type packet_t "typedef unsigned int packet_t", where all the packet are listed. You have to add PT_GEO to this list as shown in the next lines of code (--> = add this additional line). ------------------------------------------------------------------ -- common/packet.h -- : ... : typedef unsigned int packet_t; : static const packet_t PT_TCP = 0; : ... : --> static const packet_t PT_GEO = 73; : static packet_t PT_NTYPE = 74; // This MUST be the LAST one ------------------------------------------------------------------ Just below, in the same file, is the definition of "p_info" class. Inside the constructor you need to provide a name for the new GEO packet type (--> = add this additional line). ------------------------------------------------------------------ -- common/packet.h -- : ... : p_info() { : name_[PT_TCP]= "tcp"; : name_[PT_UDP]= "udp"; : name_[PT_CBR]= "cbr"; : /* ... much more names ... */ : --> name_[PT_GEO]= "geo"; : } ------------------------------------------------------------------ -- Step 4 -- Now you need to do some changes in Tcl files (configuration files of the simulator also its scripting language). You need to the packet type, give the default values for its attributes and some additional parameters needed to create the wireless nodes running the GEO routing protocol. In "/ns-2.35/tcl/lib/ns-packet.tcl" locate the code below and add GEO to the list (--> = add this additional line). ----------------------------------------------------------------- -- tcl/lib/ns-packet.tcl -- : set protolist { : # Common: : Common : Flags : .... : --> GEO # geographic protocol ----------------------------------------------------------------- -- Step 5 -- Finally you have to modify "/ns-allinone-2.35/tcl/lib/ns-lib.tcl" by adding the procedures for node creation. We are interested in creating a wireless node with GEO as the routing protocol. Find the "create-wireless-node" procedure and add the new GEO case in the switch-case construct, as below (--> = add this additional line). ---------------------------------------------------------------- -- tcl/lib/ns-lib.tcl -- : Simulator instproc create-wireless-node args { : # ... : switch -exact $routingAgent_ { : --> GEO { : --> set ragent [$self create-geo-agent $node] : --> } : # ... : } --------------------------------------------------------------- Then add the "create-geo-agent" procedure in the same file as shown in the next piece of code (copy and paste). -- tcl/lib/ns-lib.tcl -- Simulator instproc create-geo-agent { node } { #create the GEO routing agent set ragent [new Agent/GEO [$node node-addr]] set addr [$node node-addr] $ragent addr $addr $ragent node $node if [Simulator set mobile_ip_] { $ragent port-dmux [$node set dmux_] } $node addr $addr $node set ragent_ $ragent $self at 0.0 "$ragent set-location" $self at 0.0 "$ragent start" return $ragent } -- Step 6 -- Now everything is in place and you only need to compile it! To do so you need to edit the Makefile file by adding the new object files inside OBJ CC variable as follows (--> = add this additional line). -- Makefile -- : OBJ_CC = \ : tools/random.o tools/rng.o tools/ranvar.o common/misc.o common/timer-handler.o \ : # ... : --> geo/geo.o geo/geo_node.o geo/geo_next_node.o geo/geo_utility.o \ : # ... : $(OBJ_STL) After that you can execute make and enjoy with GEO protocol. This basic version of GEO protocol includes the following forwarding algorithms: 1. GREEDY 2. COMPASS 3. MOST FORWARD 4. ELLIPSOID 5. PAB3D 6. PROJECTIVE FACE 7. CFACE(3) 8. ALSP FACE 9. GREEDY-ALSP_FACE-GREEDY 10. PAB3D-FACE(1)-PAB3D 11. GREEDY-PAB3D-GREEDY 12. LAR 13. PAB3D-LAR 14. DEPTH FIRST SEARCH Good Luck