Base Class: Adapter
| Purpose |
Allow for the injection of libcap-based traffic into the framework |
The
AdapterFile object emulates an adapter in the
ScaleBox framework to provide replay of tcpdump files (libpcap format) similar to
tcpreplay. Similar to the normal pcap-based adapter, the file adapter can have its own chain of modules with respect to both the input and output aspects. Future planned modules include remapping modules to allow for layer 2, layer 3, and layer 4 translation of previous packets into a new virtual network.
Example Declaration (see readDumpFile.xml
<Adapter type="file">
<name>fileAdapter</name>
<file>../test/file/testFile.tcpdump</file>
<!-- Start the input module chain -->
<InputModule type="InputLog">
</InputModule>
<!-- We really don't want to send it, just to see the packets -->
<InputModule type="InputPurge">
</InputModule>
<!-- Start the output module chain -->
<OutputModule type="OutputPurge">
</OutputModule>
</Adapter>
In the above example, an
AdapterFile file object is defined under the name of
fileAdapter. The adapter will read in the file testFile.tcpdump (contained in the
ScaleBox distribution for testing) and play it back at normal speed across its input chain which contains only a call to the simple logging function. The remainder of the packets are purged via the
InputPurge module listed in the chain shortly after the logging module. The adapter can queue up a list of files that will then be played back in sequential order as per the relative timing specified in each of the files.
Note that the adapter class will do its best to play back packets at the specified rate. Depending upon the load of the system and other processes, it may not be possible to meet the exact playback criterion specified by the file.
processPacket (InputLog)
IL(fileAdapter): 0x80E400 66 bytes IPv4 129.74.153.157 to 129.74.227.102
processPacket (InputLog)
IL(fileAdapter): 0x809400 66 bytes IPv4 129.74.227.102 to 129.74.153.157
processPacket (InputLog)
IL(fileAdapter): 0x809E00 78 bytes IPv4 129.74.153.157 to 129.74.227.102
processPacket (InputLog)
IL(fileAdapter): 0x80A800 74 bytes IPv4 129.74.227.102 to 129.74.153.157
processPacket (InputLog)
IL(fileAdapter): 0x80B200 66 bytes IPv4 129.74.153.157 to 129.74.227.102
processPacket (InputLog)
IL(fileAdapter): 0x808000 77 bytes IPv4 129.74.153.157 to 129.74.250.100
Tags
The following tags (in addition to the base Adapter tags) are recognized by the adapter when processing the XML configuration file.
|
Tag |
Description |
Values |
Note
| file |
A file name relative to the path for the adapter |
Single valid UNIX filename |
|
| filePath |
Modifier to the search path for playback files |
Absolute or modifier for path |
To be added |
| playbackRate |
The relative rate to apply to the playback |
Accelerate (< 1) or decelerate (< 1) packet gaps |
To be added |
| loopCount |
The number of times to loop through the files |
0 = Loop infinitely, default = 1 |
To be added |
Tag - file
<file>../test/file/testFile.tcpdump</file>
The
file tag contains a single file listing that will be added to the replay list. By default, the file will be replayed at the same rate as recorded by libpcap.
Tag - filePath
<filePath>/zfs/filedumps/</filePath>
Tag - playbackRate
<playbackRate >0.5</playbackRate >
Tag - loopCount
<loopCount >5</loopCount >
Special Notes
- When rolling between files, relative times are not preserved for the first packet in each new file, i.e. if the adapter finishes playing back file 1 and opens up file 2, the first packet of file 2 will not be replayed relative to the timeline of file 1.
- The adapter will not fill in missing data when the capture length is not the same as the actual length. Packets that do not have the entirety of their data will be ignored for the time being to avoid adverse impacts on downstream processing.