71 void Open(
const std::string& filename, std::ios::openmode mode);
110 bool swapMode =
false,
111 bool nanosecMode =
false);
277 static bool Diff(
const std::string& f1,
278 const std::string& f2,
317 uint8_t
Swap(uint8_t val);
323 uint16_t
Swap(uint16_t val);
A class representing a pcap file.
bool IsNanoSecMode()
Get the nanosecond mode of the file.
void Close()
Close the underlying file.
static bool Diff(const std::string &f1, const std::string &f2, uint32_t &sec, uint32_t &usec, uint32_t &packets, uint32_t snapLen=SNAPLEN_DEFAULT)
Compare two PCAP files packet-by-packet.
void Open(const std::string &filename, std::ios::openmode mode)
Create a new pcap file or open an existing pcap file.
uint32_t GetDataLinkType()
Returns the data link type field of the pcap file as defined by the network field in the pcap global ...
void Read(uint8_t *const data, uint32_t maxBytes, uint32_t &tsSec, uint32_t &tsUsec, uint32_t &inclLen, uint32_t &origLen, uint32_t &readLen)
Read next packet from file.
uint32_t GetMagic()
Returns the magic number of the pcap file as defined by the magic_number field in the pcap global hea...
uint16_t GetVersionMajor()
Returns the major version of the pcap file as defined by the version_major field in the pcap global h...
std::string m_filename
file name
uint16_t GetVersionMinor()
Returns the minor version of the pcap file as defined by the version_minor field in the pcap global h...
PcapFileHeader m_fileHeader
file header
void Clear()
Clear all state bits of the underlying iostream.
uint32_t WritePacketHeader(uint32_t tsSec, uint32_t tsUsec, uint32_t totalLen)
Write a Pcap packet header.
void Init(uint32_t dataLinkType, uint32_t snapLen=SNAPLEN_DEFAULT, int32_t timeZoneCorrection=ZONE_DEFAULT, bool swapMode=false, bool nanosecMode=false)
Initialize the pcap file associated with this object.
void Write(uint32_t tsSec, uint32_t tsUsec, const uint8_t *const data, uint32_t totalLen)
Write next packet to file.
uint32_t GetSnapLen()
Returns the max length of saved packets field of the pcap file as defined by the snaplen field in the...
bool GetSwapMode()
Get the swap mode of the file.
static const int32_t ZONE_DEFAULT
Time zone offset for current location.
bool m_nanosecMode
nanosecond timestamp mode
static const uint32_t SNAPLEN_DEFAULT
Default value for maximum octets to save per packet.
int32_t GetTimeZoneOffset()
Returns the time zone offset of the pcap file as defined by the thiszone field in the pcap global hea...
std::fstream m_file
file stream
void ReadAndVerifyFileHeader()
Read and verify a Pcap file header.
void WriteFileHeader()
Write a Pcap file header.
uint32_t GetSigFigs()
Returns the accuracy of timestamps field of the pcap file as defined by the sigfigs field in the pcap...
uint8_t Swap(uint8_t val)
Swap a value byte order.
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.