Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 7 of 7

Thread: how to send udp packet inorder to compute packet loss ?

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to send udp packet inorder to compute packet loss ?

    Hi , All

    I am working on an VOIP application witch require to play the RTP (audio) packet that are comming from the RTP server throught UDP connection ,
    how to send RTP packet inorder to compute packet loss ?Whether can provide an example reference
    Last edited by NARs; October 23rd, 2009 at 03:12 AM.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?

    Why not use TCP instead then?

    Have a look at Apache MINA - Index for some nice tools for networking

    // Json

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?

    Because I don't mind to loss the packet.
    so do you know how to send packet to server ?

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?


  5. #5
    Junior Member
    Join Date
    Oct 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?

    json~
    thanks for your help!
    i have write client connect server , but i don't know how to send packet to server ?
    i am require to play the RTP (audio) packet that are comming from the RTP server throught UDP connection ,
    how to send RTP packet to server inorder to reply the packet loss to client ?

  6. #6
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?

    As simple example have a look at http://java.sun.com/docs/books/tutor...verThread.java

    Here is an extract of the code.

        public void run() {
     
            while (moreQuotes) {
                try {
                    byte[] buf = new byte[256];
     
                        // receive request
                    DatagramPacket packet = new DatagramPacket(buf, buf.length);
                    socket.receive(packet);
     
                        // figure out response
                    String dString = null;
                    if (in == null)
                        dString = new Date().toString();
                    else
                        dString = getNextQuote();
                    buf = dString.getBytes();
     
    		    // send the response to the client at "address" and "port"
                    InetAddress address = packet.getAddress();
                    int port = packet.getPort();
                    packet = new DatagramPacket(buf, buf.length, address, port);
                    socket.send(packet);
                } catch (IOException e) {
                    e.printStackTrace();
    		moreQuotes = false;
                }
            }
            socket.close();
        }

    Above you can see that it takes a string in this case and puts it in the byte array buffer called buf. It then creates a DatagramPacket using this buf variable and then it sends the packet off using the socket.send method.

    What you need to do us open up a stream to your file, read the file and while you are reading it, pass the data of the stream out as packets to the socket.

    // Json

  7. #7
    Junior Member
    Join Date
    Oct 2009
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: how to send udp packet inorder to compute packet loss ?

    json :
    thanks for you help!
    but i am require to play the RTP (audio) packet that are comming from the RTP server throught UDP connection , do you have any example about this ?To the best of my knowledge , it's looks like have to using JMF , but i don't know how to using jmf ?

Similar Threads

  1. send image (logo) and text & barcode to the Zebra Printer
    By ehsanlinux in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 11th, 2011, 05:41 AM
  2. Problem on sending vectors from Java server to C# client
    By MS_Dark in forum Java Networking
    Replies: 2
    Last Post: July 7th, 2009, 02:35 PM
  3. How to Send command line arguments in Eclipse?
    By JavaPF in forum Java JDK & IDE Tutorials
    Replies: 0
    Last Post: April 23rd, 2009, 11:37 AM
  4. UDP server sends thread application
    By Koren3 in forum Threads
    Replies: 2
    Last Post: April 20th, 2009, 11:46 AM