use of com.exalttech.trex.remote.models.profiles.Profile in project trex-stateless-gui by cisco-system-traffic-generator.
the class RPCMethods method assignTrafficProfile.
/**
*
* @param portID
* @param profileList
* @return true in case of success
* @throws java.lang.Exception
*/
public StreamValidation assignTrafficProfile(int portID, Profile[] profileList) throws Exception {
String handler = (String) connectionHandler.get(portID);
stopTraffic(portID);
removeAllStreams(portID);
LogsController.getInstance().appendText(LogType.INFO, "Assigning Traffic Profile on Port " + portID);
TrafficProfile trexTrafficProfile = new TrafficProfile();
Profile[] updatedProfileList;
updatedProfileList = trexTrafficProfile.prepareTrafficProfile(profileList, portID, handler);
serverConnectionManager.sendAddStreamRequest(updatedProfileList);
return validateStream(portID);
}
use of com.exalttech.trex.remote.models.profiles.Profile in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketTableView method handleExportPcapFile.
/**
* Export stream to pcap file
*/
public void handleExportPcapFile() {
try {
Profile p = tabledata.getProfiles().get(streamPacketTableView.getSelectionModel().getSelectedIndex());
String packetBinary = p.getStream().getPacket().getBinary();
byte[] pkt = Base64.decodeBase64(packetBinary);
Packet packet = EthernetPacket.newPacket(pkt, 0, pkt.length);
File pcapFile = File.createTempFile("temp-file-name", ".pcap");
PcapHandle handle = Pcaps.openDead(DataLinkType.EN10MB, 65536);
PcapDumper dumper = handle.dumpOpen(pcapFile.getAbsolutePath());
Timestamp ts = new Timestamp(0);
dumper.dump(packet, ts);
dumper.close();
handle.close();
String fileName = p.getName() + ".pcap";
Window owner = streamPacketTableView.getScene().getWindow();
FileManager.exportFile("Save Pcap File", fileName, pcapFile, owner, FileType.PCAP);
} catch (IllegalRawDataException | IOException | PcapNativeException | NotOpenException ex) {
LOG.error("Error during generate JSON file", ex);
}
}
use of com.exalttech.trex.remote.models.profiles.Profile in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketTableView method loadStreamTable.
/**
* Load stream table data
*
* @param fileToLoad
* @return
* @throws Exception
*/
public Profile[] loadStreamTable(File fileToLoad) throws Exception {
this.loadedProfile = fileToLoad;
doUpdate = false;
Profile[] profileList;
this.profileName = fileToLoad.getName();
try {
profileList = trafficProfile.getTrafficProfile(fileToLoad);
} catch (IOException ex) {
LOG.warn("Profile does not have any streams");
profileList = new Profile[0];
}
List<TableProfileStream> packetDataList = trafficProfile.convertProfilesToTableData(profileList);
TableProfile tableData = new TableProfile(new ArrayList<>(Arrays.asList(profileList)), packetDataList, fileToLoad.getPath());
setPacketData(tableData);
return profileList;
}
use of com.exalttech.trex.remote.models.profiles.Profile in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketTableView method handleAddPacket.
/**
* Handle Add packet button clicked
*
* @param streamName
* @param type
*/
public void handleAddPacket(String streamName, StreamBuilderType type) {
doUpdate = false;
TableProfileStream newRow = new TableProfileStream();
newRow.setName(streamName);
tabledata.getStreamsList().add(newRow);
Profile newProfile = new Profile();
newProfile.setName(streamName);
tabledata.getProfiles().add(newProfile);
streamPacketTableView.setItems(FXCollections.observableArrayList(tabledata.getStreamsList()));
streamPacketTableView.getSelectionModel().select(newRow);
openStreamDialog(type);
}
use of com.exalttech.trex.remote.models.profiles.Profile in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketTableView method handleExportToYaml.
/**
* Export current load profile to yaml
*/
private void handleExportToYaml() {
Window owner = this.getScene().getWindow();
Profile[] profilesList = tabledata.getProfiles().toArray(new Profile[tabledata.getProfiles().size()]);
trafficProfile.exportProfileToYaml(owner, profilesList, profileName);
}
Aggregations