Ask Your Question

Stuck in packet out

asked 2016-04-20 04:39:23 -0700

Ayushi gravatar image

what I have done is I got the l2switch code from github . My architecture is of my machines is connected to controller and controller is connected to switch. So everytime a packet comes on switch ,it gets received my controller(odl) and then sends it to my machine which is connected through tcp connection. I have successfully implemented packet in ...I can see my packets coming from switch ,received at controller and controller sending them up to my machine. For this I only made changes in inside onpacketReceived in packethandler and wrote a new function. Now next what I have to test is receive packet from my machine on to the controller and controller will do the packet out . But I am stuck .I know the packet out code is present in inside arphandler. However I dont know how to use it .. I want to understand the basics of when to use data broker rpc notificatiob service binding aware . What do I write in inventory ?

edit retag flag offensive close merge delete


@Ayushi I assume u r writing a northbound application in the machine connected to controller. May I knw how u r forwarding the PACKET_IN messages to ur application? I see that u have written a function in onpacketReceived. But how r u sending out the PACKET_OUT from ur application via the controller

ashvanth48 ( 2016-04-27 11:36:31 -0700 )edit

2 answers

Sort by ยป oldest newest most voted

answered 2016-04-20 05:16:44 -0700

updated 2016-04-20 23:52:32 -0700

You can follow the following steps:

1) get the PacketProcessingService instance:


2) use the PacketProcessingService instance to send the packet. Following is example for sending the packet:

     * This method sends the packet on given output port
     * @param nodeIID SwithID
     * @param ncIID Node connector (ouput port)
     * @param data packet to transmit
    private void sendPacket(InstanceIdentifier<Node> nodeIID,
            InstanceIdentifier<NodeConnector> ncIID,
            byte[] data) {

        TransmitPacketInputBuilder txBuilder = new TransmitPacketInputBuilder();
        .setNode(new NodeRef(nodeIID))
        .setEgress(new NodeConnectorRef(ncIID));


For reference you can take a look into my repo router-on-stick .

edit flag offensive delete publish link more

answered 2016-04-20 06:30:32 -0700

Ayushi gravatar image

updated 2016-04-21 00:45:55 -0700

HI Subhash yes thanks I found out the mistake .However even after initializing nodeId I am getting the error.

Exception in thread "Thread-58" java.lang.NullPointerException at org.opendaylight.l2switch.packethandler.decoders.EthernetDecoder.createNodeConnRef( at org.opendaylight.l2switch.packethandler.decoders.EthernetDecoder.PACKET_OUT( at org.opendaylight.l2switch.packethandler.decoders.EthernetDecoder.ClassifyPacket( at org.opendaylight.l2switch.packethandler.decoders.EthernetDecoder$TcpClient.loop( at org.opendaylight.l2switch.packethandler.decoders.EthernetDecoder$

According to my understanding ,I have included the following functions. In function nodeConnectorAdded I am taking out the nodeId. Please find the functions



nodeConnectorAdded(called inside onDataChanged)

However I think these functions are not being hit as my switch gets connected to controller because of which nodeId is not getting fetched. Once controller will find out the nodeId only then code will proceed . Could you tell me how do we fetch nodeId when switch gets connected or how these functions are called on its own whenever a switch gets onnected.





nodeConnectorAdded(called inside onDataChanged)

Please find my updated code at :

edit flag offensive delete publish link more


can you share your code in pastebin ?? here it is cluttered ;)

subhash ( 2016-04-20 07:08:57 -0700 )edit

@Ayushi I am not able to find the method `PACKET_OUT` and `createNodeRef` ? is it the correct file ?

subhash ( 2016-04-20 12:27:28 -0700 )edit

HI @subhash ,Please find the updated code .

Ayushi ( 2016-04-20 22:10:40 -0700 )edit

@Ayushi you havn't initialised the nodeID. It is set to null, that is why it is complaining `nullpointerexception`.

subhash ( 2016-04-20 23:35:21 -0700 )edit

@subhash ,thanks for the reply ..Please find my question

Ayushi ( 2016-04-21 00:47:58 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2016-04-20 04:39:23 -0700

Seen: 224 times

Last updated: Apr 21 '16