Search in sources :

Example 6 with TrexEthernetPacket

use of com.exalttech.trex.packets.TrexEthernetPacket 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)

Example 7 with TrexEthernetPacket

use of com.exalttech.trex.packets.TrexEthernetPacket in project trex-stateless-gui by cisco-system-traffic-generator.

the class IPV4Test method testIPV4Profile.

@Test(dataProvider = "packetData", dependsOnGroups = { "init" })
public void testIPV4Profile(PacketData packetData) throws IOException, InterruptedException, PcapNativeException, NotOpenException, URISyntaxException {
    TrexEthernetPacket ethernetPacket = buildIPV4Packet(packetData);
    // 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) Test(org.testng.annotations.Test)

Example 8 with TrexEthernetPacket

use of com.exalttech.trex.packets.TrexEthernetPacket in project trex-stateless-gui by cisco-system-traffic-generator.

the class TCPTest method testTCPProfile.

@Test(dataProvider = "packetData", dependsOnGroups = { "init" })
public void testTCPProfile(PacketData packetData) throws IOException, InterruptedException, PcapNativeException, NotOpenException, URISyntaxException {
    TrexEthernetPacket ethernetPacket = buildIPV4Packet(packetData);
    // 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) Test(org.testng.annotations.Test)

Aggregations

TrexEthernetPacket (com.exalttech.trex.packets.TrexEthernetPacket)8 Test (org.testng.annotations.Test)4 TrexIpV4Packet (com.exalttech.trex.packets.TrexIpV4Packet)2 Payload (com.exalttech.trex.ui.views.streams.builder.Payload)2 TrexTcpPacket (com.exalttech.trex.packets.TrexTcpPacket)1 TrexUdpPacket (com.exalttech.trex.packets.TrexUdpPacket)1 TrexVlanPacket (com.exalttech.trex.packets.TrexVlanPacket)1 IpV4Packet (org.pcap4j.packet.IpV4Packet)1 Builder (org.pcap4j.packet.IpV4Packet.Builder)1