LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VOICE over UDP need some help here

I have attached a vi i have been working on and i am having a litte trouble.  I want to do somethink like voice over ip.  Currently i have a setup that broadcasts the data to a client.  The mic is sent over udp to the clients speakers and vice versa. I ingore anything that comes from one's one ip address.  This works just great,  but the problem is i need more than 2 on at a time.  I dont want to mess with entering specific ip address ect. At most i only want to have to enter ones own ip address as i have in the example.  
When i start running 3 of these vi's on separate machines, i can probe the address which the data is being received, and it seems to only get data from one address, not two like i would expect.  Is there a buffer being cleared when read or something?   Any help would be appreciated.
Thanks
Dave
0 Kudos
Message 1 of 17
(4,948 Views)

I have looked at your code and tweaked it a bit so if you get an error you will at least be able to tell that it happened. I also added a stop button so everything gets deinitialized properly.

But I see one rather fundamental problem. Your code is assuming that the data is coming through error-free. This is a problem because the UDP protocol does no error checking what so ever. If you get a datagram it might be garbled, or it might not show up at all. Likewise, two datagrams might even show up at the receiver out of order because they took different routes to get through.

Now having said that, I'm also a little confused why you need the "filter" to ignore your own messages. The datagrams are being sent to a specific IP address so you shouldn't see your own transmissions.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 17
(4,928 Views)

Just did a little more research. The reason for your basic problem is that you are wanting to have a single receiver getting datagrams from multiple transmitters--that is called a multicast. UDP like you are doing it is a point-to-point connection. Check out LV app note 160. Pay particular attention to the "delivery problems" cited on the first page. It mentions another problem I forgot about. You can actually get the same datagram twice!

Mike...


Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 3 of 17
(4,925 Views)
Thanks for the small mods, to the program. I usually dont leave my vi's this sloppy but i am more woried about the funcionality right now, and will finish properly later on.  
Maybe i was not to clear in my first post. The reason i need to filter out messages coming to myself is that i want to broadcast the data using the address 255.255.255.255
this means that it goes out to everyone on my small network, including myself again.   I will read up some more on multicasting, I guess that i did not realize that is what i needed. Ill keep you posted, thanks again for the help.
 
0 Kudos
Message 4 of 17
(4,895 Views)
I have tried using multicasting and it is still behaving the same.  It only wants to read from one ip address when i run 3 of these vi's.  It is not always the same one that is reads from, but once it reads one one ip address it does not read from the other.  Any ideas?
0 Kudos
Message 5 of 17
(4,884 Views)
You keep talking about wanting to do multicasting.  I'm not so sure this is the best way to go (as you're undoubtably realizing).

My suggestion would be to set up a client-server type system, whereby all the clients connect to a single server application that receives data and then sends it out to the list of clients connected.  Now of course, error checking is a big issue here, especially if you include any clients that are outside your local network.

If you don't want clients to have to type in the IP address of the server, set the server up on a machine that has a static IP, or use a dynamic DNS service (such as dyndns.org) to allow you to hard-code an address into your clients. 

I hope this makes sense. 

--Randall
0 Kudos
Message 6 of 17
(4,867 Views)
I thought about trying this route but i still have a problem. Why cant i receive data on the same udp port from multiple senders?  I could do the server idea with different ports for each client i guess, but then i would have to know how many clients i will have. (could be 3, could be 6) i would never know. 
0 Kudos
Message 7 of 17
(4,864 Views)
okay, i think i have got something that will work at least for receiving the packets.  Now i am into another problem.  How do i combine the16bit digital sounds from each client and play them so that it is not choppy. Can i just add them?
0 Kudos
Message 8 of 17
(4,857 Views)
Here is how I have dealt with the port problem in the past (albeit, not in labview, but lets hope LabView's usage of UDP is consistent with other programming languages 🙂 ) is you always have clients connect to a listen port on the server.  You will have a thread watching for incoming connections on that port.  When one is detected, you create a new "personalized" connection for that client to use to communicate with the server.  Part of this process involves assigning that conenction a new port.  This assignment is dynamic--the server just assigns some random available port (so in other words, you don't have to hard code one in).

So once a client connects, the server responds from the new port, the client receives that datagram and checks where it came from (address and port) and sends all future messages to that port on the server.

Does this make sense?  I'm afraid I won't be much help with anything aside from theory as I haven't actually played with the network functionality in labview--all my network programming comes from C and Java. 

As to combining the sounds, I'm afraid I don't know.  I think the simplest system would be a half-duplex system whereby clients can only send data when they are not receiving it (or rather, 1 person talks at a time).  I can understand how this isn't ideal.  I wonder how this is accomplished in other, similar voice-chat programs?

One final thought: I'm not sure, but I'd be willing to make a wild stab in the dark and say you might run into bandwidth problems if you're transmitting an unencoded (uncompressed) voice signal.  This is undoubtably more complex than you want to get, but you might look around for ways to reduce the amount of bandwidth you're going to use.  And if you'd like examples of programs that will allow this kind of chat go check out Teamspeak (http://www.teamspeak.org/) or Skype (http://www.skype.com/).  Both these programs allow multiuser voice chat (teamspeak is intended for chatting with your team in video games).  Skype is a very professional, very high quality voice chat program that works more or less the same, with higher quality voice.  Oh and both are free 🙂

--R
0 Kudos
Message 9 of 17
(4,852 Views)
Thanks ill try those applications, i am afraid this is turning into more of a headache than it is worth. 🙂
I am curious to see how the sounds are combined though.   I was a little worried about band width, but so far with 2 users it has not been a problem. Ill let you know how the other apps work. Thanks!!
Dave
0 Kudos
Message 10 of 17
(4,850 Views)