Ask Your Question

How can I use java code to send a packet from Controller to a specific switch?

asked 2015-05-13 09:07:15 -0700

ShawLinLoveLife gravatar image

I use Controller Helium SR3. I have got Id of the switch to which I want to send a message(packet). How could I build up my package in controller and then let controller send this package to that switch?

Thanks & Best Wishes!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2015-05-18 23:52:03 -0700

You can use the the PacketProcessingService interface from model-flow-service :

Future<RpcResult<java.lang.Void>> transmitPacket(TransmitPacketInput input);

Sample Example from the LLDP speaker, as suggested by the @dandrushko :

// Generate packet with destination switch and port
        TransmitPacketInput packet = new TransmitPacketInputBuilder()
                .setEgress(new NodeConnectorRef(nodeConnectorInstanceId))
                .setNode(new NodeRef(nodeInstanceId))
                        LLDPUtil.buildLldpFrame(nodeId, nodeConnectorId,
                                srcMacAddress, outputPortNo,

        // Save packet to node connector id -> packet map to transmit it every 5
        // seconds
        nodeConnectorMap.put(nodeConnectorInstanceId, packet);
        LOG.trace("Port {} added to LLDPSpeaker.nodeConnectorMap",

        // Transmit packet for first time immediately
edit flag offensive delete publish link more


Thanks a lot. It is really a great help!

ShawLinLoveLife ( 2015-05-19 03:00:25 -0700 )edit

I tried getting the PacketProcessingService from my odl plugin via session.getRpcService(PacketProcessingService.class) but when calling transmitPacket() on the Proxy I get IllegalStatsException: No default provider is available. I assume the service is not installed in karaf. Do you know which bundle do I need to install if this is the case?

cpetroaca ( 2015-05-25 07:05:18 -0700 )edit

answered 2015-05-18 07:22:03 -0700

dandrushko gravatar image

As one of the options, you can look at LLDP speaker code ( in the Openflow plugin project to get basic understanding how to generate and send out arbitrary packet out of a given switch.

edit flag offensive delete publish link more


Thank you very much! It is really helpful!

ShawLinLoveLife ( 2015-05-19 03:07:16 -0700 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools



Asked: 2015-05-13 09:07:15 -0700

Seen: 634 times

Last updated: May 18 '15