Bug 416

Summary: pcap traces not always closing cleanly at simulation end
Product: ns-3 Reporter: Tom Henderson <tomh>
Component: helpersAssignee: Craig Dowell <craigdo>
Status: RESOLVED INVALID    
Severity: normal CC: mathieu.lacage, ns-bugs
Priority: P1    
Version: ns-3-dev   
Hardware: All   
OS: All   
Attachments: start of a patch to fix this

Description Tom Henderson 2008-11-19 20:03:35 EST
Created attachment 308 [details]
start of a patch to fix this

I noticed some non-deterministic output in the pcap tracing while debugging something else, and I tracked it down to the fact that the destructor for PcapWriter is not being called in most cases, and the ofstream is not being flushed and closed.  

I saw some support in InternetStackHelper for scheduling a SimulatorDestroy() event to cleanup and close these ofstreams.  However, there are two problems that I see with that particular support:
- it tries to cause the destructor to be invoked by zeroing the smart pointer, but my testing suggests that this is not sufficient (hence I added an explicit Close() method in the attached patch)
- it only covers the case when EnablePcapAll() has been selected, but not when Pcap is enabled with finer granularity.

Attached is a start of a patch to try to fix this behavior, but it would need to be extended to all NetDevices (esp. WifiNetDevice) and it would need to cover all of the entry points into Pcap tracing (rather than just EnablePcapAll()).
Comment 1 Craig Dowell 2008-11-26 15:09:18 EST
This is due to a memory leak in dynamic-global-routing.cc that causes the pcap writer destructors not to be called.

Don't know what exactly is holding references, but there is a channel cycle that makes me nervous.