Bug 563 - example/stats calling old callbacks
example/stats calling old callbacks
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: samples
ns-3-dev
All All
: P5 minor
Assigned To: ns-bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-05-09 09:44 UTC by Tommaso Pecorella
Modified: 2009-06-24 10:47 UTC (History)
2 users (show)

See Also:


Attachments
examples/stats patch described above (2.50 KB, patch)
2009-05-20 12:06 UTC, Tommaso Pecorella
Details | Diff
update the function signatures too (1.56 KB, patch)
2009-06-03 03:40 UTC, Mathieu Lacage
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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!