36 * Log Packets to a file in pcap format which can be |
36 * Log Packets to a file in pcap format which can be |
37 * read by pcap readers. |
37 * read by pcap readers. |
38 */ |
38 */ |
39 class PcapWriter { |
39 class PcapWriter { |
40 public: |
40 public: |
41 PcapWriter (); |
41 PcapWriter (); |
42 ~PcapWriter (); |
42 ~PcapWriter (); |
43 |
43 |
44 /** |
44 /** |
45 * \param name the name of the file to store packet log into. |
45 * \param name the name of the file to store packet log into. |
46 * This method creates the file if it does not exist. If it |
46 * This method creates the file if it does not exist. If it |
47 * exists, the file is emptied. |
47 * exists, the file is emptied. |
48 */ |
48 */ |
49 void Open (char const *name); |
49 void Open (char const *name); |
50 |
50 |
51 /** |
51 /** |
52 * Write a pcap header in the output file which specifies |
52 * Write a pcap header in the output file which specifies |
53 * that the content of the file will Packets with |
53 * that the content of the file will Packets with |
54 * Ethernet/LLC/SNAP encapsulation. This method should |
54 * Ethernet/LLC/SNAP encapsulation. This method should |
55 * be invoked before ns3::PcapWriter::writePacket and after |
55 * be invoked before ns3::PcapWriter::writePacket and after |
56 * ns3::PcapWriter::open. |
56 * ns3::PcapWriter::open. |
57 */ |
57 */ |
58 void WriteHeaderEthernet (void); |
58 void WriteHeaderEthernet (void); |
59 |
59 |
60 /** |
60 /** |
61 * \param packet packet to write to output file |
61 * \param packet packet to write to output file |
62 */ |
62 */ |
63 void WritePacket (Packet const packet); |
63 void WritePacket (Packet const packet); |
64 |
64 |
65 private: |
65 private: |
66 void WriteData (uint8_t *buffer, uint32_t size); |
66 void WriteData (uint8_t *buffer, uint32_t size); |
67 void Write32 (uint32_t data); |
67 void Write32 (uint32_t data); |
68 void Write16 (uint16_t data); |
68 void Write16 (uint16_t data); |
69 SystemFile *m_writer; |
69 SystemFile *m_writer; |
70 Callback<void,uint8_t *,uint32_t> m_writeCallback; |
70 Callback<void,uint8_t *,uint32_t> m_writeCallback; |
71 }; |
71 }; |
72 |
72 |
73 }; // namespace ns3 |
73 }; // namespace ns3 |
74 |
74 |
75 #endif /* PCAP_WRITER_H */ |
75 #endif /* PCAP_WRITER_H */ |