Package: inet.common.packet.recorder
PcapRecorder
simple moduleRecords PCAP traces of frames sent/received by other modules within the same host. By default, it records frames sent/received by L2 modules of ~StandardHost and ~Router(1,2). The output filename is expected in the pcapFile parameter. The PcapRecorder module can also print tcpdump-like textual information on the log (EV); this functionality can be controlled by the verbose parameter.
<b>Which modules to record:</b> The list of modules can be specified in the moduleNamePatterns parameter. It is a space-separated list of module names, which will be interpreted as children of the PcapRecorder's parent module. To record elements of a module vector, add "[*]" to the name (example: "eth[*]").
<b>Operation:</b> PcapRecorder adds signal listeners to the recorded modules. The signals subscribed to are packetSentToLower and packetReceivedFromLower, but these names can be overridden with the sendingSignalNames and receivingSignalNames parameters. The packets themselves are expected as cPacket* signal values.
Inheritance diagram
The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.
Used in compound modules
| Name | Type | Description |
|---|---|---|
| EthernetSwitch | compound module |
EthernetSwitch models a Layer 2 Ethernet switch with support for various IEEE 802.1 protocols and features. It provides frame forwarding based on MAC addresses and implements multiple switching technologies. |
| LinkLayerNodeBase | compound module |
An extension of the basic node infrastructure with link layer functionality. Provides support for various network interfaces and link layer protocols, forming the foundation for network connectivity. |
| NetworkInterface | compound module |
Serves as the base module for all network interfaces. |
Used in
| Name | Type | Description |
|---|---|---|
| BGP_Basic_Topology | network | (no description) |
| BGP_LOCAL_PREF | network | (no description) |
| BGP_Topology_1 | network | (no description) |
| BGP_Topology_1a | network | (no description) |
| BGP_Topology_2 | network | (no description) |
| BGP_Topology_3 | network | (no description) |
| BGP_Topology_4 | network | (no description) |
| Freshness | network | (no description) |
| InterfaceNetworkType | network | (no description) |
| Multihop_EBGP | network | (no description) |
| Network | network | (no description) |
| Network2 | network | (no description) |
| NetworkBase | network | (no description) |
| OSPF_Area_External_Forwarding | network | (no description) |
| OSPF_AreaTest | network | (no description) |
| OSPF_Default_Route_Distribution | network | (no description) |
| OSPF_LoopAvoidance | network | (no description) |
| OSPF_Route_Selection | network | (no description) |
| OSPF_Suboptimal | network | (no description) |
| OSPF_Summary_LSA | network | (no description) |
| OspfNetwork | network | (no description) |
| RouterLSA | network | (no description) |
| TopologyChange | network | (no description) |
| VirtualLink | network | (no description) |
| VirtualLink_2 | network | (no description) |
Extends
| Name | Type | Description |
|---|---|---|
| SimpleModule | simple module |
Base module for all INET simple modules. |
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
| displayStringTextFormat | string | "rec: %n pks" |
Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information |
| verbose | bool | true |
Whether to log packets on the module output |
| recordEmptyPackets | bool | true |
Specifies if zero length packets are recorded or not |
| enableConvertingPackets | bool | true |
Specifies if converting packets to link type is allowed or not |
| pcapFile | string | "" |
The PCAP file to be written, suggested value: pcapFile = "${resultdir}/${configname}-#${runnumber}" + fullpath() + ".pcap" |
| fileFormat | string | "pcapng" | |
| snaplen | int | 65535 |
Maximum number of bytes to record per packet |
| timePrecision | int | 6 |
Time precision in recorded file. pcap supports only 6 (usec) or 9 (nanosec), pcapng supports more values (see 'if_tsresol' option in pcapng file format). |
| dumpBadFrames | bool | true |
Enable dump of frames with hasBitError |
| moduleNamePatterns | string | "wlan[*] eth[*] ppp[*]" |
Space-separated list of sibling module names to listen on |
| sendingSignalNames | string | "transmissionEnded" |
Space-separated list of outbound packet signals to subscribe to |
| receivingSignalNames | string | "receptionEnded" |
Space-separated list of inbound packet signals to subscribe to |
| dumpProtocols | string | "ethernetmac ppp ieee80211mac" |
Space-separated list of protocol names as defined in the Protocol class |
| packetFilter | object | "*" |
Which packets are considered, matches all packets by default |
| helpers | string | "" |
Usable PcapRecorder::IHelper helpers for accept packettype and store/convert packet as specified linktype currently available: "inet::AckingMacToEthernetPcapRecorderHelper" |
| alwaysFlush | bool | false |
Flush the pcapFile after each write to ensure that all packets are captured in case of a crash |
Properties
| Name | Value | Description |
|---|---|---|
| class | PcapRecorder | |
| display | i=block/blackboard |
Signals
| Name | Type | Unit | Description |
|---|---|---|---|
| packetRecorded | Packet |
Source code
// // Records PCAP traces of frames sent/received by other modules within // the same host. By default, it records frames sent/received by L2 modules // of ~StandardHost and ~Router. The output filename is expected in the // `pcapFile` parameter. The `PcapRecorder` module can also print tcpdump-like // textual information on the log (EV); this functionality can be // controlled by the verbose parameter. // // <b>Which modules to record:</b> The list of modules can be specified in // the `moduleNamePatterns` parameter. It is a space-separated list of module // names, which will be interpreted as children of the `PcapRecorder`'s parent // module. To record elements of a module vector, add "[*]" to the name // (example: "eth[*]"). // // <b>Operation:</b> `PcapRecorder` adds signal listeners to the recorded // modules. The signals subscribed to are `packetSentToLower` and // `packetReceivedFromLower`, but these names can be overridden with the // `sendingSignalNames` and `receivingSignalNames` parameters. The packets // themselves are expected as `cPacket*` signal values. // simple PcapRecorder extends SimpleModule { parameters: @class(PcapRecorder); bool verbose = default(true); // Whether to log packets on the module output bool recordEmptyPackets = default(true); // Specifies if zero length packets are recorded or not bool enableConvertingPackets = default(true); // Specifies if converting packets to link type is allowed or not string pcapFile = default(""); // The PCAP file to be written, suggested value: pcapFile = "${resultdir}/${configname}-#${runnumber}" + fullpath() + ".pcap" string fileFormat @enum("pcap","pcapng") = default("pcapng"); int snaplen = default(65535); // Maximum number of bytes to record per packet int timePrecision = default(6); // Time precision in recorded file. pcap supports only 6 (usec) or 9 (nanosec), pcapng supports more values (see 'if_tsresol' option in pcapng file format). bool dumpBadFrames = default(true); // Enable dump of frames with hasBitError string moduleNamePatterns = default("wlan[*] eth[*] ppp[*]"); // Space-separated list of sibling module names to listen on string sendingSignalNames = default("transmissionEnded"); // Space-separated list of outbound packet signals to subscribe to string receivingSignalNames = default("receptionEnded"); // Space-separated list of inbound packet signals to subscribe to string dumpProtocols = default("ethernetmac ppp ieee80211mac"); // Space-separated list of protocol names as defined in the Protocol class object packetFilter = default("*"); // Which packets are considered, matches all packets by default string helpers = default(""); // Usable PcapRecorder::IHelper helpers for accept packettype and store/convert packet as specified linktype // currently available: "inet::AckingMacToEthernetPcapRecorderHelper" bool alwaysFlush = default(false); // Flush the pcapFile after each write to ensure that all packets are captured in case of a crash displayStringTextFormat = default("rec: %n pks"); @display("i=block/blackboard"); @signal[packetRecorded](type=Packet); }File: src/inet/common/packet/recorder/PcapRecorder.ned