Search in sources :

Example 1 with TrexIpV4Packet

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

the class TCPTest method getIPV4PacketBuilder.

@Override
protected IpV4Packet.Builder getIPV4PacketBuilder(int totalLength, int packetLength, Payload payload, PacketData packetData) throws UnknownHostException {
    LOG.info("Create IPV4 Packet");
    TrexIpV4Packet ipV4Packet = prepareIPV4Packet(totalLength, packetLength, payload, packetData);
    int ipv4PacketLength = PacketBuilderHelper.getIPV4PacketLength(packetData.isTaggedVlan(), packetLength, totalLength);
    ipV4Packet.setPacketLength(ipv4PacketLength);
    int tcpPacketLength = PacketBuilderHelper.getTcpUdpPacketLength(packetData.isTaggedVlan(), packetLength, totalLength);
    // build  packet
    ipV4Packet.buildPacket(getTcpPacket(payload, tcpPacketLength, packetData).getBuilder(), IpNumber.TCP);
    return ipV4Packet.getBuilder();
}
Also used : TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet)

Example 2 with TrexIpV4Packet

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

the class AbstractIPV4Test method prepareIPV4Packet.

protected TrexIpV4Packet prepareIPV4Packet(int totalLength, int packetLength, Payload payload, PacketData packetData) throws UnknownHostException {
    TrexIpV4Packet ipV4Packet = new TrexIpV4Packet();
    ipV4Packet.setSrcAddr(packetData.getIpv4Data().getSrcAddress().getAddress());
    ipV4Packet.setDstAddr(packetData.getIpv4Data().getDstAddress().getAddress());
    ipV4Packet.setTotalLength((short) totalLength);
    ipV4Packet.setPacketLength(packetLength + 4);
    ipV4Packet.setPayload(payload);
    return ipV4Packet;
}
Also used : TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet)

Example 3 with TrexIpV4Packet

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

the class ProtocolData method init.

private void init() {
    try {
        ethernetPacket = new TrexEthernetPacket();
        ipv4Packet = new TrexIpV4Packet();
        tcpPacket = new TrexTcpPacket();
        udpPacket = new TrexUdpPacket();
    } catch (Exception ex) {
        LOG.error("Couldn't initialize protocol data", ex);
    }
}
Also used : TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet) TrexEthernetPacket(com.exalttech.trex.packets.TrexEthernetPacket) TrexTcpPacket(com.exalttech.trex.packets.TrexTcpPacket) TrexUdpPacket(com.exalttech.trex.packets.TrexUdpPacket)

Example 4 with TrexIpV4Packet

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

the class ProtocolDataView method getIPV4Packet.

/**
     * Prepare and return IPV4 builder
     *
     * @return
     * @throws Exception
     */
private Builder getIPV4Packet(int totalLength, int packetLength) throws Exception {
    if (selections.isIPV4Selected()) {
        TrexIpV4Packet ipV4Packet = new TrexIpV4Packet();
        ipV4Packet.setSrcAddr(ipv4View.getSourceAddress().getAddress());
        ipV4Packet.setDstAddr(ipv4View.getDestinationAddress().getAddress());
        ipV4Packet.setTotalLength((short) totalLength);
        ipV4Packet.setPacketLength(packetLength + 4);
        Payload payload = payloadView.getPayload();
        ipV4Packet.setPayload(payload);
        int ipv4PacketLength = PacketBuilderHelper.getIPV4PacketLength(selections.isTaggedVlanSelected(), packetLength, totalLength);
        int tcpUdpPacketLength = PacketBuilderHelper.getTcpUdpPacketLength(selections.isTaggedVlanSelected(), packetLength, totalLength);
        if (selections.isTCPSelected()) {
            ipV4Packet.setPacketLength(ipv4PacketLength);
            ipV4Packet.buildPacket(tcpView.getTcpPacket(payload, tcpUdpPacketLength).getBuilder(), IpNumber.TCP);
        } else if (selections.isUDPSelected()) {
            ipV4Packet.setPacketLength(ipv4PacketLength);
            ipV4Packet.buildPacket(udpView.getUDPPacket(payload, tcpUdpPacketLength).getBuilder(), IpNumber.UDP);
        } else {
            ipV4Packet.buildPacket(null, IpNumber.getInstance((byte) 0));
        }
        return ipV4Packet.getBuilder();
    }
    return null;
}
Also used : TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet)

Example 5 with TrexIpV4Packet

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

the class IPV4Test method getIPV4PacketBuilder.

/**
     * Create IPV4 packet
     *
     * @param totalLength
     * @param packetLength
     * @param payload
     * @param packetData
     * @return IPV4 packet
     * @throws java.net.UnknownHostException
     */
@Override
protected Builder getIPV4PacketBuilder(int totalLength, int packetLength, Payload payload, PacketData packetData) throws UnknownHostException {
    LOG.info("Create IPV4 Packet");
    TrexIpV4Packet ipV4Packet = prepareIPV4Packet(totalLength, packetLength, payload, packetData);
    // build IPV4 packet
    ipV4Packet.buildPacket(null, IpNumber.getInstance((byte) 0));
    return ipV4Packet.getBuilder();
}
Also used : TrexIpV4Packet(com.exalttech.trex.packets.TrexIpV4Packet)

Aggregations

TrexIpV4Packet (com.exalttech.trex.packets.TrexIpV4Packet)6 TrexEthernetPacket (com.exalttech.trex.packets.TrexEthernetPacket)1 TrexTcpPacket (com.exalttech.trex.packets.TrexTcpPacket)1 TrexUdpPacket (com.exalttech.trex.packets.TrexUdpPacket)1