Search in sources :

Example 1 with Payload

use of com.exalttech.trex.ui.views.streams.builder.Payload in project trex-stateless-gui by cisco-system-traffic-generator.

the class PacketUtil method getPayload.

/**
     * Create payload
     *
     * @param payloadData
     * @return
     */
public Payload getPayload(PayloadData payloadData) {
    Payload payload = new Payload();
    payload.setPayloadPattern(payloadData.getPattern());
    payload.setPayloadType(PayloadType.getPayloadType(payloadData.getType()));
    return payload;
}
Also used : Payload(com.exalttech.trex.ui.views.streams.builder.Payload)

Example 2 with Payload

use of com.exalttech.trex.ui.views.streams.builder.Payload in project trex-stateless-gui by cisco-system-traffic-generator.

the class AbstractIPV4Test method buildIPV4Packet.

/**
     * Build IPV4 packet
     *
     * @param packetData
     * @return
     * @throws IOException
     * @throws InterruptedException
     * @throws PcapNativeException
     * @throws NotOpenException
     * @throws java.net.URISyntaxException
     */
public TrexEthernetPacket buildIPV4Packet(PacketData packetData) throws IOException, InterruptedException, PcapNativeException, NotOpenException, URISyntaxException {
    LOG.info("create ethernet packet");
    int packetLength = PacketBuilderHelper.getPacketLength(packetData.getPacketLength().getLengthType(), packetData.getPacketLength().getFrameLength(), packetData.getPacketLength().getMaxLength());
    Payload payload = packetUtil.getPayload(packetData.getPayload());
    TrexEthernetPacket ethernetPacket = packetUtil.prepareEthernetPacket(packetData, packetLength, payload);
    // define VLAN 
    IpV4Packet.Builder ipV4Packet = getIPV4PacketBuilder(PacketBuilderHelper.getIPV4TotalLength(packetData.isTaggedVlan()), packetLength, payload, packetData);
    if (!packetData.isTaggedVlan()) {
        LOG.info("Add IPV4 packet");
        ethernetPacket.buildPacket(ipV4Packet);
    } else {
        packetUtil.addVlanToPacket(ethernetPacket, ipV4Packet);
    }
    return ethernetPacket;
}
Also used : TrexEthernetPacket(com.exalttech.trex.packets.TrexEthernetPacket) TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet) IpV4Packet(org.pcap4j.packet.IpV4Packet) Payload(com.exalttech.trex.ui.views.streams.builder.Payload)

Example 3 with Payload

use of com.exalttech.trex.ui.views.streams.builder.Payload in project trex-stateless-gui by cisco-system-traffic-generator.

the class EthernetTest method testEthernetProfile.

@Test(dataProvider = "packetData", dependsOnGroups = { "init" })
public void testEthernetProfile(PacketData packetData) throws IOException, InterruptedException, PcapNativeException, NotOpenException, URISyntaxException {
    // create profile
    LOG.info("create ethernet packet");
    int packetLength = PacketBuilderHelper.getPacketLength(packetData.getPacketLength().getLengthType(), packetData.getPacketLength().getFrameLength(), packetData.getPacketLength().getMaxLength());
    Payload payload = packetUtil.getPayload(packetData.getPayload());
    TrexEthernetPacket ethernetPacket = packetUtil.prepareEthernetPacket(packetData, packetLength, payload);
    if (!packetData.isTaggedVlan()) {
        ethernetPacket.buildPacket(null);
    } else {
        packetUtil.addVlanToPacket(ethernetPacket, null);
    }
    // prepare and save yaml data
    LOG.info("Prepare and save Yaml file");
    packetUtil.prepareAndSaveYamlFile(ethernetPacket.getPacket().getRawData(), packetData);
    //Generate pcap files
    LOG.info("Generate Pcap file for " + packetData.getTestFileName() + ".yaml");
    packetUtil.generatePcapFile(packetData.getTestFileName());
    // compare pcaps
    boolean result = packetUtil.comparePcaps(packetData.getTestFileName(), "generated_" + packetData.getTestFileName());
    Assert.assertEquals(result, true, "Invalid generated " + packetData.getTestFileName() + " pcap. ");
}
Also used : TrexEthernetPacket(com.exalttech.trex.packets.TrexEthernetPacket) Payload(com.exalttech.trex.ui.views.streams.builder.Payload) Test(org.testng.annotations.Test)

Aggregations

Payload (com.exalttech.trex.ui.views.streams.builder.Payload)3 TrexEthernetPacket (com.exalttech.trex.packets.TrexEthernetPacket)2 TrexIpV4Packet (com.exalttech.trex.packets.TrexIpV4Packet)1 IpV4Packet (org.pcap4j.packet.IpV4Packet)1 Test (org.testng.annotations.Test)1