Results 1 to 5 of 5

Thread: UDP Multicast Not Sending Packets

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    9

    UDP Multicast Not Sending Packets

    Hi,

    I have a light bulb that needs a specific multicast UDP packet sent to discover whether any exist on the network (it is similar to SSDP but on a different port and none of the third party libraries work with it, so I'm going to have to roll my own).

    I've read the .net SDK for the UDPClient and it is simply not working in the way it seems to say, at it's simplest to send the string I have;

    Code:
    Dim IP As IPAddress = IPAddress.Parse("239.255.255.250")
    
    Dim uClient As New UdpClient(1982)
    
    uClient.JoinMulticastGroup(IP)
    
    Dim RemoteEndPoint As New IPEndPoint(IP, 1982)
    
    Dim senddata As Byte()
    
    Dim query_str As String = "M-SEARCH * HTTP/1.1" & vbCrLf & "HOST: 239.255.255.250:1982" & vbCrLf & "MAN: ""ssdp:discover""" & vbCrLf & "ST: wifi_bulb" & vbCrLf
    
    senddata = Encoding.UTF8.GetBytes(query_str)
    
    uClient.Send(senddata, senddata.Length, RemoteEndPoint)
    Which to me should attempt to join the multicast IP, then set up the end point and then send the string of data (I'll cross receiving the data later). Whatever I do does not send the data (I am monitoring using Wireshark), if I swap the IP for a local IP then it sends the data just fine, if I use a third party discovery tool (sadly no source code) on the PC it works fine which says to me that the problem is in my coding rather than anything like router settings, firewalls etc have been disabled.

    The .net SDK seems to say "You do not need to belong to a multicast group to send datagrams to a multicast IP address." which I have tried doing by dropping the .joinmulticast but that seems to have no effect and it still does not send the packet. As far as I can see I am doing everything I should (setting up the UDP client with a port parameter) but it appears the moment I put a multicast IP in it fails to resolve. The address is valid for the range and it does not throw any exceptions, it just does not send it?

    Does anyone please have any ideas what I can try? I am compiling for .net 4.6 but have tried 4.0 and no difference.

    Thanks,

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: UDP Multicast Not Sending Packets

    Have you made consideration for firewalls? I've never done multi-casting though so I don't have any experience with network model.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: UDP Multicast Not Sending Packets

    I haven't worked with UDP for several years now (I can hardly believe it), but here's a link to a UDP class I had that used broadcasting. This was only over a local LAN, though, but it might give you some ideas for some tests.
    My usual boring signature: Nothing

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2013
    Posts
    9

    Re: UDP Multicast Not Sending Packets

    Thanks for the reply both...

    Quote Originally Posted by Niya View Post
    Have you made consideration for firewalls? I've never done multi-casting though so I don't have any experience with network model.
    I've turned all firewalls off just to test and it does not work, the guidance in the note here https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx suggests that if I specify an address in the multicast range then then it is irrespective of whether I join the group or not ("You do not need to belong to a multicast group to send datagrams to a multicast IP address.") and should send the packet out itself. For some reason that is not happening for me and can't think what is between that could be blocking it.

    Quote Originally Posted by Shaggy Hiker View Post
    I haven't worked with UDP for several years now (I can hardly believe it), but here's a link to a UDP class I had that used broadcasting. This was only over a local LAN, though, but it might give you some ideas for some tests.
    I'd far prefer not to be dealing with UDP if I could help it I guess it has a place in principle...I'm afraid I can't see a link in your post though - am I just missing it??

    Thanks

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: UDP Multicast Not Sending Packets

    Nope, you didn't miss anything....I'm not sure what happened to that link. Here it is again:

    http://www.vbforums.com/showthread.p...ass&highlight=
    My usual boring signature: Nothing

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width