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;
}
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;
}
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. ");
}
Aggregations