What to do with received udp packet

Hello I can finally send and receive data with udp.
But now I receive a packet
socket.receive(packet);
But how can I get the ipaddress, portnumber and data from the packet?
I know I can get the byte length with socket.getLength.

did you bother looking at the API docs for DatagramPacket?

Similar Messages

  • Not receiving UDP packet with Windows

    Using a Windows 2000 Professional system I send a UDP packet (DatagramSocket()/DatagramPacket()) to a server, which returns a UDP packet on the same socket. Simple textbook stuff! The Java application works fine on a Linux machine, but catches an SocketException with "socket closed" message from the receive() method when run on a Windows 2000 machine. What gives? I have disabled the security checks and still can't get the packet. Any suggestions? (other than ditch Windows)

    I got the same problem. I ran the identical program on WinXP and no exception! What's the cause for this? How to avoid it?
    Thanks,

  • Sending udp packets using java and receiving it using c

    hi,
    Is it possible to send udp packets using java and receive the same using c??????? if yes.... plz help immediately.

    The biggest issue is data format. The JVM is big endian, with 16-bit characters. The machine running 'C' could be almost anything. A (signed!) byte array is probably the easiest unit of exchange.
    The Java program has its own techniques for storing/retrieving data to/from the byte array - and the C program has its own techniques. ASCII Strings are often the easiest to exchange - just convert the java String objects to byte array and send them.
    apaliwal1 has already given the UDP calls to send/receive the data.

  • What is wrong with my Iphone 4s when it won't alert me by sound when text is received

    What is wrong with my Iphone 4s when it wont alert me by sound when text is received?

    You use the side control and make sure your phone isn't on vibrate.  Up is for ringer down is for vibrate.

  • Problem with receiving of the UDP multicasting on multiple interfaces in the W2K12 cluster

    Hi,
    I have my .NET application which receives the UDP multicasting communication. It works fine until it is deployed on a W2K12 cluster. Some multicast groups are still available and some are not in the cluster. The
    problem is caused by the cluster which creates a virtual interface for a inter-node communication. When the cluster is on and my app is trying to subscibe to the affected group then IGMP packets are routed to the cluster's
    virtual interface where the multicast communication is not available. When the cluster (cluster service) is off all groups are available and IGMP is routed to a right interface.
    I also have a different application which is not based on .NET and it receives all multicast groups in any deployment (same W2K12 clustered server). So, I guess that in my app I have to tell to the socket somehow, which local interface should
    be used for a particular multicast group. In my app I use code below for a group subscribtion, but I still can't manage routing of IGMP to a right local interface. Can you help me?
    As you can see in the code example I try to mapp a group to a local interface using its IP and index using MulticastOption class, but it has no effect. Different interface (cluster's virtual interface) is used for a IGMP
    subscribtion. I also tried to bind\set local interface to Any, but without success.
    It seems that there is some OS logic which overrides my setup. But, it must be possible to do the socket setup correctlly because non .NET application works fine.
    Thanks.
    Regards,
    Marek
    public void Start(string[] args)
    //args[0] - multicast group
    //args[1] - multicast port
    //args[2] - local interface IP
    //args[3] - local interface index
    UdpClient udp = new UdpClient();
    udp.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
    udp.Client.Bind(new IPEndPoint(IPAddress.Parse(args[2]), Convert.ToInt32(args[1])));
    MulticastOption mcastOption = new MulticastOption(IPAddress.Parse(args[0]));
    mcastOption.LocalAddress = IPAddress.Parse(args[2]);
    mcastOption.InterfaceIndex = int.Parse(args[3]);
    udp.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, mcastOption);
    udp.BeginReceive(new AsyncCallback(Receive), udp);

    I don’t know if it will help you but I can illustrate my problem on the following prints from netsh and route tools. First print from netsh shows that the affected group 224.0.46.232 is assigned to interface 20. Second print shows
    that interface 20 is Microsoft Failover Cluster Virtual Adapter where multicast communication is not available.
    When the test app, which works fine, is used than these prints show that group 224.0.46.232 is assigned to interface 19 - Microsoft Network Adapter Multiplexor Driver, where multicast communication is available.
    So, the question is how to manage these „prints“ to requested setup in .NET.
    Regards,
    Marek
    C:\Windows\system32>netsh interface ip show joins
    Interface 1: Loopback Pseudo-Interface 1
    Scope       References  Last  Address
    0                    0  Yes   239.255.255.250
    Interface 20: Local Area Connection* 12
    Scope       References  Last  Address
    0                    0  Yes   224.0.0.1
    0                    1  Yes   224.0.0.252
    0                    1  Yes   224.0.46.232
    Interface 19: Public
    Scope       References  Last  Address
    0                    0  No    224.0.0.1
    0                    1  No    224.0.0.252
    0                    0  Yes   239.255.255.250
    C:\Windows\system32>route print
    ===========================================================================
    Interface List
    19...3c d9 2b ef 8a ec ......Microsoft Network Adapter Multiplexor Driver
    20...02 91 08 09 1a ae ......Microsoft Failover Cluster Virtual Adapter
      1...........................Software Loopback Interface 1
    16...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter
    21...00 00 00 00 00 00 00 e0 Microsoft ISATAP Adapter #3
    ===========================================================================

  • HT1212 my iphone 5's screen blacks out every now and then. the phone is turned on but the screen is black and i can receive calls. what is wrong with my phone

    my iphone 5's screen blacks out every now and then. the phone is turned on but the screen is black and i can receive calls. what is wrong with my phone?

    I have to believe this has something to do with iOS 7 issues. I have taken my screen blacked out 5s twice to the Genius Bar and the found a bunch of system apps had crashed.  So if this is the case, is iOS7 the problem?

  • When I try and open a word document I received the following message:  "You cant open the application Microsoft Word because PoerPC applications are no longer supported".  What is up with that?

    When I try and open a word document I received the following message:  "You cant open the application Microsoft Word because PoerPC applications are no longer supported".  What is up with that?

    Here is a post that I assembled for a similar question:
    Unfortunately you got caught up in the minor miracle of Rosetta.  Originally licensed by Apple when it migrated from the PowerPC CPU platform that it had used from the mid-1990's until the Intel CPU platform in 2006, Rosetta allowed Mac users to continue to use their library of PPC software transparently in emulation.
    However, Apple's license to continue to use this technology expired with new releases of OS X commencing with Lion (and now Mountain Lion).  While educational efforts have been made over the last 6 years, the fact is that Rosetta was SO successful that many users were caught unaware UNTIL they upgraded to Lion or Mountain Lion.
    Workarounds:
    1. If your Mac will support it, restore OS X Snow Leopard;
    2.  If your Mac will support it, partition your hard drive or add an external hard drive and install Snow Leopard into it and use the "dual-boot" method to choose between your PowerPC software or Lion/Mt. Lion;
    3.  Upgrade your software to Intel compatible versions, or find alternative software that will open your data files;
    3.  Install Snow Leopard (with Rosetta) into Parallels:
                                  [click on image to enlarge]
    Full Snow Leopard installation instructions here:
    http://forums.macrumors.com/showthread.php?t=1365439
    NOTE: STEP ONE of the instructions must currently be completed on a Snow Leopard or Lion Mac and the resulting modified Snow Leopard.cdr install file can then be moved over to your Mountain Lion Mac for completion of the remaining steps.
    NOTE 2:  Computer games with complex, 3D or fast motion graphics make not work well or at all in virtualization.

  • UDPevent? What should I use to make an event when an UDP packet arrives?

    every time my machine gets an UDP packet I need to write out the time(within millisec), and therefor I need to find an eventnotifier of some kind that checks for UDP packets arriving..

    oki.. so I'm building a class for reciving the packets.. I guess i should use a thread since my program allredy is reciving these packets whit JMF - reciveStream.
    now the problem is, how do I write out the time for each packet, i cant seem to find any events i can use for this, and as far as I can see, the datagarmsocket is listening for the packets and doing something with them(**) without somewhere for me to put the: System.out.printeln(time);
    (**) I am going to write the packets to a file and parse it for the sequence numbers, how do I do this?

  • My (postage stamp icon) mail program will not send outgoing mail - only receives, what's up with that?

    My (postage stamp icon) mail program will not send outgoing mail - only receives mail.
    Says the outgoing mail server is wrong, but Comcast says it's right - what's up with that?
    Is there a way to reload the standard (postage stamp icon) mail program?

    Clearly there's something wrong with the configuration. Reverting to some other mail application (whatever the 'standard' one is...) won't help.
    What does the Connection Doctor (Mail -> Window -> Connection Doctor) have to say about it?
    Chances are your username/password for your SMTP server are incorrect.

  • I bought 120 gold in Haypi dragon on Mar 12 and 15 2012 , but I havenot received them yet.What is wrong with it ,and when i can reveive them ?

    I bought 120 gold in Haypi dragon on Mar 12 and 15 2012 , but I havenot received them yet.What is wrong with it ,and when i can reveive them ?

    For in-app purchases you should contact the developer's customer support, assuming there is one.

  • TA21328 every time I use Safari I receive a message that says Safari is no longer responding because of a script problem with the website and I must press "continue" for the page to continue. This happens with every website I go to.  What is wrong with my

    When using Safari I have begun to notice this box appearing as I try to reach any website:  "Safari is no longer responding because of a script on the webpage and then it lists what ever web page I have tried to reach.  It then asks me if I want to "stop" the script or allow it to continue.  I must "continue" it in order to reach my web page/  If I press "stop" it just keeps coming back and back and I can't continue.  What is wrong with my computer or Sarari or both?

    chick --
    Does it mention "Slow Script?

  • JMF How to stream rtp from udp packet

    I implemented an rtsp client and use the client to setup two rtp session(audio, vedio). But when I use the example pramgram "AVReceive3" to stream the udp packet, it doesn't work.
    When the AVReceive3 receive the udp packet from the rtp port, it will call the update(ReceiveStreamEvent evt) function, and the event type is StreamMappedEvent, and the call to evt.getReceiveStream().getDataSource() return null.
    I thought the first event should be NewReceiveStreamEvent. Please help to solve the problem.
    What's rtp packet will cause the event StreamMappedEvent.
    Following is the code of AVReceive3.java:
    * AVReceive3.java
    * Created on 2007年10月30日, 下午4:11
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package PlayerTest;
    import java.io.*;
    import java.awt.*;
    import java.net.*;
    import java.awt.event.*;
    import java.util.Vector;
    import javax.media.*;
    import javax.media.rtp.*;
    import javax.media.rtp.event.*;
    import javax.media.rtp.rtcp.*;
    import javax.media.protocol.*;
    import javax.media.protocol.DataSource;
    import javax.media.format.AudioFormat;
    import javax.media.format.VideoFormat;
    import javax.media.Format;
    import javax.media.format.FormatChangeEvent;
    import javax.media.control.BufferControl;
    * AVReceive3 to receive RTP transmission using the RTPConnector.
    public class AVReceive3 extends Thread implements ReceiveStreamListener, SessionListener,
    ControllerListener
    String sessions[] = null;
    RTPManager mgrs[] = null;
    Vector playerWindows = null;
    boolean dataReceived = false;
    Object dataSync = new Object();
    public AVReceive3(String sessions[])
    this.sessions = sessions;
    public void run()
    initialize();
    public boolean initialize() {
    try {
    mgrs = new RTPManager[sessions.length];
    playerWindows = new Vector();
    SessionLabel session;
    // Open the RTP sessions.
    for (int i = 0; i < sessions.length; i++) {
    // Parse the session addresses.
    try {
    session = new SessionLabel(sessions);
    } catch (IllegalArgumentException e) {
    System.err.println("Failed to parse the session address given: " + sessions[i]);
    return false;
    System.err.println(" - Open RTP session for: addr: " + session.addr + " port: " + session.port + " ttl: " + session.ttl);
    mgrs[i] = (RTPManager) RTPManager.newInstance();
    mgrs[i].addSessionListener(this);
    mgrs[i].addReceiveStreamListener(this);
    // Initialize the RTPManager with the RTPSocketAdapter
    mgrs[i].initialize(new RTPSocketAdapter(
    InetAddress.getByName(session.addr),
    session.port, session.ttl));
    // You can try out some other buffer size to see
    // if you can get better smoothness.
    BufferControl bc = (BufferControl)mgrs[i].getControl("javax.media.control.BufferControl");
    if (bc != null)
    bc.setBufferLength(350);
    } catch (Exception e){
    System.err.println("Cannot create the RTP Session: " + e.getMessage());
    return false;
    // Wait for data to arrive before moving on.
    long then = System.currentTimeMillis();
    long waitingPeriod = 30000; // wait for a maximum of 30 secs.
    try{
    synchronized (dataSync) {
    while (!dataReceived &&
    System.currentTimeMillis() - then < waitingPeriod) {
    if (!dataReceived)
    System.err.println(" - Waiting for RTP data to arrive");
    dataSync.wait(1000);
    } catch (Exception e) {}
    if (!dataReceived) {
    System.err.println("No RTP data was received.");
    close();
    return false;
    return true;
    public boolean isDone() {
    return playerWindows.size() == 0;
    * Close the players and the session managers.
    protected void close() {
    for (int i = 0; i < playerWindows.size(); i++) {
    try {
    ((PlayerWindow)playerWindows.elementAt(i)).close();
    } catch (Exception e) {}
    playerWindows.removeAllElements();
    // close the RTP session.
    for (int i = 0; i < mgrs.length; i++) {
    if (mgrs[i] != null) {
    mgrs[i].removeTargets( "Closing session from AVReceive3");
    mgrs[i].dispose();
    mgrs[i] = null;
    PlayerWindow find(Player p) {
    for (int i = 0; i < playerWindows.size(); i++) {
    PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
    if (pw.player == p)
    return pw;
    return null;
    PlayerWindow find(ReceiveStream strm) {
    for (int i = 0; i < playerWindows.size(); i++) {
    PlayerWindow pw = (PlayerWindow)playerWindows.elementAt(i);
    if (pw.stream == strm)
    return pw;
    return null;
    * SessionListener.
    public synchronized void update(SessionEvent evt) {
    if (evt instanceof NewParticipantEvent) {
    Participant p = ((NewParticipantEvent)evt).getParticipant();
    System.err.println(" - A new participant had just joined: " + p.getCNAME());
    * ReceiveStreamListener
    public synchronized void update( ReceiveStreamEvent evt) {
    System.out.println("\nReceive an receiveStreamEvent:"+evt.toString());
    RTPManager mgr = (RTPManager)evt.getSource();
    Participant participant = evt.getParticipant(); // could be null.
    ReceiveStream stream = evt.getReceiveStream(); // could be null.
    System.out.println("The RTPManager is:");
    if (evt instanceof RemotePayloadChangeEvent) {
    System.err.println(" - Received an RTP PayloadChangeEvent.");
    System.err.println("Sorry, cannot handle payload change.");
    System.exit(0);
    else if (evt instanceof NewReceiveStreamEvent) {
    try {
    stream = ((NewReceiveStreamEvent)evt).getReceiveStream();
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    if (ctl != null){
    System.err.println(" - Recevied new RTP stream: " + ctl.getFormat());
    } else
    System.err.println(" - Recevied new RTP stream");
    if (participant == null)
    System.err.println(" The sender of this stream had yet to be identified.");
    else {
    System.err.println(" The stream comes from: " + participant.getCNAME());
    // create a player by passing datasource to the Media Manager
    Player p = javax.media.Manager.createPlayer(ds);
    if (p == null)
    return;
    p.addControllerListener(this);
    p.realize();
    PlayerWindow pw = new PlayerWindow(p, stream);
    playerWindows.addElement(pw);
    pw.setVisible(true);
    // Notify intialize() that a new stream had arrived.
    synchronized (dataSync) {
    dataReceived = true;
    dataSync.notifyAll();
    } catch (Exception e) {
    System.err.println("NewReceiveStreamEvent exception " + e.getMessage());
    return;
    else if (evt instanceof StreamMappedEvent) {
    if (stream != null)
    if(stream.getDataSource()!=null)
    DataSource ds = stream.getDataSource();
    // Find out the formats.
    RTPControl ctl = (RTPControl)ds.getControl("javax.media.rtp.RTPControl");
    System.err.println(" - The previously unidentified stream ");
    if (ctl != null)
    System.err.println(" " + ctl.getFormat());
    System.err.println(" had now been identified as sent by: " + participant.getCNAME());
    else if (evt instanceof ByeEvent) {
    System.err.println(" - Got \"bye\" from: " + participant.getCNAME());
    PlayerWindow pw = find(stream);
    if (pw != null) {
    pw.close();
    playerWindows.removeElement(pw);
    * ControllerListener for the Players.
    public synchronized void controllerUpdate(ControllerEvent ce) {
    Player p = (Player)ce.getSourceController();
    if (p == null)
    return;
    // Get this when the internal players are realized.
    if (ce instanceof RealizeCompleteEvent) {
    PlayerWindow pw = find(p);
    if (pw == null) {
    // Some strange happened.
    System.err.println("Internal error!");
    System.exit(-1);
    pw.initialize();
    pw.setVisible(true);
    p.start();
    if (ce instanceof ControllerErrorEvent) {
    p.removeControllerListener(this);
    PlayerWindow pw = find(p);
    if (pw != null) {
    pw.close();
    playerWindows.removeElement(pw);
    System.err.println("AVReceive3 internal error: " + ce);
    * A utility class to parse the session addresses.
    class SessionLabel {
    public String addr = null;
    public int port;
    public int ttl = 1;
    SessionLabel(String session) throws IllegalArgumentException {
    int off;
    String portStr = null, ttlStr = null;
    if (session != null && session.length() > 0) {
    while (session.length() > 1 && session.charAt(0) == '/')
    session = session.substring(1);
    // Now see if there's a addr specified.
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    addr = session;
    } else {
    addr = session.substring(0, off);
    session = session.substring(off + 1);
    // Now see if there's a port specified
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    portStr = session;
    } else {
    portStr = session.substring(0, off);
    session = session.substring(off + 1);
    // Now see if there's a ttl specified
    off = session.indexOf('/');
    if (off == -1) {
    if (!session.equals(""))
    ttlStr = session;
    } else {
    ttlStr = session.substring(0, off);
    if (addr == null)
    throw new IllegalArgumentException();
    if (portStr != null) {
    try {
    Integer integer = Integer.valueOf(portStr);
    if (integer != null)
    port = integer.intValue();
    } catch (Throwable t) {
    throw new IllegalArgumentException();
    } else
    throw new IllegalArgumentException();
    if (ttlStr != null) {
    try {
    Integer integer = Integer.valueOf(ttlStr);
    if (integer != null)
    ttl = integer.intValue();
    } catch (Throwable t) {
    throw new IllegalArgumentException();
    * GUI classes for the Player.
    class PlayerWindow extends Frame {
    Player player;
    ReceiveStream stream;
    PlayerWindow(Player p, ReceiveStream strm) {
    player = p;
    stream = strm;
    public void initialize() {
    add(new PlayerPanel(player));
    public void close() {
    player.close();
    setVisible(false);
    dispose();
    public void addNotify() {
    super.addNotify();
    pack();
    * GUI classes for the Player.
    class PlayerPanel extends Panel {
    Component vc, cc;
    PlayerPanel(Player p) {
    setLayout(new BorderLayout());
    if ((vc = p.getVisualComponent()) != null)
    add("Center", vc);
    if ((cc = p.getControlPanelComponent()) != null)
    add("South", cc);
    public Dimension getPreferredSize() {
    int w = 0, h = 0;
    if (vc != null) {
    Dimension size = vc.getPreferredSize();
    w = size.width;
    h = size.height;
    if (cc != null) {
    Dimension size = cc.getPreferredSize();
    if (w == 0)
    w = size.width;
    h += size.height;
    if (w < 160)
    w = 160;
    return new Dimension(w, h);
    public static void main(String argv[]) {
    //if (argv.length == 0)
    // prUsage();
    String sessions[]= new String[] {"127.0.0.1/6670","127.0.0.1/6672"};
    AVReceive3 avReceive = new AVReceive3(sessions);
    if (!avReceive.initialize()) {
    System.err.println("Failed to initialize the sessions.");
    System.exit(-1);
    // Check to see if AVReceive3 is done.
    try {
    while (!avReceive.isDone())
    Thread.sleep(1000);
    } catch (Exception e) {}
    System.err.println("Exiting AVReceive3");
    static void prUsage() {
    System.err.println("Usage: AVReceive3 <session> <session> ");
    System.err.println(" <session>: <address>/<port>/<ttl>");
    System.exit(0);
    }// end of AVReceive3
    Following is the code of RTPSocketAdapter.java:
    * RTPSocketAdapter.java
    * Created on 2007&#24180;10&#26376;30&#26085;, &#19979;&#21320;4:13
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package PlayerTest;
    import java.io.IOException;
    import java.net.InetAddress;
    import java.net.DatagramSocket;
    import java.net.MulticastSocket;
    import java.net.DatagramPacket;
    import java.net.SocketException;
    import javax.media.protocol.DataSource;
    import javax.media.protocol.PushSourceStream;
    import javax.media.protocol.ContentDescriptor;
    import javax.media.protocol.SourceTransferHandler;
    import javax.media.rtp.RTPConnector;
    import javax.media.rtp.OutputDataStream;
    * An implementation of RTPConnector based on UDP sockets.
    public class RTPSocketAdapter implements RTPConnector {
    DatagramSocket dataSock;
    DatagramSocket ctrlSock;
    InetAddress addr;
    int port;
    SockInputStream dataInStrm = null;
    SockInputStream ctrlInStrm = null;
    SockOutputStream dataOutStrm = null;
    SockOutputStream ctrlOutStrm = null;
    public RTPSocketAdapter(InetAddress addr, int port) throws IOException {
    this(addr, port, 1);
    public RTPSocketAdapter(InetAddress addr, int port, int ttl) throws IOException {
    try {
    if (addr.isMulticastAddress()) {
    dataSock = new MulticastSocket(port);
    ctrlSock = new MulticastSocket(port+1);
    ((MulticastSocket)dataSock).joinGroup(addr);
    ((MulticastSocket)dataSock).setTimeToLive(ttl);
    ((MulticastSocket)ctrlSock).joinGroup(addr);
    ((MulticastSocket)ctrlSock).setTimeToLive(ttl);
    } else {
    dataSock = new DatagramSocket(port, InetAddress.getLocalHost());
    ctrlSock = new DatagramSocket(port+1, InetAddress.getLocalHost());
    } catch (SocketException e) {
    throw new IOException(e.getMessage());
    this.addr = addr;
    this.port = port;
    * Returns an input stream to receive the RTP data.
    public PushSourceStream getDataInputStream() throws IOException {
    if (dataInStrm == null) {
    dataInStrm = new SockInputStream(dataSock, addr, port);
    dataInStrm.start();
    return dataInStrm;
    * Returns an output stream to send the RTP data.
    public OutputDataStream getDataOutputStream() throws IOException {
    if (dataOutStrm == null)
    dataOutStrm = new SockOutputStream(dataSock, addr, port);
    return dataOutStrm;
    * Returns an input stream to receive the RTCP data.
    public PushSourceStream getControlInputStream() throws IOException {
    if (ctrlInStrm == null) {
    ctrlInStrm = new SockInputStream(ctrlSock, addr, port+1);
    ctrlInStrm.start();
    return ctrlInStrm;
    * Returns an output stream to send the RTCP data.
    public OutputDataStream getControlOutputStream() throws IOException {
    if (ctrlOutStrm == null)
    ctrlOutStrm = new SockOutputStream(ctrlSock, addr, port+1);
    return ctrlOutStrm;
    * Close all the RTP, RTCP streams.
    public void close() {
    if (dataInStrm != null)
    dataInStrm.kill();
    if (ctrlInStrm != null)
    ctrlInStrm.kill();
    dataSock.close();
    ctrlSock.close();
    * Set the receive buffer size of the RTP data channel.
    * This is only a hint to the implementation. The actual implementation
    * may not be able to do anything to this.
    public void setReceiveBufferSize( int size) throws IOException {
    dataSock.setReceiveBufferSize(size);
    * Get the receive buffer size set on the RTP data channel.
    * Return -1 if the receive buffer size is not applicable for
    * the implementation.
    public int getReceiveBufferSize() {
    try {
    return dataSock.getReceiveBufferSize();
    } catch (Exception e) {
    return -1;
    * Set the send buffer size of the RTP data channel.
    * This is only a hint to the implementation. The actual implementation
    * may not be able to do anything to this.
    public void setSendBufferSize( int size) throws IOException {
    dataSock.setSendBufferSize(size);
    * Get the send buffer size set on the RTP data channel.
    * Return -1 if the send buffer size is not applicable for
    * the implementation.
    public int getSendBufferSize() {
    try {
    return dataSock.getSendBufferSize();
    } catch (Exception e) {
    return -1;
    * Return the RTCP bandwidth fraction. This value is used to
    * initialize the RTPManager. Check RTPManager for more detauls.
    * Return -1 to use the default values.
    public double getRTCPBandwidthFraction() {
    return -1;
    * Return the RTCP sender bandwidth fraction. This value is used to
    * initialize the RTPManager. Check RTPManager for more detauls.
    * Return -1 to use the default values.
    public double getRTCPSenderBandwidthFraction() {
    return -1;
    * An inner class to implement an OutputDataStream based on UDP sockets.
    class SockOutputStream implements OutputDataStream {
    DatagramSocket sock;
    InetAddress addr;
    int port;
    public SockOutputStream(DatagramSocket sock, InetAddress addr, int port) {
    this.sock = sock;
    this.addr = addr;
    this.port = port;
    public int write(byte data[], int offset, int len) {
    try {
    sock.send(new DatagramPacket(data, offset, len, addr, port));
    } catch (Exception e) {
    return -1;
    return len;
    * An inner class to implement an PushSourceStream based on UDP sockets.
    class SockInputStream extends Thread implements PushSourceStream {
    DatagramSocket sock;
    InetAddress addr;
    int port;
    boolean done = false;
    boolean dataRead = false;
    SourceTransferHandler sth = null;
    public SockInputStream(DatagramSocket sock, InetAddress addr, int port) {
    this.sock = sock;
    this.addr = addr;
    this.port = port;
    public int read(byte buffer[], int offset, int length) {
    DatagramPacket p = new DatagramPacket(buffer, offset, length, addr, port);
    try {
    sock.receive(p);
    } catch (IOException e) {
    return -1;
    synchronized (this) {
    dataRead = true;
    notify();
    System.out.println("RTPSocketAdapter receive RTP packet from port:"+port);
    System.out.println("The received RTP packet:"+new String(buffer));
    return p.getLength();
    public synchronized void start() {
    super.start();
    if (sth != null) {
    dataRead = true;
    notify();
    public synchronized void kill() {
    done = true;
    notify();
    public int getMinimumTransferSize() {
    return 2 * 1024; // twice the MTU size, just to be safe.
    public synchronized void setTransferHandler(SourceTransferHandler sth) {
    this.sth = sth;
    dataRead = true;
    notify();
    // Not applicable.
    public ContentDescriptor getContentDescriptor() {
    return null;
    // Not applicable.
    public long getContentLength() {
    return LENGTH_UNKNOWN;
    // Not applicable.
    public boolean endOfStream() {
    return false;
    // Not applicable.
    public Object[] getControls() {
    return new Object[0];
    // Not applicable.
    public Object getControl(String type) {
    return null;
    * Loop and notify the transfer handler of new data.
    public void run() {
    while (!done) {
    synchronized (this) {
    while (!dataRead && !done) {
    try {
    wait();
    } catch (InterruptedException e) { }
    dataRead = false;
    if (sth != null && !done) {
    sth.transferData(this);
    Thanks.

    The error of No format has been registered for RTP Payload type 96
    is caused by the dynamic payload mapping, when I add the dynamic mapping between dynamic payload and format. The Player cann't work yet. I think it because JMF doesn't support the format of my clips. For example:
    video: a=rtpmap:96 H263-2000/90000
    audio:a=rtpmap:97 MP4A-LATM/12000/1
    Is there some available plugin to support these format?
    Thanks

  • ASA 5510 'bounces' UDP packets. Why?

    Hi. I hope to find someone who can shed a light on something that is bugging me for days now. We have an ASA (5510, running 7.2(2)) to connect our subnets to the backbone of the ISP. I received complaints about one specific connection, which I'll "draw" here:
    [ remote host 192.87.x.y (A) ] -- {"Internet"} -- [ Telecity Router ] -- [ Our ASA ] -- [ switch ] -- [ fibre ] -- [ switch ] -- [ our host 82.199.c.d (B) ]
    What happens is the following: I can successfully ping from A to B and back. I can also traceroute (UDP) from A to B and back. But a specific UDP packet sent by A (port 9001) to B (port 5432) is causing a problem. "Our ASA" does not route the packet to the correct interface, but sends it back to the Telecity router instead. Which in turn sends it back to "Our ASA" (since it is destined for our subnet). This goes back and forth for 60 times and then the TTL is expired.
    I have no idear what is happening here. The access-lists are correctly configured (as far as I know), but even if they weren't I would expect the packets to get dropped rather than put back on the sending interface. This packet is bounced (on ethernetlevel, the IP part remains the same apart from the TTL) to the sending router.
    Any pointers as to where to look for what is causing this and how to investigate this further are highly appreciated.
    Frank

    Hi Frederico. Of course I tried the packet tracer as one of the first tools :-). It showed a complete path (I used ASDM). Now I retried it (via the CLI) and something strange happens. This is a packet trace A to B with udp from port 9001 to 5431 (not 5432):
    Phase: 1
    Type: FLOW-LOOKUP / ALLOW / Found no matching flow, creating a new flow
    Phase: 2
    Type: ROUTE-LOOKUP / ALLOW / in   my_DMZ    255.255.255.240 my_DMZ
    Phase: 3
    Type: ACCESS-LIST / ALLOW / access-group my_backbone_access_in in interface my_backbone
                                                    access-list my_backbone_access_in extended permit ip any my_DMZ 255.255.255.240
    Phase: 4
    Type: IP-OPTIONS / ALLOW
    Phase: 5
    Type: ACCESS-LIST / ALLOW / access-group my_DMZ_access_out out interface my_DMZ
                                                    access-list my_DMZ_access_out extended permit ip any object-group host_group
                                                    object-group network host_group
                                                    network-object host myHost
    Phase: 6
    Type: IP-OPTIONS / ALLOW
    Phase: 7
    Type: FLOW-CREATION / ALLOW / New flow created with id 7342770, packet dispatched to next module
    Phase: 8
    Type: ROUTE-LOOKUP / ALLOW / found next-hop myHost using egress ifc my_DMZ
                                                        adjacency Active
                                                        next-hop mac address 00bb.ccdd.eeff hits 1
    Result:
    input-interface:   my_backbone / input-status: up / input-line-status: up
    output-interface: my_DMZ / output-status: up / output-line-status: up
    Action: allow
    As you can see it is a complete path. But this is what happens if I try it for A/9001 to B/5432:
    Phase: 1
    Type: FLOW-LOOKUP / ALLOW / Found flow with id 12, using existing flow
    Module information for forward flow: snp_fp_inspect_ip_options, snp_fp_adjacency, snp_fp_fragment, snp_ifc_stat
    Module information for reverse flow: snp_fp_inspect_ip_options, snp_fp_adjacency, snp_fp_fragment, snp_ifc_stat
    Result:
    input-interface: my_backbone / input-status: up / input-line-status: up / Action: allow
    Apparently the packet is send into an existing flow (is there a command to see what this flow is?) and that is where it ends. Now I need to find out why this is happening... This firewall has been reloaded a few times, but that did not solve the problem. Any pointers are highly appreciated as was this hint.
    Frank

  • Java NIO - UDP packets

    I'm curious as to the rationale behind having a DatagramPacket class and just using ByteBuffers for TCP connections. I can see the logic, but I'm trying to write a Java framework wrapping NIO with TCP and UDP connections. In my C++ version I have one packet class that I use for both types of connections. I'm stuck with what to implement for Java as I'm going to need two classes, NIO's DatagramPacket and a new TCPPacket. Ideally I would like both to implement an interface or derive from a parent class so I can pass them to all class methods that deal with packets, be they UDP or TCP based. But this won't work. I could wrap DatagramPacket into a new class, and have it and the TCPPacket class implement a Packet interface. But when I'm sending UDP packets I'll be creating two objects for the price of one.
    Any suggestions?
    Thanks

    Remember that in UDP case you can easily lose packets and never know. In TCP you would receive an exception, but UDP can silently discard your packages while in transit.
    My point is, you probably should use a different package class for UDP anyway, maybe adding some stuff like a package ID that would enable re-sending and additional processing in order to ensure a successful communication.
    If you already have this information and some procedures for retrying in your package, then I agree with the previous poster in that you can use bytebuffer for both.

  • How do I create, send and receive ethernet packets to UUT

    I need to create and send ethernet packets to control and communicate with an RF board. I would also like to receive ethernet packets back which would be parsed and interpreted.

    There you are!
    I was wondering how this project was going.
    As I said before, we need to know what protocol is being used.
    Let me eaxplain. (Please refer to the diagrams and tutorial on pages 752-755 of 2002 NI catalog.)
    802.3 is the spec for ethernet. It defines how packets will be transmitted on the wire.
    Real Life analogy:
    US Mail service.
    It moves messages from one place to another. It defines that messages should be in an envelope. The Envelope must have a address so they know where it should be delivered to. You should also have a return address (but this is not enforced). Inside the envelope, you can put any kind of message you want as long as the person recieving it knows how to read it. The
    reciever can look at the message and say "oh, this is english, I will read it in english".
    Ethernet is similar. Ethernet (ignoring the electrical specs) defines a packet as consisting of
    Source address (return address in US mail)
    Destination address (delivery address)
    Protocol (pretend there was a mark on the envelope that said this letter is in French).
    Data (the letter itself)
    Checksum (letter pages number as 1 of 4, 2 of 4, etc).
    So what you have told me so far is that you want to send a letter!
    You have been asking me how to comunicate with the other person but you have not told me what language they speak!
    There are many different languages (i.e. protocol's) possible with 802.3.
    Examples are
    TCP/IP ( say this is English)
    UDP (French)
    etc....
    LV has built in VI's to take a message and convert it to the protocol (lanuage) you want and send it on it's way.
    So my question to you once more is;
    What protocol are you using?
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • Urgent Help Needed - Frozen  disk drive & mouse

    This is quite a complicated situation, but i will put it simply: I woke my mac from its sleep, and went to connect to the internet(wanadoo broadband. It wouldnt do it and went from saying 'connecting....connecting...'on the finder bar in the right ha

  • Restore SharePoint Database to new server - What to do about external content type?

    I currently run SharePoint 2010 and have a content database back-up which I want to restore to a new server. I was able to restore to a new server and everything seems to be working, except that I have one list in my previous site which had an extern

  • Exporting iPod to iMAC Desktop

    My Powerbook G4 crashed and i want to export songs stored on G5 iPod to my little used iMac G4. Can i do this - there is nothing in my itunes library on the iMac - I'm scared that I will replace songs that are on iPod with contents of iMac library wh

  • Safari blocks my email access

    I am getting a 'too many redirects' notice whilst trying to open my email account with Virginmedia.com. Nowhere in Apple's 'support' is there any help or admission their Safari program can be sorted to cure the problem. In fact they want £25 for a 'o

  • By product showing only in recp reservation not in un resticted

    Hii PP guru, when i enter by product in production order  componenet.quantyty ; in -Ve and item category L and i tick on back flash.. when i confirm the order..by product showing in recp Reservation..but not showing in unrestricted. but when i do man