Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Sniffing broadcast udp socket on specific MAC address
QtWS25 Last Chance

Sniffing broadcast udp socket on specific MAC address

Scheduled Pinned Locked Moved Unsolved General and Desktop
networkudp
3 Posts 3 Posters 398 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lior
    wrote on 7 Mar 2023, 17:48 last edited by
    #1

    Hi,
    Let say I have multiple network cards.

    How can I open broadcast udp socket for specific MAC adrress. (port X)

    A small example will be perfect.

    Using qt tools QUdp and QNetworkInterface.
    For now I know how to read all the exist interfaces but didn't understand from the documentation how to open broadcast udp socket.

    *the socket is only for sniffing.

    Tnx.

    C 1 Reply Last reply 7 Mar 2023, 18:00
    0
    • L Lior
      7 Mar 2023, 17:48

      Hi,
      Let say I have multiple network cards.

      How can I open broadcast udp socket for specific MAC adrress. (port X)

      A small example will be perfect.

      Using qt tools QUdp and QNetworkInterface.
      For now I know how to read all the exist interfaces but didn't understand from the documentation how to open broadcast udp socket.

      *the socket is only for sniffing.

      Tnx.

      C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on 7 Mar 2023, 18:00 last edited by
      #2

      @Lior The broadcast adress of your interface is the last adress in the possible subnet as explained e.g. in wikipedia. So find out this adress and listen to it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      1
      • C Offline
        C Offline
        ChrisW67
        wrote on 7 Mar 2023, 20:12 last edited by
        #3

        If something else sends a UDP datagram to the sub-net IP broadcast address (e.g. 192.168.1.255 on IP subnet 192.168.1.0/24) then any device connected to, and configured for, that IP sub-net should receive the datagram. You need to know the port that the UDP datagram was sent to also.

        Assuming your listeneing device is connected to the relevant physical network and has suitable IP address/subnet mask, then all you should need is to QUdpSocket::bind() to your IP and port.

        1 Reply Last reply
        0

        3/3

        7 Mar 2023, 20:12

        • Login

        • Login or register to search.
        3 out of 3
        • First post
          3/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved