Solved

streaming data across a network

Posted on 1998-05-15
6
294 Views
Last Modified: 2011-02-20
I am trying to figure out how to stream data from a server to a across the network.  I am using UDP since it needs to be fast and I only need the latest packets.  The problem I have is how does the server know that it is sending packets to fast?  If I kill the server the client will still be receiving data for a while afterwards.  If the client and the server are both on local machines this will not happen so it seems that stuff is getting delayed on the network?

So the root of the question is how do I find the optimal speed to send datagrams?
0
Comment
Question by:micah
  • 4
6 Comments
 

Expert Comment

by:knollc
Comment Utility
Network broadcasts through UDP is definitely slower than local communication.   I would suggest having the logic about what is 'too fast' to be determined by the client.  The client can determine if it needs to buffer for a while before starting to display the stream of data based on how fast they are being received.  Although you do indicate that the latest packet is the only relavent packet, I fail to see a problem with the server sending packets too quickly.  The only issue is:  "are there too many packets being sent over the network to cause network congestion problems?"   Can you be more specific about what exactily is the problem that you need solved?


0
 

Author Comment

by:micah
Comment Utility
To me it seemed that if the Server is piping datagrams to the network at say 50/second and the Client hardware is receiving datagrams at 40/second.  Then as time goes on the client will be getting older and older datagrams.  Basically I want the client(s) to get datagrams as fast as possible.  I think the key here is when I kill the server I want the client to also stop getting data.  As it stands now the client continues to print data for quite a while, suggesting a substantial lag.   Since if I kill the server and then see the last datagram the server sent show up at the client a few seconds later.  When I start the server I don't notice any delay as to when the first datagram arives.

Performance is a high priority.  So I need the quickest way to get about 144 bytes of data to all concerned clients.  This is a starting point I am planning to also having each client also sending similar data to all the other clients.  In otherwords each machine has the same set of devices and needs to get all the data from each device.

Maybe it would clear things up if I said this was for tying together VR environments and each device is actually a sensor on a person.  So I will have 'x' number of people imersed.  I want to tie each person together by sending the current location of each sensor.  

Wether or not this is feasable in Java is part of the experiment here.  Hopefully as I progress in this Java performance will increase.  From what I  hear after jdk 1.2 work will be focused on performance and stability.

Thanks
0
 
LVL 5

Accepted Solution

by:
fontaine earned 200 total points
Comment Utility
I am not sure that you really understand how flow control works in networking. When a machine A and a machine B try to communicate, their transpost layer synchronize their speed for transmission. This means that the data transmission rate of a too fast machine will decrease to adapt to the speed of the slower receiving machine. This operation is transparent to the programmer and is handled by the transport protocol layer (UDP, TCP, or other). The transport layer protocols make use of buffers in order to not block the server: the application gives the data to the transport layer and the transport layer sends them at the adequate rate. This explains why data can continue to be transmitted even if the server has been killed.

Now, if you want the client to stop treating data as soon as the server decides it, you have to work with another socket, dedicated to the sending of management packets. For example, the packet could be tagged with an ID and the server could send on this socket the ID of the last pack to treat. Then, packets packets with a greater ID coming from the data socket would
not be taken into account.

Finally, be very careful with UDP: data is not guarenteed to be delivered and the receiver can receive a packet more than once.


   Now, if your application generates a lot of data, there is a buffering mechanism that prevents your application to block: the
   application gives the data to the underlying protocol layers, that will buffer the data until they can transmit them.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 5

Expert Comment

by:fontaine
Comment Utility
Ooops, the last paragraph was not part of the answer. I forgot to delete it when I wrote the answer.
0
 
LVL 5

Expert Comment

by:fontaine
Comment Utility
Also, with UDP, you don't have the guarantee that the packets will be delivered in sequence. If the server sends the packet A, then the packet B, the client will maybe receive B before A.

My reference for Java networking is the following book. I really recommend you it:

Java Network Programming
Merlin and Conrad Hugues, Michael Shoffner, Maria Winslow
Manning
ISBN: 1-884777-34-1
0
 
LVL 5

Expert Comment

by:fontaine
Comment Utility
My apologies, micah. I indeed talked about flow control, but there is no congestion avoidance mechanism with UDP. Thinking deeper about your problem, I really beleive that UDP is not the way to go. Amongst other things, the fact that you want to deliver data ASAP using a protocol that does not guarentee the delivery seems somewhat contradictory to me. In fact, your requirements seem close to the ones of a chat system. In a chat system, one wants - ideally - to communicate in real time with several persons. The amount of data sent is each time a sentence, i.e. a few bytes. All the chat systems I know about use TCP/IP. What is costly with TCP/IP is the establishment of the connection, but this has to be done only once, at the starting of the chat client: subsequent calls are made on the same connection. You can find information on how to build a chat system here:

http://www.javaworld.com/javaworld/jw-01-1997/jw-01-chat.html
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now