Home:ALL Converter>Wireshark captures packet but JAVA application do not capture

Wireshark captures packet but JAVA application do not capture

Ask Time:2012-09-25T18:51:38         Author:Debobroto Das

Json Formatter

I am working on a application on MEGACO protocol on Controller side. I am sending MEGACO messages to the Media Gateway via UDP prptocol. And the Media gateway is answering the requests. When I run wireshark with specified port and IP filter wireshark shows all the captured MEGACO packets. But in my application (written in JAVA) some of the packets are not reaching. More specifically saying to my application only Transaction Reply and Transaction Reply Acknowledgement (Reference: RFC 3015) messages are not reaching.

I have tried a lot of permutations and combinations. Even I have allocated new Datagram Packet and buffer space for each receiving messages as test. But no result. My code for the udp receiver is following.

while (running) {
        //do work here
        try {
            byte[] dpBuffer = new byte[MAX_BUFFER_SIZE];
            DatagramPacket dp = new DatagramPacket(dpBuffer, MAX_BUFFER_SIZE);
            this.socket.receive(dp);
            byte[] temp = new byte[dp.getLength()];
            System.arraycopy(dp.getData(), 0, temp, 0, dp.getLength());
            System.out.println("Read data");
            for(int i=0;i<temp.length;i++)
            {
                System.out.print((char)(temp[i]));
            }
            ByteArrayUtil msg = new ByteArrayUtil(temp, dp.getLength());
            msgParser.parseMsg(msg);
        } catch (Exception e) {
            logger.error("Megaco Reader Failed to read Packet due to :" ,e);
        }
    }

Any help??

Author:Debobroto Das,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12581455/wireshark-captures-packet-but-java-application-do-not-capture
yy