How to send packet from controller to its path?

asked 2016-03-09 04:52:16 -0800

vinayaktj gravatar image

Hello, I am trying to get a packet to the controller, mark its ecn and send it back to its destination. Following is the code snippet :

public PacketResult receiveDataPacket(RawPacket inPkt) { // The connector, the packet came from ("port") NodeConnector ingressConnector = inPkt.getIncomingNodeConnector(); // The node that received the packet ("switch") Node node = ingressConnector.getNode();

log.trace("Packet from " + node.getNodeIDString() + " " + ingressConnector.getNodeConnectorIDString());

// Use DataPacketService to decode the packet.
Packet pkt = dataPacketService.decodeDataPacket(inPkt);

if (pkt instanceof Ethernet) {
    System.out.println("New Packet Received");
    Ethernet ethFrame = (Ethernet) pkt;
    Object l3Pkt = ethFrame.getPayload();
    byte[] srcMac = ethFrame.getSourceMACAddress();
    byte[] destMac = ethFrame.  getDestinationMACAddress();

    if (l3Pkt instanceof IPv4) {
        IPv4 ipv4Pkt = (IPv4) l3Pkt;
        NodeConnector outConnector = inPkt.getIncomingNodeConnector();
        RawPacket outPkt = this.dataPacketService.encodeDataPacket(ipv4Pkt.getParent());
        System.out.println("IPV4 packet received and Sent");
        return PacketResult.CONSUME;


System.out.println("Packet Sent Back");
// We did not process the packet -> let someone else do the job.
return PacketResult.IGNORED;

When I display the packet after setting the ECN, its showing that ECN bit is set. However when I check the packet from wireshark by setting the filter as ip.dsfield.ecn==3, I'm seeing it as TCP Re-Transmission packet_out and when I check the packet the ECN bit is not set. Also my hosts are ECN enabled but still its showing it as NOT-ECT. Is there anything wrong in the code ? Or is there any other approach to set ECN ?

edit retag flag offensive close merge delete