Bug 563

Summary: example/stats calling old callbacks
Product: ns-3 Reporter: Tommaso Pecorella <tommaso.pecorella>
Component: samplesAssignee: ns-bugs <ns-bugs>
Status: RESOLVED FIXED    
Severity: minor CC: mathieu.lacage, tjkopena
Priority: P5    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: examples/stats patch described above
update the function signatures too

Description Tommaso Pecorella 2009-05-09 09:44:26 UTC
In file examples/stats/wifi-example-sim.cc:

line 204:
  Config::Connect("/NodeList/0/DeviceList/*/$ns3::WifiNetDevice/Tx",
                  MakeBoundCallback(&TxCallback, totalTx));

line 215:
  Config::Connect("/NodeList/1/DeviceList/*/$ns3::WifiNetDevice/Rx",
                  MakeCallback(&PacketCounterCalculator::FrameUpdate,
                                    totalRx));


The callbacks aren't anymore there. As a result the counted values are zero.

My best solution is to bind those to:
$ns3::WifiNetDevice/Mac/MacTx
and
$ns3::WifiNetDevice/Mac/MacRx
respectively.

Moreover in examples/stats/wifi-example-apps.cc, in the function Receiver::Receive(Ptr<Socket> socket) there is no check if the TimeTag is present or not. Impossible? Not really, there's another bug somewhere, but it will be covered in another ticket.

I'd change the function into this:

void
Receiver::Receive(Ptr<Socket> socket)
{
  // NS_LOG_FUNCTION (this << socket << packet << from);

  Ptr<Packet> packet;
  Address from;
  while (packet = socket->RecvFrom(from)) {
    if (InetSocketAddress::IsMatchingType (from)) {
      InetSocketAddress address = InetSocketAddress::ConvertFrom (from);
      NS_LOG_INFO ("Received " << packet->GetSize() << " bytes from " << 
                   address.GetIpv4());
    }

    TimestampTag timestamp;
    if( packet->FindFirstMatchingTag(timestamp) ) {
      Time tx = timestamp.GetTimestamp();
      
      if (m_delay != 0) {
        m_delay->Update(Simulator::Now() - tx);
      }
    }
    else {
      NS_LOG_INFO ("** missing time tag **");
    }
    
    if (m_calc != 0) {
      m_calc->Update();
    }

    // end receiving packets
  }

  // end Receiver::Receive
}
Comment 1 Faker Moatamri 2009-05-20 09:58:01 UTC
Can you please submit a patch for review?
Thanks
Comment 2 Tommaso Pecorella 2009-05-20 12:06:31 UTC
Created attachment 441 [details]
examples/stats patch described above

Sure thing, here is the patch file.

Cheers
Comment 3 Mathieu Lacage 2009-06-03 03:40:46 UTC
Created attachment 451 [details]
update the function signatures too
Comment 4 Joe Kopena 2009-06-24 10:47:46 UTC
These fixes have been added to the main branch.  Thanks!