use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketUtil method getPacketInfoData.
/**
* Decode string and return packet info data
*
* @param encodedBinaryPacket
* @return packet info
* @throws IOException
*/
public PacketInfo getPacketInfoData(String encodedBinaryPacket) throws IOException {
// decode binary data
File pcapFile = trafficProfile.decodePcapBinary(encodedBinaryPacket);
PacketInfo packetInfo = new PacketInfo();
PacketParser parser = new PacketParser();
parser.parseFile(pcapFile.getAbsolutePath(), packetInfo);
return packetInfo;
}
use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.
the class ImportedPacketTableView method setPcapFile.
/**
* Parse pcap file to get all streams
*
* @param pcapFile
* @return
*/
public boolean setPcapFile(File pcapFile) {
List<PacketInfo> packetInfoList = new ArrayList<>();
try {
PacketUpdater.getInstance().reset();
PcapHandle handler = Pcaps.openOffline(pcapFile.getAbsolutePath());
PacketParser parser = new PacketParser();
Packet packet;
while ((packet = handler.getNextPacketEx()) != null) {
if (!PacketUpdater.getInstance().validatePacket(packet)) {
break;
}
PacketInfo packetInfo = new PacketInfo();
packet = PacketUpdater.getInstance().updatePacketSrcDst(packet);
packetInfo.setPacket(packet);
packetInfo.setTimeStamp(handler.getTimestamp().getTime());
parser.parsePacket(packet, packetInfo);
packetInfoList.add(packetInfo);
}
} catch (EOFException e) {
LOG.info("End of pcap file");
} catch (PcapNativeException | TimeoutException | NotOpenException ex) {
LOG.error("Error parsing selectd pcap file", ex);
}
setTableData(packetInfoList);
return PacketUpdater.getInstance().isValidPacket();
}
use of com.exalttech.trex.ui.views.streams.viewer.PacketParser in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketBuilderHomeController method initialize.
@Override
public void initialize(URL url, ResourceBundle rb) {
trafficProfile = new TrafficProfile();
packetHex = new PacketHex(hexPane);
nextStreamBtn.setGraphic(new ImageView(new Image("/icons/next_stream.png")));
prevStreamBtn.setGraphic(new ImageView(new Image("/icons/prev_stream.png")));
packetInfo = new PacketInfo();
parser = new PacketParser();
}
Aggregations