Ask Your Question

How make the Parse IP/TCP packet from PacketHandler

asked 2014-07-17 11:41:31 -0700

anonymous user


Hi Everyone,

The example of the learning-switch application (in openflowplugin/sample/learning-switch) uses the PacketHandler Class. How and which I use the API for parse IP / TCP from a PacketReceive data?

Thank you very much.

Best Regards.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-08-05 11:33:21 -0700

updated 2014-08-05 11:34:07 -0700

You can use the org.opendaylight.controller.sal.packet package to parse the IP/TCP and other packets.

For a example :

public PacketResult receiveDataPacket(RawPacket inPkt) {
    Packet formattedPak = this.dataPacketService.decodeDataPacket(inPkt);

    if (nextPak instanceof IPv4) {
        IPv4 ipPak = (IPv4)nextPak;
        log.trace("Handled IP packet");
        int sipAddr = ipPak.getSourceAddress();
        InetAddress sip = NetUtils.getInetAddress(sipAddr);
        int dipAddr = ipPak.getDestinationAddress();
        InetAddress dip = NetUtils.getInetAddress(dipAddr);
        System.out.println("SRC IP:");
        System.out.println("DST IP:");

        Object frame = ipPak.getPayload();
        if (frame instanceof ICMP) {
            System.out.println("ICMP from instance");
edit flag offensive delete publish link more

Your Answer

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

Add Answer

[hide preview]


Asked: 2014-07-17 11:41:31 -0700

Seen: 433 times

Last updated: Aug 05 '14