Public Member Functions | Static Public Member Functions

ns3::PcapFileWrapper Class Reference

Inheritance diagram for ns3::PcapFileWrapper:
Inheritance graph
[legend]
Collaboration diagram for ns3::PcapFileWrapper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

bool Fail (void) const
bool Eof (void) const
void Clear (void)
void Open (std::string const &filename, std::ios::openmode mode)
void Close (void)
void Init (uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits< uint32_t >::max(), int32_t tzCorrection=PcapFile::ZONE_DEFAULT)
void Write (Time t, Ptr< const Packet > p)
 Write the next packet to file.
void Write (Time t, Header &header, Ptr< const Packet > p)
 Write the provided header along with the packet to the pcap file.
void Write (Time t, uint8_t const *buffer, uint32_t length)
 Write the provided data buffer to the pcap file.
uint32_t GetMagic (void)
uint16_t GetVersionMajor (void)
uint16_t GetVersionMinor (void)
int32_t GetTimeZoneOffset (void)
uint32_t GetSigFigs (void)
uint32_t GetSnapLen (void)
uint32_t GetDataLinkType (void)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::PcapFileWrapper.

Member Function Documentation

void ns3::PcapFileWrapper::Clear ( void   ) 

Clear all state bits of the underlying iostream.

void ns3::PcapFileWrapper::Close ( void   ) 

Close the underlying pcap file.

bool ns3::PcapFileWrapper::Eof ( void   )  const
Returns:
true if the 'eof' bit is set in the underlying iostream, false otherwise.
bool ns3::PcapFileWrapper::Fail ( void   )  const
Returns:
true if the 'fail' bit is set in the underlying iostream, false otherwise.
static TypeId ns3::PcapFileWrapper::GetTypeId ( void   )  [static]

This method returns the TypeId associated to ns3::PcapFileWrapper.

This object is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/DeviceList/[i]/$ns3::AlohaNoackNetDevice/Phy/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/BsIpcsPacketClassifier/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/LinkManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/SSManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::BaseStationNetDevice/ServiceFlowManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::NonCommunicatingNetDevice/Phy/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/Classifier/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/LinkManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::SubscriberStationNetDevice/SSScheduler/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Channel/NoiseModel/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Channel/PropagationModel/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Mac/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Phy/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::UanNetDevice/Transducer/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/BsIpcsPacketClassifier/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/LinkManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/SSManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::BaseStationNetDevice/ServiceFlowManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/Classifier/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/LinkManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/$ns3::SubscriberStationNetDevice/SSScheduler/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/BandwidthManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/BurstProfileManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Channel/$ns3::UanChannel/NoiseModel/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Channel/$ns3::UanChannel/PropagationModel/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/ConnectionManager/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Phy/Channel/$ns3::UanChannel/NoiseModel/$ns3::PcapFileWrapper
  • /NodeList/[i]/DeviceList/[i]/$ns3::WimaxNetDevice/Phy/Channel/$ns3::UanChannel/PropagationModel/$ns3::PcapFileWrapper

Attributes defined for this type:

  • CaptureSize: Maximum length of captured packets (cf. pcap snaplen)

No TraceSources defined for this type.

Reimplemented from ns3::Object.

void ns3::PcapFileWrapper::Init ( uint32_t  dataLinkType,
uint32_t  snapLen = std::numeric_limits< uint32_t >::max(),
int32_t  tzCorrection = PcapFile::ZONE_DEFAULT 
)

Initialize the pcap file associated with this wrapper. This file must have been previously opened with write permissions.

Parameters:
dataLinkType A data link type as defined in the pcap library. If you want to make resulting pcap files visible in existing tools, the data link type must match existing definitions, such as PCAP_ETHERNET, PCAP_PPP, PCAP_80211, etc. If you are storing different kinds of packet data, such as naked TCP headers, you are at liberty to locally define your own data link types. According to the pcap-linktype man page, "well-known" pcap linktypes range from 0 to 177. If you use a large random number for your type, chances are small for a collision.
snapLen An optional maximum size for packets written to the file. Defaults to 65535. If packets exceed this length they are truncated.
tzCorrection An integer describing the offset of your local time zone from UTC/GMT. For example, Pacific Standard Time in the US is GMT-8, so one would enter -8 for that correction. Defaults to 0 (UTC).
Warning:
Calling this method on an existing file will result in the loss any existing data.
void ns3::PcapFileWrapper::Open ( std::string const &  filename,
std::ios::openmode  mode 
)

Create a new pcap file or open an existing pcap file. Semantics are similar to the stdc++ io stream classes.

Since a pcap file is always a binary file, the file type is automatically selected as a binary file (fstream::binary is automatically ored with the mode field).

Parameters:
filename String containing the name of the file.
mode String containing the access mode for the file.
void ns3::PcapFileWrapper::Write ( Time  t,
uint8_t const *  buffer,
uint32_t  length 
)

Write the provided data buffer to the pcap file.

Parameters:
t Packet timestamp as ns3::Time.
buffer The buffer to write.
length The size of the buffer.
void ns3::PcapFileWrapper::Write ( Time  t,
Ptr< const Packet p 
)

Write the next packet to file.

Parameters:
t Packet timestamp as ns3::Time.
p Packet to write to the pcap file.
void ns3::PcapFileWrapper::Write ( Time  t,
Header header,
Ptr< const Packet p 
)

Write the provided header along with the packet to the pcap file.

It is the case that adding a header to a packet prior to writing it to a file must trigger a deep copy in the Packet. By providing the header separately, we can avoid that copy.

Parameters:
t Packet timestamp as ns3::Time.
header The Header to prepend to the packet.
p Packet to write to the pcap file.

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