Search in sources :

Example 6 with Profile

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);
}
Also used : TrafficProfile(com.exalttech.trex.util.TrafficProfile) Profile(com.exalttech.trex.remote.models.profiles.Profile) TrafficProfile(com.exalttech.trex.util.TrafficProfile)

Example 7 with Profile

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);
    }
}
Also used : Window(javafx.stage.Window) DialogWindow(com.exalttech.trex.ui.dialog.DialogWindow) Packet(org.pcap4j.packet.Packet) EthernetPacket(org.pcap4j.packet.EthernetPacket) IllegalRawDataException(org.pcap4j.packet.IllegalRawDataException) IOException(java.io.IOException) Timestamp(java.sql.Timestamp) TableProfile(com.exalttech.trex.ui.views.models.TableProfile) Profile(com.exalttech.trex.remote.models.profiles.Profile) TrafficProfile(com.exalttech.trex.util.TrafficProfile) File(java.io.File)

Example 8 with Profile

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;
}
Also used : TableProfile(com.exalttech.trex.ui.views.models.TableProfile) TableProfileStream(com.exalttech.trex.ui.views.models.TableProfileStream) IOException(java.io.IOException) TableProfile(com.exalttech.trex.ui.views.models.TableProfile) Profile(com.exalttech.trex.remote.models.profiles.Profile) TrafficProfile(com.exalttech.trex.util.TrafficProfile)

Example 9 with Profile

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);
}
Also used : TableProfileStream(com.exalttech.trex.ui.views.models.TableProfileStream) TableProfile(com.exalttech.trex.ui.views.models.TableProfile) Profile(com.exalttech.trex.remote.models.profiles.Profile) TrafficProfile(com.exalttech.trex.util.TrafficProfile)

Example 10 with Profile

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);
}
Also used : Window(javafx.stage.Window) DialogWindow(com.exalttech.trex.ui.dialog.DialogWindow) TableProfile(com.exalttech.trex.ui.views.models.TableProfile) Profile(com.exalttech.trex.remote.models.profiles.Profile) TrafficProfile(com.exalttech.trex.util.TrafficProfile)

Aggregations

Profile (com.exalttech.trex.remote.models.profiles.Profile)18 TrafficProfile (com.exalttech.trex.util.TrafficProfile)8 File (java.io.File)6 IOException (java.io.IOException)6 TableProfile (com.exalttech.trex.ui.views.models.TableProfile)5 TableProfileStream (com.exalttech.trex.ui.views.models.TableProfileStream)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 DialogWindow (com.exalttech.trex.ui.dialog.DialogWindow)2 Alert (javafx.scene.control.Alert)2 Window (javafx.stage.Window)2 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)1 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)1 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)1 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)1 Mode (com.exalttech.trex.remote.models.profiles.Mode)1 PacketInfo (com.exalttech.trex.remote.models.profiles.PacketInfo)1 AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)1 ImportPcapTableData (com.exalttech.trex.ui.views.models.ImportPcapTableData)1 YAMLFactory (com.fasterxml.jackson.dataformat.yaml.YAMLFactory)1 EOFException (java.io.EOFException)1