Search in sources :

Example 1 with TrexTcpPacket

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

the class TCPProtocolView method getTcpPacket.

/**
     * Return TCP packet
     *
     * @param payload
     * @param packetLength
     * @return @throws Exception
     */
public TrexTcpPacket getTcpPacket(Payload payload, int packetLength) throws Exception {
    TrexTcpPacket tcpPacket = new TrexTcpPacket();
    tcpPacket.setSrcPort(Util.getPortValue(srcPort.getText()));
    tcpPacket.setDstPort(Util.getPortValue(dstPort.getText()));
    tcpPacket.setSequenceNumber(Util.getIntFromString(seqNumber.getText()));
    tcpPacket.setAcknowledgmentNumber(Util.getIntFromString(ackNumber.getText()));
    //header length not set
    tcpPacket.setWindow(Util.getShortFromString(window.getText(), false));
    tcpPacket.setChecksum(Util.getShortFromString(checksum.getText(), true));
    tcpPacket.setUrgentPointer(Util.getShortFromString(urgentPointer.getText(), false));
    // set flags
    tcpPacket.setUrg(urg.isSelected());
    tcpPacket.setAck(ack.isSelected());
    tcpPacket.setPsh(psh.isSelected());
    tcpPacket.setRst(rst.isSelected());
    tcpPacket.setSyn(syn.isSelected());
    tcpPacket.setFin(fin.isSelected());
    tcpPacket.setPacketLength(packetLength);
    tcpPacket.setPayload(payload);
    // build packet
    tcpPacket.buildPacket();
    return tcpPacket;
}
Also used : TrexTcpPacket(com.exalttech.trex.packets.TrexTcpPacket)

Example 2 with TrexTcpPacket

use of com.exalttech.trex.packets.TrexTcpPacket 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 3 with TrexTcpPacket

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

the class TCPTest method getTcpPacket.

/**
     * Create TCP packet
     *
     * @param payload
     * @param packetLength
     * @return TCP packet
     */
private TrexTcpPacket getTcpPacket(Payload payload, int packetLength, PacketData packetData) {
    LOG.info("Create TCP Packet");
    TrexTcpPacket tcpPacket = new TrexTcpPacket();
    tcpPacket.setSrcPort(packetData.getTcpData().getSrcPort());
    tcpPacket.setDstPort(packetData.getTcpData().getDstPort());
    tcpPacket.setSequenceNumber(packetData.getTcpData().getSequenceNumber());
    tcpPacket.setAcknowledgmentNumber(packetData.getTcpData().getAckNumber());
    tcpPacket.setWindow(Util.getShortFromString(packetData.getTcpData().getWindow(), false));
    tcpPacket.setChecksum(Util.getShortFromString(packetData.getTcpData().getChecksum(), true));
    tcpPacket.setUrgentPointer(Util.getShortFromString(packetData.getTcpData().getUrgetPointer(), false));
    tcpPacket.setPacketLength(packetLength);
    tcpPacket.setPayload(payload);
    tcpPacket.buildPacket();
    return tcpPacket;
}
Also used : TrexTcpPacket(com.exalttech.trex.packets.TrexTcpPacket)

Aggregations

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