use of com.exalttech.trex.packets.TrexVlanPacket in project trex-stateless-gui by cisco-system-traffic-generator.
the class PacketUtil method addVlanToPacket.
/**
* Add VLan to the generated packet
*
* @param ethernetPacket
* @param ipV4Packet
*/
public void addVlanToPacket(TrexEthernetPacket ethernetPacket, IpV4Packet.Builder ipV4Packet) {
LOG.info("Add VLAN data");
ethernetPacket.setType(EtherType.DOT1Q_VLAN_TAGGED_FRAMES.value());
TrexVlanPacket vlanPacket = new TrexVlanPacket();
if (ipV4Packet == null) {
ethernetPacket.setAddPad(true);
vlanPacket.setType((short) 0xFFFF);
} else {
vlanPacket.setType(EtherType.IPV4.value());
}
vlanPacket.buildPacket(ipV4Packet);
ethernetPacket.buildPacket(vlanPacket.getBuilder());
}
use of com.exalttech.trex.packets.TrexVlanPacket in project trex-stateless-gui by cisco-system-traffic-generator.
the class ProtocolDataView method getProtocolData.
/**
* Return protocol data view
*
* @return
* @throws Exception
*/
public TrexEthernetPacket getProtocolData() throws Exception {
int packetLength = PacketBuilderHelper.getPacketLength(selections.getFrameLengthType(), Integer.parseInt(selections.getFrameLength()), Integer.parseInt(selections.getMaxLength()));
TrexEthernetPacket ethernetPacket = new TrexEthernetPacket();
// set mac address
ethernetPacket.setSrcAddr(macView.getSourceAddress().getAddress());
ethernetPacket.setDstAddr(macView.getDestinationAddress().getAddress());
ethernetPacket.setLength(packetLength);
// set payload in ethernet
ethernetPacket.setPayload(payloadView.getPayload());
if (ethernetView.isOverrideType()) {
ethernetPacket.setType(ethernetView.getType());
}
Builder ipV4Packet = getIPV4Packet(PacketBuilderHelper.getIPV4TotalLength(selections.isTaggedVlanSelected()), packetLength);
if (selections.isTaggedVlanSelected()) {
if (!ethernetView.isOverrideType()) {
ethernetPacket.setType(EtherType.DOT1Q_VLAN_TAGGED_FRAMES.value());
}
TrexVlanPacket vlanPacket = vlanView.getVlan();
/// IF IPV4 is selected
if (!vlanPacket.isOverrideType()) {
if (!selections.isIPV4Selected()) {
ethernetPacket.setAddPad(true);
vlanPacket.setType((short) 0xFFFF);
} else {
vlanPacket.setType(EtherType.IPV4.value());
}
}
vlanPacket.buildPacket(ipV4Packet);
ethernetPacket.buildPacket(vlanPacket.getBuilder());
} else {
ethernetPacket.buildPacket(ipV4Packet);
}
return ethernetPacket;
}
Aggregations