PcapRecorder

Package: inet.common.packet.recorder

PcapRecorder

simple module

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 to on the log (EV); this functionality can be controlled by the verbose parameter.

Which modules to record: The list of modules can to 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[*]").

Operation: 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.

Used in compound modules

Name Type Description
EthernetSwitch compound module

Model of an Ethernet switch.

LinkLayerNodeBase compound module (no description)
NetworkInterface compound module

This module serves as the base module for all network interfaces.

Used in

Name Type Description
NetworkBase network (no description)

Parameters

Name Type Default value Description
verbose bool true

whether to log packets on the module output

pcapFile string ""

the PCAP file to be written

fileFormat string "pcapng"
snaplen int 65535

maximum number of bytes to record per packet

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 "packetSentToLower"

space-separated list of outbound packet signals to subscribe to

receivingSignalNames string "packetReceivedFromLower"

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

displayStringTextFormat string "rec: %n pks"

Properties

Name Value Description
display i=block/blackboard

Signals

Name Type Unit
packetRecorded Packet

Called methods (observed)

functioninfocall from
inet::PcapRecorder::receiveSignalpacketReceivedFromLowerAckingMac, BMac, CsmaCaMac, EthernetMac, Ieee80211Mac, Ieee802154Mac, LMac, Ppp, XMac, Ipv4, EthernetPhyHeaderChecker, ApskDimensionalRadio, ApskScalarRadio, Ieee80211DimensionalRadio, Ieee80211ScalarRadio, UnitDiskRadio, DestreamingReceiver, PacketReceiver, PacketClassifier, Udp
inet::PcapRecorder::receiveSignalpacketSentToLowerEthernetMac, Ieee80211Mac, Ppp, InterpacketGapInserter, InstantServer, Udp

Packet operations (observed)

chunkTypepacketAction
peekData, peekDataAsBytes, setBackOffset, setFrontOffset, trimFront
AckingMacHeaderpopAtFront
ArpPacketpopAtFront
ChunkpopAtFront
EthernetFcspopAtBack
EthernetMacHeaderinsertAtFront, popAtFront
IcmpHeaderpopAtFront
Ipv4HeaderpopAtFront
TcpHeaderpopAtFront

Shared Tagging operations (observed)

tagTypetagAction
InterfaceIndfindTag
InterfaceReqfindTag
PacketProtocolTagaddTagIfAbsent, findTag, getTag

Tagging operations (observed)

tagTypetagAction
inet::Ipv4InterfaceDatafindTag

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 to on the log (EV); this functionality can be
// controlled by the verbose parameter.
//
// <b>Which modules to record:</b> The list of modules can to 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
{
    parameters:
        bool verbose = default(true);  // whether to log packets on the module output
        string pcapFile = default(""); // the PCAP file to be written
        string fileFormat @enum("pcap","pcapng") = default("pcapng");
        int snaplen = default(65535);  // maximum number of bytes to record per packet
        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("packetSentToLower"); // space-separated list of outbound packet signals to subscribe to
        string receivingSignalNames = default("packetReceivedFromLower"); // 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
        string displayStringTextFormat = default("rec: %n pks");
        @display("i=block/blackboard");
        @signal[packetRecorded](type=Packet);
}

File: src/inet/common/packet/recorder/PcapRecorder.ned