Mercurial > stress-tester
changeset 1075:c3bcec472408
PcapUnidirectionalRawPacketWorker.dumpFile
author | Devel 2 |
---|---|
date | Tue, 28 Apr 2020 15:20:57 +0200 |
parents | a5236d71d2ca |
children | 992057a5cc68 |
files | stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketWorker.java |
diffstat | 1 files changed, 25 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketWorker.java Tue Apr 28 15:14:00 2020 +0200 +++ b/stress-tester/src/main/java/com/passus/st/emitter/raw/PcapUnidirectionalRawPacketWorker.java Tue Apr 28 15:20:57 2020 +0200 @@ -1,6 +1,8 @@ package com.passus.st.emitter.raw; +import com.passus.config.schema.MapNodeDefinition; import com.passus.pcap.Pcap; +import com.passus.pcap.PcapDumper; import com.passus.pcap.PcapIfc; import org.apache.commons.lang3.SystemUtils; @@ -11,10 +13,23 @@ import java.util.HashMap; import java.util.Map; +import static com.passus.config.schema.ConfigurationSchemaBuilder.tupleDef; +import static com.passus.config.schema.ConfigurationSchemaBuilder.valueDef; + class PcapUnidirectionalRawPacketWorker extends UnidirectionalRawPacketWorker<PcapOutput> { private final Map<String, PcapInstance> pcaps = new HashMap<>(); + private String dumpFile; + + public String getDumpFile() { + return dumpFile; + } + + public void setDumpFile(String dumpFile) { + this.dumpFile = dumpFile; + } + protected String resolveDevice(NetworkInterface ifc) throws SocketException { //Windows workaround if (SystemUtils.IS_OS_WINDOWS) { @@ -48,7 +63,14 @@ LOGGER.debug("Pcap instance for device {} created.", device); } - pcapInstance = new PcapInstance(new PcapOutput.Sender(pcap)); + + if (dumpFile == null) { + pcapInstance = new PcapInstance(new PcapOutput.Sender(pcap)); + } else { + PcapDumper pcapDumper = PcapDumper.open(pcap, "c:/tmp/st/netflow/out.pcap", sb); + pcapInstance = new PcapInstance(new PcapOutput.Writer(pcap, pcapDumper)); + } + pcaps.put(device, pcapInstance); } @@ -89,4 +111,6 @@ this.pcap = pcap; } } + + }