Debobroto Das
Debobroto Das

Reputation: 862

Wireshark captures packet but JAVA application do not capture

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??

Upvotes: 2

Views: 3675

Answers (1)

Debobroto Das
Debobroto Das

Reputation: 862

THanks E_net4.

As I have mentioned in my comment, I was using wrong filter in wireshark. in wireshark if you use only

"udp.port == x" 

as the filter it will filter those packets having either source or destination port x. To filter those packets that have either source port == x or destination port ==x, you should use udp.srcport == x and udp.destport==xrespectively. Thanks everyone.

Upvotes: 2

Related Questions