A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::PcapHelper Class Reference

Manage pcap files for device models. More...

#include <trace-helper.h>

Public Types

enum  {
  DLT_NULL = 0, DLT_EN10MB = 1, DLT_PPP = 9, DLT_RAW = 101,
  DLT_IEEE802_11 = 105, DLT_PRISM_HEADER = 119, DLT_IEEE802_11_RADIO = 127
}
 

Public Member Functions

 PcapHelper ()
 Create a pcap helper. More...
 
 ~PcapHelper ()
 Destroy a pcap helper. More...
 
Ptr< PcapFileWrapperCreateFile (std::string filename, std::ios::openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0)
 Create and initialize a pcap file. More...
 
std::string GetFilenameFromDevice (std::string prefix, Ptr< NetDevice > device, bool useObjectNames=true)
 Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device. More...
 
std::string GetFilenameFromInterfacePair (std::string prefix, Ptr< Object > object, uint32_t interface, bool useObjectNames=true)
 Let the pcap helper figure out a reasonable filename to use for the pcap file associated with a node. More...
 
template<typename T >
void HookDefaultSink (Ptr< T > object, std::string traceName, Ptr< PcapFileWrapper > file)
 Hook a trace source to the default trace sink. More...
 

Static Private Member Functions

static void DefaultSink (Ptr< PcapFileWrapper > file, Ptr< const Packet > p)
 

Detailed Description

Manage pcap files for device models.

Handling pcap files is a common operation for ns-3 devices. It is useful to provide a common base class for dealing with these ops.

Definition at line 38 of file trace-helper.h.

Member Enumeration Documentation

anonymous enum
Enumerator
DLT_NULL 
DLT_EN10MB 
DLT_PPP 
DLT_RAW 
DLT_IEEE802_11 
DLT_PRISM_HEADER 
DLT_IEEE802_11_RADIO 

Definition at line 47 of file trace-helper.h.

Constructor & Destructor Documentation

ns3::PcapHelper::PcapHelper ( )

Create a pcap helper.

Definition at line 38 of file trace-helper.cc.

References NS_LOG_FUNCTION_NOARGS.

ns3::PcapHelper::~PcapHelper ( )

Destroy a pcap helper.

Definition at line 43 of file trace-helper.cc.

References NS_LOG_FUNCTION_NOARGS.

Member Function Documentation

Ptr< PcapFileWrapper > ns3::PcapHelper::CreateFile ( std::string  filename,
std::ios::openmode  filemode,
uint32_t  dataLinkType,
uint32_t  snapLen = 65535,
int32_t  tzCorrection = 0 
)

Create and initialize a pcap file.

Parameters
filenamefile name
filemodefile mode
dataLinkTypedata link type of packet data
snapLenmaximum length of packet data stored in records
tzCorrectiontime zone correction to be applied to timestamps of packets

Definition at line 49 of file trace-helper.cc.

References NS_ABORT_MSG_IF, and NS_LOG_FUNCTION.

Referenced by ns3::FdNetDeviceHelper::EnablePcapInternal(), ns3::EmuHelper::EnablePcapInternal(), ns3::PointToPointHelper::EnablePcapInternal(), ns3::CsmaHelper::EnablePcapInternal(), ns3::YansWifiPhyHelper::EnablePcapInternal(), ns3::WimaxHelper::EnablePcapInternal(), ns3::InternetStackHelper::EnablePcapIpv4Internal(), ns3::InternetStackHelper::EnablePcapIpv6Internal(), and main().

+ Here is the caller graph for this function:

void ns3::PcapHelper::DefaultSink ( Ptr< PcapFileWrapper file,
Ptr< const Packet p 
)
staticprivate

Definition at line 167 of file trace-helper.cc.

References ns3::Simulator::Now(), and NS_LOG_FUNCTION.

Referenced by HookDefaultSink().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::PcapHelper::GetFilenameFromDevice ( std::string  prefix,
Ptr< NetDevice device,
bool  useObjectNames = true 
)

Let the pcap helper figure out a reasonable filename to use for a pcap file associated with a device.

Parameters
prefixprefix string
deviceNetDevice
useObjectNamesuse node and device names instead of indexes

Definition at line 80 of file trace-helper.cc.

References ns3::Names::FindName(), ns3::Node::GetId(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.

Referenced by ns3::FdNetDeviceHelper::EnablePcapInternal(), ns3::EmuHelper::EnablePcapInternal(), ns3::PointToPointHelper::EnablePcapInternal(), ns3::CsmaHelper::EnablePcapInternal(), ns3::YansWifiPhyHelper::EnablePcapInternal(), and ns3::WimaxHelper::EnablePcapInternal().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::PcapHelper::GetFilenameFromInterfacePair ( std::string  prefix,
Ptr< Object object,
uint32_t  interface,
bool  useObjectNames = true 
)

Let the pcap helper figure out a reasonable filename to use for the pcap file associated with a node.

Parameters
prefixprefix string
objectinterface (such as Ipv4Interface or Ipv6Interface)
interfaceinterface id
useObjectNamesuse node and device names instead of indexes

Definition at line 125 of file trace-helper.cc.

References ns3::Names::FindName(), ns3::Node::GetId(), ns3::Object::GetObject(), NS_ABORT_MSG_UNLESS, and NS_LOG_FUNCTION.

Referenced by ns3::InternetStackHelper::EnablePcapIpv4Internal(), and ns3::InternetStackHelper::EnablePcapIpv6Internal().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename T >
void ns3::PcapHelper::HookDefaultSink ( Ptr< T >  object,
std::string  traceName,
Ptr< PcapFileWrapper file 
)

Hook a trace source to the default trace sink.

Parameters
objectobject
traceNametrace source name
filefile wrapper

Definition at line 114 of file trace-helper.h.

References DefaultSink(), ns3::MakeBoundCallback(), and NS_ASSERT_MSG.

Referenced by ns3::FdNetDeviceHelper::EnablePcapInternal(), ns3::EmuHelper::EnablePcapInternal(), ns3::PointToPointHelper::EnablePcapInternal(), and ns3::CsmaHelper::EnablePcapInternal().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


The documentation for this class was generated from the following files: