Bug 563 - example/stats calling old callbacks
: example/stats calling old callbacks
Status: RESOLVED FIXED
: ns-3
samples
: ns-3-dev
: All All
: P5 minor
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2009-05-09 09:44 EDT by
Modified: 2009-06-24 10:47 EDT (History)


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


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2009-05-09 09:44:26 EDT
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 From 2009-05-20 09:58:01 EDT -------
Can you please submit a patch for review?
Thanks
------- Comment #2 From 2009-05-20 12:06:31 EDT -------
Created an attachment (id=441) [details]
examples/stats patch described above

Sure thing, here is the patch file.

Cheers
------- Comment #3 From 2009-06-03 03:40:46 EDT -------
Created an attachment (id=451) [details]
update the function signatures too
------- Comment #4 From 2009-06-24 10:47:46 EDT -------
These fixes have been added to the main branch.  Thanks!