void ReceiveData(ns3::Ptr<ns3::Socket> socket) {
Ptr<Packet> msg = socket->Recv();
....
}
and later in the code, I have:
Ptr<Socket> data_sink;
....
data_sink->SetRecvCallback(MakeCallback(&ReceiveData));
So that ReceiveData is notified whenever the socket has packet
available to be read.
My plan is to update some local variables/storages each time a new
data packet is received. Imagine in a network, each node has its own
state, including data currently in possess, received data sequence
number etc. Each incoming data should cause a state change. But
apparently I could not pass extra arguments to ReceiveData via
callback, or I could, but don't know how to do that.
doxygen mentioned in ns3::Socket section:
SetRecvCallback (Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
Could anyone explain to me about how my ReceiveData could update local
variables?
Thanks a lot
Zhang Bo
class MyReceiver
{
public:
void RecvCallback (Ptr<Socket> sock);
private:
// private variables
};
MyReceiver receiver;
sock->SetRecvCallback (MakeCallback (&MyReceiver::RecvCallback, &receiver));
If you create the socket from a subclass of the Application class
(like OnOffApplication), you can easily set the RecvCallback to a
method of your application.
Mathieu
--
Mathieu Lacage <mathieu...@gmail.com>
Zhang Bo
On Apr 8, 4:47 pm, Mathieu Lacage <mathieu.lac...@gmail.com> wrote:
> Mathieu Lacage <mathieu.lac...@gmail.com>