1

I'm trying to see my outgoing UDP traffic in Wireshark.

I created new socket and bind it to my QHostAddress::LocalHost with no errors. I then sent some data writeDatagram and the return value is correct, but I see no outgoing traffic in Wireshark.

// create a socket called from init() 
socket = new QUdpSocket(this);
bool ret = socket->bind(QHostAddress::LocalHost, 47000);
if (ret == false)
   {
    printf("failed to bind socket\n");
   }    


// create and sent some data called from send()
QHostAddress addr("192.168.5.12"); // addr of my other computer
qint64 size = socket->writeDatagram(QByteArray("udp data"),addr,47000);

printf("sent %d\n",size); // correct size sent 8

I checked the firewall setting and it's the same result if I turn it off.

Milo
  • 51
  • 5
  • 4
    What platform are you on? [WinPcap can not capture from loopback device out of the box on windows](https://wiki.wireshark.org/CaptureSetup/Loopback). Can you see any other loopback traffic? Maybe try `ping localhost` and see if that generates any traffic in wireshark... – Mike May 23 '19 at 22:26
  • 1
    What operating system are you on? QHostAddress::LocalHost should resolve to the loopback address which wireshark cannot listen to on windows (and some others) https://stackoverflow.com/questions/5847168/wireshark-localhost-traffic-capture – Kieran May 23 '19 at 22:27
  • What network device are you listening to on wireshark? – James m May 23 '19 at 22:48
  • @Mike, Sorry for not stating platform It was 12AM and I was working late. I'm on Windows 7. I don't see any traffic when pinging localhost. I changed QHostAddress::LocalHost to my network address and now I see packets. Thank you all for the help. I can't believe I didn't try this. SOLVED. – Milo May 24 '19 at 13:45
  • No worries :) You can see what Qt sends on wireshark only if you are able to see ICMP packets from `ping localhost`. You might want to refer to the link in my previous comment if you want to try to get wireshark to capture loopback traffic (haven't tried the instructions myself though). – Mike May 24 '19 at 13:52
  • A simpler solution might be to run the application on two separate devices (one of them could be a VM), if you are looking for a fast way to inspect some packets. This way, the traffic is no longer loopback traffic. – Mike May 24 '19 at 13:55
  • Which version of Wireshark are you using? 3.0.0 and later ship with Npcap, which supports loopback capture. – Gerald Combs May 24 '19 at 21:18

1 Answers1

1

SOLVED by changing the QHostAddress from localhost to assigned router address.

Milo
  • 51
  • 5