use of com.exalttech.trex.remote.models.profiles.PacketInfo in project trex-stateless-gui by cisco-system-traffic-generator.
the class TrafficProfile method getPacketInfo.
/**
*
* @param packetBinary
* @return
*/
public PacketInfo getPacketInfo(String packetBinary) {
PacketInfo packetInfo = null;
try {
byte[] pkt = Base64.decodeBase64(packetBinary);
Packet packet = EthernetPacket.newPacket(pkt, 0, pkt.length);
packetInfo = getPacketTypeText(packet);
} catch (IllegalRawDataException ex) {
LOG.error("Error reading packet info", ex);
}
return packetInfo;
}
use of com.exalttech.trex.remote.models.profiles.PacketInfo in project trex-stateless-gui by cisco-system-traffic-generator.
the class TrafficProfile method convertProfilesToTableData.
/**
* Convert profiles to equivalent tableProfile data
*
* @param profilesList
* @return
*/
public List<TableProfileStream> convertProfilesToTableData(Profile[] profilesList) {
List<TableProfileStream> tableData = new ArrayList<>();
for (int index = 0; index < profilesList.length; index++) {
Profile p = profilesList[index];
TableProfileStream stream = new TableProfileStream();
Mode modeYaml = p.getStream().getMode();
stream.setIndex(String.valueOf(index + 1));
stream.setEnabled(p.getStream().isEnabled());
stream.setName(p.getName());
stream.setMode(modeYaml.getType());
String rateUnits = "";
switch(modeYaml.getRate().getType()) {
case Rate.RateTypes.PPS:
rateUnits = "pps";
break;
case Rate.RateTypes.BPS_L1:
rateUnits = "bps L1";
break;
case Rate.RateTypes.BPS_L2:
rateUnits = "bps L2";
break;
case Rate.RateTypes.PERCENTAGE:
rateUnits = "%";
break;
}
stream.setRate(Util.formattedData((long) modeYaml.getRate().getValue(), true) + rateUnits);
stream.setNextStream(getNextStreamValue(p.getNext()));
String packetBinary = p.getStream().getPacket().getBinary();
String packetModel = p.getStream().getPacket().getModel();
stream.setPcapBinary(packetBinary);
stream.setPktModel(packetModel);
PacketInfo packetInfo = getPacketInfo(packetBinary);
stream.setLength(String.valueOf(packetInfo.getLength() + Constants.EXTRA_BYTE));
stream.setPacketType(packetInfo.getType());
tableData.add(stream);
}
return tableData;
}
use of com.exalttech.trex.remote.models.profiles.PacketInfo in project trex-stateless-gui by cisco-system-traffic-generator.
the class TrafficProfile method getPacketTypeText.
/**
*
* @param packet
* @return
*/
public PacketInfo getPacketTypeText(Packet packet) {
PacketInfo packetInfo = new PacketInfo();
String packetType = "";
// Default values for packet info
packetInfo.setType("Unknown");
packetInfo.setLength(packet.length());
if (packet != null) {
// EthernetPacket
if (packet.get(EthernetPacket.class) != null) {
packetType += "Ethernet/";
}
// IPPacket
if (packet.get(IpV4Packet.class) != null) {
packetType += "IPV4/";
}
// TCPPacket
if (packet.get(TcpPacket.class) != null) {
packetType += "TCP/";
}
// UDPPacket
if (packet.get(UdpPacket.class) != null) {
packetType += "UDP";
}
if (packetType.endsWith("/")) {
packetType = packetType.substring(0, packetType.length() - 1);
}
packetInfo.setType(packetType);
}
return packetInfo;
}
Aggregations