tx/rx of udp packets/ over ethernet shield and processing

#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x90, 0xA2, 0xDA, 0x0D, 0x0C, 0xE9 };
IPAddress ip(195, 100, 101, 61);

unsigned int localPort = 8888; // local port to listen on

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);

}

void loop() {

Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write("hello");
Udp.endPacket();

}

this is the sketch uploaded on arduino ethernet shield.

i'm trying to receive these packets on my laptop powering this shield.
using processing

import hypermedia.net.*;
int PORT_RX=3000; //port
String HOST_IP="195.100.101.60"; //
UDP udp;
string receivedFromUDP = "";

void setup() {
size(400,400);
udp= new UDP(this,PORT_RX,HOST_IP);
udp.log(true);
udp.listen(true);
super.start();
}

void draw() {
background(0);
text(receivedFromUDP, 50, 50);
}

void receive(byte[] data, String HOST_IP, int PORT_RX) {
receivedFromUDP ="";
for (int i = 0; i < data.length; i++) {
receivedFromUDP += str(data*) + " ";*

  • }*
  • println(data);*
  • }*
    its shows nothing...
    no output , where changing the global variable at declaration itself , changes the output in the output window :confused:
    plz help.
    also how to find out input port for receiving ..... netstat -an ????

Please re-edit your post using code tags so we can tell what's code and what's not - the # button generates code tags for you.

Your sketch doesn't appear to set the destination IP and UDP port to the IP and UDP port that the Processing application is listening on.

I need more information on User Datagram Protocol because my boss asked me to keep a presentation about VoIP technology and UDP. During googling, I have found a website that seems to be suitable to my ideas because it is full of samples and comprehensive documentations as well.

Among others, I have found a good description about UDP which I wish to share:

The User Datagram Protocol (UDP) belongs to the Internet Protocol Suite that is a set of network protocols for the Internet. UDP makes computers possible to send messages (referred to as datagram in the case of UDP) to other hosts on an IP (Internet Protocol) network. The great advantage of this protocol is that special transmission channels or data paths are not required.

To avoid overheads at the network, UDP supposes that error checking and correction is not necessary. That is why time-sensitive applications often employs UDP as real-time systems may prefer dropping packets instead of waiting for delayed ones. Furthermore, UDP is compatible with packet broadcast (refers to sending to all on local network) and multicasting (means sending to all subscribers).

However, unlike TCP (Transmission Control Protocol), UDP does not guarantee transferred data integrity, reliability or ordering. In practice it means that datagrams may arrive out of order, appear duplicated, or lost without notice. Since UDP does not check the integrity of data transfer, it cannot recover lost or damaged packets or even it doesn't acknowledge that the packets being sent have been received or not.

For these reasons, UDP is typically applied in cases in which the loss of smaller part of the sent data does not cause any problem or even it is desired (for example in case of overheads); or if there is an upper layer protocol that corrects these errors. Streaming media, real-time multiplayer games and voice over IP (VoIP) are examples of applications that often use UDP.

If you're interested in VoIP technology then I recommend you to take a look at Ozeki’s website. You can read the mentioned article about UDP protocol further on the following webpage:

Regards,
Niklas