typedef Callback<bool,Ptr<NetDevice>,Ptr<const Packet>,uint16_t,const Address &> ReceiveCallback;
NetDevice::ReceiveCallback m_rxCallback;
m_rxCallback (this, packet, protocol, GetRemote ());
void
PointToPointNetDevice::SetReceiveCallback (NetDevice::ReceiveCallback cb)
{
m_rxCallback = cb;
}
uint32_t Node::AddDevice (Ptr<NetDevice> device)
{
NS_LOG_FUNCTION (this << device);
uint32_t index = m_devices.size ();
m_devices.push_back (device);
device->SetNode (this);
device->SetIfIndex (index);
device->SetReceiveCallback (MakeCallback (&Node::NonPromiscReceiveFromDevice, this));
Simulator::ScheduleWithContext (GetId (), Seconds (0.0),
&NetDevice::Initialize, device);
NotifyDeviceAdded (device);
return index;
}
node->RegisterProtocolHandler (MakeCallback (&Ipv4L3Protocol::Receive, this),
Ipv4L3Protocol::PROT_NUMBER, device);
Simulator::ScheduleWithContext (GetId (), Seconds (0.0), &NetDevice::Initialize, device);
NotifyDeviceAdded (device);
void myfunc()
{
std::cout << "Packet arrived!" << std::endl;
}NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
Config::ConnectWithoutContext("MacTx",MakeCallback(&myfunc));
assert failed. cond="slash != std::string::npos", file=../src/core/model/config.cc, line=518
terminate called without an active exception
Command
['/home/rng/repos/ns-3-allinone/ns-3.20/build/scratch/first']
terminated with signal SIGIOT. Run it under a debugger to get more
information (./waf --run <program> --command-template="gdb --args
%s <args>").
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
Config::ConnectWithoutContext("MacTx",MakeCallback(&myfunc));
My understanding is that whenever the trace source is fired, myfunc() should get called. I believe that makecallback will create a pointer to myfunc which will be used to call the function and when myfunc() is called the statement "Packet arrived!" should get printed.
However, I get this error message:
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
Config::ConnectWithoutContext("MacTx",MakeCallback(&myfunc));
My understanding is that whenever the trace source is fired, myfunc() should get called. I believe that makecallback will create a pointer to myfunc which will be used to call the function and when myfunc() is called the statement "Packet arrived!" should get printed.
However, I get this error message:
Ok. Thanks. There's no error message now. But myfunc() is still not called. I tried rest of the trace sources as well such as PhyRxEnd, PhyTxBegin and so on but myfunc() is still not called.Peshal
On Mon, Jun 15, 2015 at 3:01 PM, Peter Barnes <pd...@mac.com> wrote:
I think your config path is incomplete. It should probably by something like"/NodeList/0/$PointToPointNetDevice/MacTx"PeterSee the tutorial and manual sections:On Jun 14, 2015, at 2:45 PM, Peshal Nayak <pesha...@gmail.com> wrote:NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
Config::ConnectWithoutContext("MacTx",MakeCallback(&myfunc));
My understanding is that whenever the trace source is fired, myfunc() should get called. I believe that makecallback will create a pointer to myfunc which will be used to call the function and when myfunc() is called the statement "Packet arrived!" should get printed.
However, I get this error message:
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
I'm still not able to figure out why this is happenning. Can anyone please help me out?
Peshal
On Monday, June 15, 2015 at 3:34:58 PM UTC-5, Peshal Nayak wrote:
Ok. Thanks. There's no error message now. But myfunc() is still not called. I tried rest of the trace sources as well such as PhyRxEnd, PhyTxBegin and so on but myfunc() is still not called.Peshal
On Mon, Jun 15, 2015 at 3:01 PM, Peter Barnes <pd...@mac.com> wrote:
I think your config path is incomplete. It should probably by something like"/NodeList/0/$PointToPointNetDevice/MacTx"PeterSee the tutorial and manual sections:On Jun 14, 2015, at 2:45 PM, Peshal Nayak <pesha...@gmail.com> wrote:NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
Config::ConnectWithoutContext("MacTx",MakeCallback(&myfunc));
My understanding is that whenever the trace source is fired, myfunc() should get called. I believe that makecallback will create a pointer to myfunc which will be used to call the function and when myfunc() is called the statement "Packet arrived!" should get printed.
However, I get this error message:
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
./waf --run scratch/ns3user
Waf: Entering directory `/Users/ntinos/ns3/ns-3.22/build'
Waf: Leaving directory `/Users/ntinos/ns3/ns-3.22/build'
'build' finished successfully (2.691s)
At time 2s client sent 1024 bytes to 10.1.1.2 port 9
At time 2.00369s server received 1024 bytes from 10.1.1.1 port 49153
At time 2.00369s server sent 1024 bytes to 10.1.1.1 port 49153
I was called
At time 2.00737s client received 1024 bytes from 10.1.1.2 port 9
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
Could you please attach the modified code? I need to check what I missed. I know this sounds stupid, but I need to be sure that I've set up everything in the right way. I'm not getting the output "I was called" when I run the code.
Peshal
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/xJiWTsfxtQo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.