GeographicRouting-WSN
-
Upload
jasper-wessly -
Category
Documents
-
view
36 -
download
2
description
Transcript of GeographicRouting-WSN
Code Available
• GPSR– Geographic Routing– http://www.icir.org/bkarp/gpsr/gpsr.html
• GRID– Geographic Location Service– http://pdos.lcs.mit.edu/grid/
GPSR Code
• ns-2.1b6 • gpsr/{gpsr.cc,h}: GPSR routing agent• gpsr/paper-cmu.tcl: TCL script (parameter
setting)• tcl/mobility/gpsr.tcl: TCL library• locdbase.{cc,h}: Location database• modify ip.h, packet.h, cmu-trace.cc, and
Makefile.in
GPSR Code
• packet.h: PT_GPSR
• cmu-trace.cc:case PT_GPSR:
format_msg(p, offset);
• ip.h: double dx_, dy_, dz_; //destination position
although there is a separate header!
locdbase.{cc,h}
class LocDbase : public NsObject {public: LocDbase(); ~LocDbase(); MobileNode *nlookup(int);protected: void recv(Packet *, Handler *) { }; int command(int argc, const char * const * argv);private: // lookup table MobileNode **table_; int nn_;};
LocDbase Commands
• int command(int argc, const char * const * argv)– nnodes ‘number of nodes’– register ‘address(id)’ ‘node object’
gpsr.h
• class GPSR_Agent : public Tap, public Agent• class hdr_gpsr• class NeighbEnt• class NeighbTable• class GPSR_BeaconTimer• class GPSR_LastPeriTimer• class GPSR_PlanarTimer
class hdr_gpsr
• static int offset_• int mode_• int currhop_• PeriEnt hops_[MAX_PERI_HOPS_STATIC]• struct PeriEnt peript_• nsaddr_t periptip_[3]• int nhops_
Packet Types
• #define GPSRH_DATA_GREEDY 0 // greedy mode data packet
• #define GPSRH_DATA_PERI 1 // perimeter mode data packet
• #define GPSRH_PPROBE 2 // perimeter probe packet
• #define GPSRH_BEACON 3 // liveness beacon packet
gpsr.cc
• int GPSR_Agent::command(int argc,
const char *const *argv)– node ‘node object’– ldb ‘ldb object’– install-tap ‘mac object’– add-ifq ‘ifq object’– start-gpsr
gpsr.cc
void GPSR_Agent::recv(Packet *p, Handler *){
if ((src == mn_->address()) && (cmh->num_forwards() == 0)) {// packet I am originating? Add header fields & forward
if ((src == mn_->address()) && (gpsrh->mode_ == GPSRH_DATA_GREEDY)) { // packet I sent before? Drop
if (iph->dport_ == GPSR_PORT) { // GPSR Beaconelse forwardPacket(p);
}
Packet Receiving
Packet I am originating?
Data Packet?Packet I sent
Before?GPSR Beacon?
Add header fields & forward
Drop Process Forward
gpsr.cc
void GPSR_Agent::forwardPacket(Packet *p, int rtxflag = 0)
{switch(gpsrh->mode_) case GPSRH_DATA_GREEDY: case GPSRH_DATA_PERI: …cmh->direction_ = -1; // send packet down the stacktarget_->recv(p, (Handler *)0);}
tcl/mobility/gpsr.tcl
• GPSR TCL library functions
• proc create-gpsr-routing-agent { node id }
• proc gpsr-create-mobile-node { id args }
TCL Scripts
• Setting parameters
• Create topography and god
• Create mobile nodes and configure
• Create GPSR agents and attach to nodes
• Mobility scenarios
• Traffic scenarios
Setting Parameters
• val(ragent) Agent/GPSR
• Agent/GPSR set bint_ 3.0
• Agent/GPSR set bdesync_ 0.5
• Agent/GPSR set bexp_ 15.0
• Agent/GPSR set use_mac_ 1
• Agent/GPSR set use_peri_ 1
• Agent/GPSR set peri_proact_ 0
• Agent/GPSR set use_planar_ 1
• Agent/GPSR set use_implicit_beacon_ 1
Creating GPSR Agents
set ldb_ [new LocDbase]
$ldb_ nnodes $val(nn)
for {set i 0} {$i < $val(nn) } {incr i} {
create-gpsr-routing-agent $node_($i) $i
# $ragent_($i) created and started
$ragent_($i) install-tap [$node_($i) set mac_(0)]
$ldb_ register [$node_($i) address?] $node_($i)
$ragent_($i) ldb $ldb_
}
Some Tips
• MobileNode::getLoc(double *x, double *y, double *z)– mn->getLoc(&x, &y, &z);
• ARP• Range
– GridKeeper$gkeeper addnode $node_($i)$node_($i) radius $opt(radius)
– Tx power– setdest