I have developed a new wireless application on directed diffusion and have
followed the necessary steps to integrate it into the ns code.but on
executing the command make ,it gives the following error:
Makefile:195:*** command commences before first target.Stop.
below i am attaching the files i have created for my application.
#include packet1_receiver.hh
#ifdef NS_DIFFUSION
static class Packet1ReceiverAppClass : public TclClass {
public:
Packet1ReceiverAppClass() : TclClass(Application/DiffApp/Packet1Receiver)
{}
TclObject* create(int , const char*const* ) {
return(new Packet1ReceiverApp());
}
} class_packet1_receiver;
int Packet1ReceiverApp::command(int argc, const char*const* argv) {
if (argc == 2) {
if (strcmp(argv[1], subscribe) == 0) {
run();
return TCL_OK;
}
}
return DiffApp::command(argc, argv);
}
#endif // NS_DIFFUSION
void Packet1ReceiverReceive::recv(NRAttrVec *data, NR::handle my_handle)
{
app_-recv(data, my_handle);
}
void Packet1ReceiverApp::recv(NRAttrVec *data, NR::handle my_handle)
{
NRSimpleAttributeint *counterAttr = NULL;
NRSimpleAttributevoid * *timeAttr = NULL;
EventTime *probe_event;
long delay_seconds;
long delay_useconds;
float total_delay;
struct timeval tmv;
GetTime(tmv);
counterAttr = AppCounterAttr.find(data);
timeAttr = TimeAttr.find(data);
if (!counterAttr || !timeAttr){
DiffPrint(DEBUG_ALWAYS, Received a BAD packet !\n);
PrintAttrs(data);
return;
}
// Calculate latency
probe_event = (EventTime *) timeAttr-getVal();
delay_seconds = tmv.tv_sec;
delay_useconds = tmv.tv_usec;
if ((delay_seconds probe_event-seconds_) ||
((delay_seconds == probe_event-seconds_)
(delay_useconds probe_event-useconds_))){
// Time's not synchronized
delay_seconds = -1;
delay_useconds = 0;
DiffPrint(DEBUG_ALWAYS, Error calculating delay !\n);
}
else{
delay_seconds = delay_seconds - probe_event-seconds_;
if (delay_useconds probe_event-useconds_){
delay_seconds--;
delay_useconds = delay_useconds + 100;
}
delay_useconds = delay_useconds - probe_event-useconds_;
}
total_delay = (float) (1.0 * delay_seconds) + ((float) delay_useconds /
100.0);
// Check if this is the first message received
if (first_msg_recv_ 0){
first_msg_recv_ = counterAttr-getVal();
}
// Print output message
if (last_seq_recv_ = 0){
if (counterAttr-getVal() last_seq_recv_){
// Multiple sources detected, disabling statistics
rp = 1;
last_seq_recv_ = -1;
DiffPrint(DEBUG_ALWAYS, Received data %d, total latency = %f!\n,
counterAttr-getVal(), total_delay);
}
else{
last_seq_recv_ = counterAttr-getVal();
num_msg_recv_++;
DiffPrint(DEBUG_ALWAYS, Received data: %d, total latency = %f, %%
messages received: %f !\n,
last_seq_recv_, total_delay,
(float) ((num_msg_recv_ * 100.00) /
((last_seq_recv_ - first_msg_recv_) + 1)));
}
}
else{
DiffPrint(DEBUG_ALWAYS, Received data %d, total latency = %f !\n,
counterAttr-getVal(), total_delay);
}
}
handle Packet1ReceiverApp::setupSubscription()
{
NRAttrVec attrs;
path_ = 0;
attrs.push_back(NRClassAttr.make(NRAttribute::IS,
NRAttribute::INTEREST_CLASS));
attrs.push_back(LatitudeAttr.make(NRAttribute::GT, 54.78));
attrs.push_back(LongitudeAttr.make(NRAttribute::LE, 87.32));
attrs.push_back(TargetAttr.make(NRAttribute::IS, F117A));
handle h = dr_-subscribe(attrs, mr_);
ClearAttrs(attrs);
return h;
}
void Packet1ReceiverApp::run()
{
subHandle_ = setupSubscription();
#ifndef NS_DIFFUSION
// Do nothing
while (1){
sleep(1000);
}
#endif // !NS_DIFFUSION
}
#ifdef NS_DIFFUSION
Packet1ReceiverApp::Packet1ReceiverApp()
#else
Packet1ReceiverApp::Packet1ReceiverApp(int argc, char **argv)
#endif // NS_DIFFUSION
{
last_seq_recv_ = 0;
num_msg_recv_ = 0;
first_msg_recv_ = -1;
mr_ = new Packet1ReceiverReceive(this);
#ifndef NS_DIFFUSION
parseCommandLine(argc, argv);
dr_ = NR::createNR(diffusion_port_);
#endif // !NS_DIFFUSION
}
#ifndef NS_DIFFUSION
int main(int argc, char **argv)
{
Packet1ReceiverApp *app;
app = new Packet1ReceiverApp(argc, argv);
app-run();
return 0;
}
#endif // !NS_DIFFUSION
#ifndef _PACKET1_RECEIVER_HH_
#define _PACKET1_RECEIVER_HH_
#ifdef HAVE_CONFIG_H
#include config.h
#endif // HAVE_CONFIG_H
#include ping.hh
class Packet1ReceiverReceive;
class Packet1ReceiverApp : public DiffApp {
public:
#ifdef NS_DIFFUSION
Packet1ReceiverApp();
int command(int argc, const char*const* argv);
#else
Packet1ReceiverApp(int argc, char **argv);
#endif // NS_DIFFUSION
void recv(NRAttrVec *data, NR::handle my_handle);
void run();
private:
// NR Specific variables
Packet1ReceiverReceive *mr_;
handle subHandle_;
// Packet1 App variables
int last_seq_recv_;
int num_msg_recv_;