Ask is moving to Stack Overflow and Serverfault.com! Please use the "opendaylight" tag on either of these sites. This site is now in Read-Only mode

Revision history [back]

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

For a example :

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

    if (nextPak instanceof IPv4) {
        IPv4 ipPak = (IPv4)nextPak;
        System.out.println("IP");
        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(sip);
        System.out.println("DST IP:");
        System.out.println(dip);

        Object frame = ipPak.getPayload();
        if (frame instanceof ICMP) {
            System.out.println("ICMP from instance");
        }

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;
        System.out.println("IP");
        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(sip);
        System.out.println("DST IP:");
        System.out.println(dip);

        Object frame = ipPak.getPayload();
        if (frame instanceof ICMP) {
            System.out.println("ICMP from instance");
        }