drop packet accounting bug fix
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Wed May 06 19:06:09 2009 +0100 (9 months ago)
changeset 3964efdf773a79d0
parent 3963 00a6be12bcc3
child 3965 a71934a94f2b
drop packet accounting bug fix
examples/flowmon.py
src/contrib/flow-monitor/flow-monitor.cc
     1.1 --- a/examples/flowmon.py	Wed May 06 18:37:14 2009 +0100
     1.2 +++ b/examples/flowmon.py	Wed May 06 19:06:09 2009 +0100
     1.3 @@ -93,7 +93,7 @@
     1.4          #print i, destaddr
     1.5          onOffHelper.SetAttribute("Remote", ns3.AddressValue(ns3.InetSocketAddress(destaddr, port)))
     1.6          app = onOffHelper.Install(ns3.NodeContainer(node))
     1.7 -        app.Start(ns3.Seconds(ns3.UniformVariable(0.1, 1).GetValue()))
     1.8 +        app.Start(ns3.Seconds(ns3.UniformVariable(20, 30).GetValue()))
     1.9              
    1.10      #internet.EnablePcapAll("wifi-olsr")
    1.11      flowmon_helper = ns3.FlowMonitorHelper()
    1.12 @@ -136,7 +136,7 @@
    1.13                    st.packetSizeHistogram.GetBinEnd (i), "): ", st.packetSizeHistogram.GetBinCount (i)
    1.14  
    1.15          for reason, drops in enumerate(st.packetsDropped):
    1.16 -            print "Packets dropped by reason %i: %i" % (reason, drops)
    1.17 +            print "  Packets dropped by reason %i: %i" % (reason, drops)
    1.18          #for reason, drops in enumerate(st.bytesDropped):
    1.19          #    print "Bytes dropped by reason %i: %i" % (reason, drops)
    1.20  
     2.1 --- a/src/contrib/flow-monitor/flow-monitor.cc	Wed May 06 18:37:14 2009 +0100
     2.2 +++ b/src/contrib/flow-monitor/flow-monitor.cc	Wed May 06 19:06:09 2009 +0100
     2.3 @@ -219,13 +219,7 @@
     2.4      {
     2.5        return;
     2.6      }
     2.7 -  TrackedPacketMap::iterator tracked = m_trackedPackets.find (std::make_pair (flowId, packetId));
     2.8 -  if (tracked == m_trackedPackets.end ())
     2.9 -    {
    2.10 -      NS_LOG_WARN ("Received packet drop report (flowId=" << flowId << ", packetId=" << packetId
    2.11 -                   << ") but not known to be transmitted.");
    2.12 -      return;
    2.13 -    }
    2.14 +
    2.15    probe->AddPacketDropStats (flowId, packetSize, reasonCode);
    2.16  
    2.17    FlowStats &stats = GetStatsForFlow (flowId);
    2.18 @@ -237,12 +231,17 @@
    2.19      }
    2.20    ++stats.packetsDropped[reasonCode];
    2.21    stats.bytesDropped[reasonCode] += packetSize;
    2.22 +  NS_LOG_DEBUG ("++stats.packetsDropped[" << reasonCode<< "]; // becomes: " << stats.packetsDropped[reasonCode]);
    2.23  
    2.24 -  // we don't need to track this packet anymore
    2.25 -  // FIXME: this will not necessarily be true with broadcast/multicast
    2.26 -  NS_LOG_DEBUG ("ReportDrop: removing tracked packet (flowId="
    2.27 -                << flowId << ", packetId=" << packetId << ").");
    2.28 -  m_trackedPackets.erase (tracked);
    2.29 +  TrackedPacketMap::iterator tracked = m_trackedPackets.find (std::make_pair (flowId, packetId));
    2.30 +  if (tracked != m_trackedPackets.end ())
    2.31 +    {
    2.32 +      // we don't need to track this packet anymore
    2.33 +      // FIXME: this will not necessarily be true with broadcast/multicast
    2.34 +      NS_LOG_DEBUG ("ReportDrop: removing tracked packet (flowId="
    2.35 +                    << flowId << ", packetId=" << packetId << ").");
    2.36 +      m_trackedPackets.erase (tracked);
    2.37 +    }
    2.38  }
    2.39  
    2.40  std::map<FlowId, FlowMonitor::FlowStats>