Hi,
Recently I have been trying to implement the code for the GPSR routing protocol
ins ns-2.34 as the original GPSR code is for an older version. I have made
several modifications to the code and feel that I am fairly close to getting it
working, however I have two undefined reference errors when trying to compile
code.
Below is my output:
gpsr/gpsr.o: In function `GPSR_Agent::trace(char*, ...)':
gpsr.cc:(.text+0x1bf5): undefined reference to `Trace::dump()'
gpsr/gpsr.o: In function `GPSR_Agent::recv(Packet*, Handler*)':
gpsr.cc:(.text+0x4a7c): undefined reference to `LocDbase::nlookup(int)'
collect2: ld returned 1 exit status
make: *** [ns] Error 1
----------------------------------------------------------------------------------
The Trace::dump() refers to (I understand) a variable in older versions of ns-2
that no longer exists in trace.h/cc but exists in cmu-trace.h/cc, I added the
trace variable to trace.h//cc myself based on the code from the older ns-2.
However, I think this problem may be solved by finding an alternative to dump,
but I do not know what that would be.
The trace variable is used in one line in gpsr.cc
tracetarget->dump();
----------------------------------------------------------------------------------
Where tracetarget is a '(Trace *) onk' object.
The LocDbase reference is more confusing as it refers to a location database
developed by the authors which access the global information to determine a
node's correct location, stores that in the database and then uses it when
another node needs to find a given node's location. The entire locdbase.cc is
contained below:
/* locdbase.cc -- a location database for mobile, wireless routing */
/*
Copyright (C) 2000 President and Fellows of Harvard College
All rights reserved.
NOTICE: This software is provided "as is", without any warranty,
including any implied warranty for merchantability or fitness for a
particular purpose. Under no circumstances shall Harvard University
or its faculty, staff, students or agents be liable for any use of,
misuse of, or inability to use this software, including incidental
and consequential damages.
License is hereby given to use, modify, and redistribute this
software, in whole or in part, for any commercial or non-commercial
purpose, provided that the user agrees to the terms of this
copyright notice, including disclaimer of warranty, and provided
that this copyright notice, including disclaimer of warranty, is
preserved in the source code and documentation of anything derived
from this software. Any redistributor of this software or anything
derived from this software assumes responsibility for ensuring that
any parties to whom such a redistribution is made are fully aware of
the terms of this license and disclaimer.
Author: Brad Karp, Harvard University EECS, July, 1999
*/
/* This database is a shim, and uses the simulator's global knowledge of
topology and node placement to find the true position of the destination. */
#include "locdbase.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
static class LocDbaseClass : public TclClass {
public:
LocDbaseClass() : TclClass("LocDbase") {}
TclObject *create(int, const char * const *) {
return (new LocDbase);
}
} class_locdbase;
LocDbase::LocDbase() :
table_(NULL), nn_(0)
{
}
LocDbase::~LocDbase()
{
delete[] table_;
}
int LocDbase::command(int argc, const char * const * argv)
{
int i;
if (argc == 3) {
if (strcmp(argv[1], "nnodes") == 0) {
assert(table_ == NULL);
nn_ = atoi(argv[2]);
table_ = new (MobileNode *)[nn_];
for (i = 0; i < nn_; i++)
table_[i] = NULL;
return(TCL_OK);
}
}
else if (argc == 4) {
if (strcmp(argv[1], "register") == 0) {
int addr = atoi(argv[2]);
MobileNode *mn = (MobileNode *) TclObject::lookup(argv[3]);
assert((addr > 0) && (addr < nn_));
table_[addr] = mn;
return(TCL_OK);
}
}
return TclObject::command(argc, argv);
}
inline MobileNode *LocDbase::nlookup(int addr)
{
assert((addr > 0) && (addr < nn_));
return table_[addr];
}
----------------------------------------------------------------------------------
The code is used in GPSR.cc as follows:
GPSR_Agent::GPSR_Agent(void) : Agent(PT_GPSR), beacon_timer_(0),
lastperi_timer_(0), use_mac_(0),
use_peri_(0), verbose_(1), drop_debug_(0), peri_proact_(1),
use_implicit_beacon_(0), use_planar_(0), use_loop_detect_(0),
use_timed_plnrz_(0), bint_(GPSR_ALIVE_INT), bdesync_(GPSR_ALIVE_DESYNC),
bexp_(GPSR_ALIVE_EXP), pint_(GPSR_PPROBE_INT), pdesync_(GPSR_PPROBE_DESYNC),
lpexp_(GPSR_PPROBE_EXP), ldb_(0), mn_(0), ifq_(0)
----------------------------------------------------------------------------------
dmn = ldb_->nlookup(dst);
----------------------------------------------------------------------------------
if (strcmp(argv[1], "ldb") == 0) {
----------------------------------------------------------------------------------
ldb_ = (LocDbase *) obj;
----------------------------------------------------------------------------------
I am slightly confused as to exactly how ldb is used as in some occasions it
appears to be a variable then as an object, it is worth noting that the error
results from ldb->nlookup(dst);' which seems to treat ldb as an object (as
nlookup() is a method) but ldb_ is only declared as an object in ldb_ =
(LocDbase *) obj which occurs AFTER nlookup is called.
I am wondering if perhaps it would be easier to create my own alternative to
locdbase that would allow me to access other node's location data.
Any advice and help would be gratefully appreciated.
Regards,
Fraser
Fraser Cadger (PhD Student)
Intelligent Systems Research Centre
University of Ulster (Magee)