LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-24-2015, 01:29 PM   #1
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Rep: Reputation: Disabled
make error


Hi,
I get the following error when I try to implement new routing protocol. Kindly help me to sort out this error

ubuntu version:14.04
gcc:4.8
g++:4.8

trace/cmu-trace.o: In function `hdr_bed::access(Packet const*)':
cmu-trace.cc.text._ZN7hdr_bed6accessEPK6Packet[_ZN7hdr_bed6accessEPK6Packet]+0x7): undefined reference to `hdr_bed:ffset_'
collect2: error: ld returned 1 exit status
make: *** [ns] Error 1
 
Old 01-25-2015, 01:31 PM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Either you are using bogus symbols or not including a needed library for linking.
 
Old 01-25-2015, 02:12 PM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
@vpchitraa : Welcome to LQ.

Your error : Looks like a generic ns2 error.
( E.g. by using the wrong g++ ).

All the Ubuntu 14.04 compilers can be present at the same time :
$ sudo apt-get install g++ g++-4.4 g++-4.6
Using : $ export CC=gcc-4.4 CXX=g++-4.4 && ./install

Besides that, you can use an updated ns-allinone-2.35 :
ns-allinone-2.35_gcc491.tar.gz
https://drive.google.com/file/d/0B7S...ew?usp=sharing
... for gcc/g++ versions 4.6.x ... 4.9.x

-
 
Old 01-25-2015, 07:38 PM   #4
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thumbs up Make error

Thanks for the reply. THe error was rectified after the declaration of
int hdr_bed:ffset_; in CMUtrace.cc file
 
Old 01-25-2015, 07:41 PM   #5
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Hi

Thanks. make error eliminated after the declaration of "int hdr_bed:ffset_;" in CMUtrace.cc file. But,I got the following error when I execute the tcl file: ns bed6.tcl

ns:
[code omitted because of length]
: invalid command name "Agent/BED"
while executing
"Agent/BED instproc init args {

$self next $args
}"

Kindly reply me the solution

Last edited by vpchitraa; 01-25-2015 at 07:44 PM.
 
Old 01-25-2015, 08:10 PM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
← #4 .

Ns2 is an (o)tcl application.
New added protocols must be compiled into tcl/lib/\
{ e.g. ns-default.tcl, ns-lib.tcl, ns-agent.tcl, ns-mobilenode.tcl }.

Make the changes, do a 'make clean' in ns-2.3x/,
and rerun './install' in the top directory = ns-allinone-2.3x/.


-
 
Old 01-25-2015, 08:37 PM   #7
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks. I followed the following steps

/ns-allinone-2.35/ns-2.35$ make clean
/ns-allinone-2.35$ ./install

It installs properly. no error.

/ns-allinone-2.35/ns-2.35$ ./configure --with-tcl-ver=8.5.10 && make && sudo make install

...

for i in indep-utils/cmu-scen-gen/setdest indep-utils/webtrace-conv/dec indep-utils/webtrace-conv/epa indep-utils/webtrace-conv/nlanr indep-utils/webtrace-conv/ucb; do ( cd $i; make all; ) done
make[1]: Entering directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/cmu-scen-gen/setdest'
make[1]: Entering directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/dec'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `//home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/dec'
make[1]: Entering directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/epa'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/epa'
make[1]: Entering directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/nlanr'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/nlanr'
make[1]: Entering directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/.../ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
[sudo] password :
for d in /usr/local/man/man1; do \
if [ ! -d $d ]; then \
mkdir -p $d ;\
fi;\
done
/usr/bin/install -c -m 755 ns /usr/local/bin
/usr/bin/install -c -m 644 ns.1 /usr/local/man/man1

ns-allinone-2.35/ns-2.35$ ns bed6.tcl
ns:
[code omitted because of length]
: invalid command name "Agent/BED"
while executing
"Agent/BED instproc init args {

$self next $args
}"

Kindly reply me a solution

Last edited by vpchitraa; 01-25-2015 at 08:47 PM.
 
Old 01-25-2015, 09:21 PM   #8
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
← #6.

What's in your protocol ? And which files were edited ?

What did you add to {ns-default.tcl, ns-lib.tcl, ns-agent.tcl, ns-mobilenode.tcl} ?


-
 
Old 01-25-2015, 09:50 PM   #9
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks. changes in the above said file is pasted

ns-lib.tcl

WFRP {
set ragent [$self create-wfrp-agent $node]
}
BED {
set ragent [$self create-bed-agent $node]
}
default {
eval $node addr $args
puts "Wrong node routing agent!"
exit
}
...

Simulator instproc create-wfrp-agent { node } {
# Create WFRP routing agent
set ragent [new Agent/WFRP [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}

Simulator instproc create-bed-agent { node } {
# Create BED routing agent
set ragent [new Agent/BED [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}
# AOMDV patch
Simulator instproc create-aomdv-agent { node } {
set ragent [new Agent/AOMDV [$node node-addr]]
$self at 0.0 "$ragent start"
$node set ragent_ $ragent
return $ragent
}

ns-agent.tcl

# Class Agent/BED -superclass Agent

Agent/BED instproc init args {

$self next $args
}

Agent/BED set sport_ 0
Agent/BED set dport_ 0

# AOMDV patch
Agent/AOMDV set sport_ 0
Agent/AOMDV set dport_ 0
Agent/AOMDV set aomdv_prim_alt_path_len_diff_ 1
Agent/AOMDV set aomdv_max_paths_ 3

ns-mobilenode.tcl

# Special processing for BED
set wfrponly [string first "BED" [$agent info class]]
if {$wfrponly != -1 } {
$agent if-queue [$self set ifq_(0)] ;# ifq between LL and MAC
}

no change in ns-default.tcl


my protocol name is BED
 
Old 01-25-2015, 09:56 PM   #10
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
IN BED

bed.cc

#include <bed/bed.h>
#include <bed/bed_packet.h>
#include <bed/select.h>
#include <random.h>
#include <cmu-trace.h>
#include <energy-model.h>

MobileNode *nadr[MAXI];

#define max(a,b) ( (a) > (b) ? (a) : (b) )
#define CURRENT_TIME Scheduler::instance().clock()


//#define DEBUG

// ======================================================================
// TCL Hooking Classes
// ======================================================================

int hdr_bed:ffset_;
static class BEDHeaderClass : public PacketHeaderClass {
public:
BEDHeaderClass() : PacketHeaderClass("PacketHeader/BED", sizeof(hdr_all_bed)) {
bind_offset(&hdr_bed:ffset_);
}
} class_rtProtoBED_hdr;

static class BEDclass : public TclClass {
public:
BEDclass() : TclClass("Agent/BED") {}
TclObject* create(int argc, const char*const* argv) {
assert(argc == 5);
return (new BED((nsaddr_t) Address::instance().str2addr(argv[4])));
}
} class_rtProtoBED;


int
BED::command(int argc, const char*const* argv) {
if(argc == 2) {
Tcl& tcl = Tcl::instance();











bed.h

#ifndef __bed_h__
#define __bed_h__
#define MAXI 1000
#include <cmu-trace.h>
#include <mobilenode.h>
#include <priqueue.h>
#include <classifier/classifier-port.h>
#include <mac/mac-802_11.h>

#define NETWORK_DIAMETER 64
#define DEFAULT_BEACON_INTERVAL 10 // seconds;
#define DEFAULT_ROUTE_EXPIRE 2*DEFAULT_BEACON_INTERVAL // seconds;
#define ROUTE_PURGE_FREQUENCY 2 // seconds

double dbr[MAXI];
double PT = 0.0;
float edd[MAXI];
float ddd[MAXI];
float energy_level[MAXI];
float delay_time[MAXI];
int nnn[MAXI];
double detax[MAXI];
double detay[MAXI];
int nodeno = 0;
int RFAC = 100;
int RLIMIT = 500;
int ORDER = 5;
int LIMS = 4;
bool cch[MAXI];
float TSL = 1.00;
float NSL = 0.00;
bool STAT = true;
int SFL=87;
int I = 0;
float WINSIZE = 1.2;
int TOTAL = 0;

#define ROUTE_FRESH 0x01
#define ROUTE_EXPIRED 0x02
#define ROUTE_FAILED 0x03

class BED;

// ======================================================================
// Timers : Beacon Timer, Route Cache Timer
// ======================================================================

class bedBeaconTimer : public Handler {
public:
bedBeaconTimer(BED* a) : agent(a) {}
void handle(Event*);
private:
BED *agent;
Event intr;
};

//
nsaddr_t next_hop(int xy){ return IP_BROADCAST;}


class bedRouteCacheTimer : public Handler {
public:
bedRouteCacheTimer(BED* a) : agent(a) {}
void handle(Event*);
private:
BED *agent;
Event intr;
};

// ======================================================================
// Route Cache Table
// ======================================================================
class RouteCache {
friend class BED;
public:
RouteCache(nsaddr_t bsrc, u_int32_t bid) { rt_dst = bsrc; rt_seqno = bid; }
protected:
LIST_ENTRY(RouteCache) rt_link;
u_int32_t rt_seqno; // route sequence number
nsaddr_t rt_dst; // route destination
nsaddr_t rt_nexthop; // next hop node towards the destionation
u_int32_t rt_xpos; // x position of destination;
u_int32_t rt_ypos; // y position of destination;
u_int8_t rt_state; // state of the route: FRESH, EXPIRED, FAILED (BROKEN)
u_int8_t rt_hopcount; // number of hops up to the destination (sink)
double rt_expire; // when route expires : Now + DEFAULT_ROUTE_EXPIRE

};
LIST_HEAD(bed_rtcache, RouteCache);



// ======================================================================
// BED Routing Agent : the routing protocol
// ======================================================================

class BED : public Agent {
friend class RouteCacheTimer;
friend class MobileNode;

public:
BED(nsaddr_t id);

void recv(Packet *p, Handler *);

int command(int, const char *const *);

// Agent Attributes
nsaddr_t index; // node address (identifier)
nsaddr_t seqno; // beacon sequence number (used only when agent is sink)

// Node Location
uint32_t posx; // position x;
uint32_t posy; // position y;
void decide_expel();
void decide_prox(MobileNode *tempn[],int num,int extra,int assigned);
void decide_proxb(MobileNode *tempn[],int num,int extra,int assigned);
MobileNode* search(double,double);
double nwpos(int pos);
double nwbpos(int pos);

// Routing Table Management
void rt_insert(nsaddr_t src, u_int32_t id, nsaddr_t nexthop, u_int32_t xpos, u_int32_t ypos, u_int8_t hopcount);
void rt_remove(RouteCache *rt);
void rt_purge();
RouteCache* rt_lookup(nsaddr_t dst);
void energy_scheme(struct hdr_bed_beacon* ,Packet * , struct hdr_ip *);
void delay_scheme(struct hdr_bed_beacon* , Packet *,struct hdr_ip *);
bool decide(int index);

// Remaining Energy
double iEnergy;


// Timers
bedBeaconTimer bcnTimer;
bedRouteCacheTimer rtcTimer;

// Caching Head
bed_rtcache rthead;

// Send Routines
void send_beacon();
void send_error(nsaddr_t unreachable_destination);
void forward(Packet *p, nsaddr_t nexthop, double delay);

// Recv Routines
void recv_data(Packet *p);
void recv_bed(Packet *p);
void recv_beacon(Packet *p);
void recv_error(Packet *p);

// Position Management
void update_position();

// Energy Management
void update_energy();

// This node;
MobileNode *iNode;

// 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;

// Port classifier for passing packets up to agents
PortClassifier *dmux_;

};

bool valid(float f)
{
if(f>1 || f<0) return false;
return true;
}


float abso(float num)
{
return num<0 ? -num : num;
}

double avg_(double a,double b)
{
return ( (a+b)/2.00 );
}

int scl()
{
return rand()%SFL;
}
#endif /* __bed_h__ */







bed_packet.h

#ifndef __bed_packet_h__
#define __bed_packet_h__

// ======================================================================
// Packet Formats: Beacon, Data, Error
// ======================================================================

#define BED_BEACON 0x01
#define BED_ERROR 0x02


// ======================================================================
// Direct access to packet headers
// ======================================================================

#define HDR_BED(p) ((struct hdr_bed*)hdr_bed::access(p))
#define HDR_BED_BEACON(p) ((struct hdr_bed_beacon*)hdr_bed::access(p))
#define HDR_BED_ERROR(p) ((struct hdr_bed_error*)hdr_bed::access(p))


// ======================================================================
// Default BED packet
// ======================================================================

struct hdr_bed {
u_int8_t pkt_type;

// header access
static int offset_;
inline static int& offset() { return offset_;}
inline static hdr_bed* access(const Packet *p) {
return (hdr_bed*) p->access(offset_);
}

};

// ======================================================================
// Beacon Packet Format
// ======================================================================

struct hdr_bed_beacon {
u_int8_t pkt_type; // type of packet : Beacon or Error
u_int8_t beacon_hops; // hop count, increadecreases as beacon is forwarded
u_int32_t beacon_id; // unique identifier for the beacon
nsaddr_t beacon_src; // source address of beacon, this is sink address
u_int32_t beacon_posx; // x position of beacon source, if available
u_int32_t beacon_posy; // y position of beacon source, if available

double timestamp; // emission time of beacon message

inline int size() {
int sz = 0;
sz = sizeof(struct hdr_bed_beacon);
assert(sz>=0);
return sz;
}
};

// =====================================================================
// Error Packet Format
// =====================================================================

struct hdr_bed_error {
u_int8_t pkt_type; // type of packet : Beacon or Error
u_int8_t reserved; // reserved for future use
nsaddr_t error_src; // error packet source node;
nsaddr_t urch_dst; // unreachable destination
double timestamp; // emission time

inline int size() {
int sz = 0;
sz = sizeof(struct hdr_bed_error);
assert(sz>=0);
return sz;
}
};


// For size calculation of header-space reservation
union hdr_all_bed {
hdr_bed bed;
hdr_bed_beacon beacon;
hdr_bed_error error;
};

#endif /* __bed_packet_h__ */
 
Old 01-25-2015, 11:29 PM   #11
vpchitraa
LQ Newbie
 
Registered: Jan 2015
Posts: 8

Original Poster
Rep: Reputation: Disabled
THanks knudfl. The code works now.

The problem is the line bed/bed.o \ is there in makefile but not reflected while install. I entered that line Makefile.in and followed ur step

/ns-allinone-2.35$./install

/ns-allinone-2.35/ns-2.35$ ./configure --with-tcl-ver=8.5.10 && make && sudo make install

ns-allinone-2.35/ns-2.35$ ns bed6.tcl

...

Coverage = 99.000000
HHH
4 4 12 3 4
4 9 4 4 5
8 4 4 4 4
3 6 4 3 6
5 4 4 4 4
Coverage = 97.000000
HHH
4 15 4 3 4
10 4 4 4 5
4 4 4 4 4
3 6 4 3 6
5 4 4 4 4
Coverage = 97.000000
HHH
21 4 4 3 4
4 4 4 4 5
4 4 4 4 4
3 6 4 3 6
5 4 4 4 4
Coverage = 97.000000
end simulation

Thank you so much for ur help
 
  


Reply

Tags
bed-ns2, ns2


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Make file error code 1 make: *** [AIQ7] Error 1 raju39k Linux - Newbie 2 04-09-2012 01:22 PM
RH9 make menuconfig error: make[1]: *** [lxdialog] Error 1 rrochele Linux - Kernel 3 02-07-2007 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration