Sérgio Sousa
unread,Feb 9, 2011, 2:02:02 PM2/9/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ns-3-users
Hello,
i'm trying to implement a ACK mechanism, using SetReceivePacket
Callback. When a node that have the callback defined receive a data
packet, i would like it to send a smaller packet to the source node of
the first packet (send it an Ack). For that i use this code to define
the callback:
TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
Ptr<Socket> recvSink = Socket::CreateSocket (wifiStaNodes.Get (i),
tid);
InetSocketAddress local = InetSocketAddress (interfaces.GetAddress(i),
9);
recvSink->Bind (local);
recvSink->SetRecvCallback (MakeCallback (&ReceivePacket));
And inside the callback method (ReceivePacket) i do this:
OnOffHelper onoffd ("ns3::UdpSocketFactory",Address (InetSocketAddress
(ipv4From, 9)));
onoffd.SetAttribute ("OnTime", RandomVariableValue
(ConstantVariable(1)));
onoffd.SetAttribute ("OffTime", RandomVariableValue
(ConstantVariable(0)));
onoffd.SetAttribute ("PacketSize", StringValue("10"));
onoffd.SetAttribute ("MaxBytes", UintegerValue (10));
Ptr<Node> appSource = NodeList::GetNode (buf_to[3]-1);
ApplicationContainer appsd;
appsd = onoffd.Install (appSource);
appsd.Start (Simulator::Now());
appsd.Stop (ns3::Seconds (1.005));
The weird thing is that if I DON'T use these two lines:
"appsd.Start (Simulator::Now());
appsd.Stop (ns3::Seconds (1.005));"
the packets ARE SENT ANYWAY, and i don't want that because i need to
control the start and the end of sending.
If i use this to lines, it looks like it overlaps the sending that
supposelly happens without these lines, and everything fails, the
wireless medium does not check for iddle moments to transmit and the
packets are sent very late in the simulation.
I can tell that the line that makes the sending the happen without the
start method is:
"appsd = onoffd.Install (appSource);"
but that does not start any sending when i use this same methodology
earlier in the simulation (to send the first packet), with the only
difference that is not used inside the callback method and that way
everything works just fine.
I would really appreciate a help here.
Best Regards
Sérgio Sousa