Problem with the UDP send receive string on Arduino YUN, please help.

Hello everyone, I’ve started a small project on understanding the UDP protocol through the Ethernet cable on my Arduino YUN. I have tried a lot of methods to solve my issue and no forum’s have simple solutions, my issue is that nothing is happening when i upload the processing code first through the ethernet cable to my arduino board and then the arduino code through the Arduino IDE to my board, both the codes are as follows :
Arduino Code :

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <Bridge.h>
#include <EthernetUdp.h>         // UDP library from: 12/30/2008
#include <Console.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, 0xFA, 0x0C, 0x87 
IPAddress ip(172,18,230,178); 

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

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
int c;
void setup() {
  // start the Ethernet and UDP:


void loop() {
  // if there's data available, read a packet
   Serial.println("Received packet of size ");
  int packetSize = Udp.parsePacket();
  if (packetSize) {
   Serial.print("Received packet of size "); 
    Serial.println("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i = 0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
    Serial.print(", port ");

    // read the packet into packetBufffer, UDP_TX_PACKET_MAX_SIZE);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());

and my processing code is :

import cc.arduino.*;
import org.firmata.*;

 // Processing UDP example to send and receive string data from Arduino
 // press any key to send the "Hello Arduino" message


 UDP udp;  // define the UDP object

 void setup() {
 udp = new UDP( this, 6000 );  // create a new datagram connection on port 6000
 //udp.log( true );     // <-- printout the connection activity
 udp.listen( true );           // and wait for incoming message

 void draw()

 void keyPressed() {
 String ip       = ""; // the remote ip address
 int port        = 8888;    // the destination port

 println(udp.send("HelloWorld", ip, port ));   // the message to send

 void receive( byte[] data ) {       // <-- default handler
 //void receive( byte[] data, String ip, int port ) {  // <-- extended handler

 for(int i=0; i < data.length; i++)

I am using 2 ethernet cables, one end of one cable connected to my laptop and it’s other end to the DHCP router switch and the other cable’s one end is connected to the same DHCP router switch and other end to my Arduino YUN’s ethernet port.So, my Arduino Yun’s ethernet network ETH1 exists on “”.But still the Udp communication is not happening despite both the codes on both softwares compiling successfully. Anyone who is familiar with this problem, your help would be precious to me and really appreciated.

I'm not familiar with the Yun, but I know network troubleshooting. Can you ping that address from the laptop? Do you have Wireshark on the laptop?

edit: Don't know how I forgot this. What network settings are on the laptop?

Thanks for your reply Tim, i do not have wireshark on my laptop, but i am able to ping the address via the command prompt on my windows 8, a reply is coming.

Then I suggest getting a copy of Wireshark. There is a version for Windows. You should be able to determine if the packet is actually being sent by your processing code.

Hey Tim, thanks for the advice, i think i have made some progress with detecting the problem.Wireshark shows that the packet is being sent from processing to the IP address of my Arduino YUN. But when arduino yun is the source (ie. for the acknowledgement process) then wireshark shows the protocol is ICMP and destination unreachable(port unreachable). I tried different UDP ports apart from the port that i’m already using ie. 8888. Still doesn’t seem to work. Can you tell me any other alternative port than 8888 for 2 sided UDP communication? or is there any way i can debug the unreachability of port “8888”? You can see the image attached below for more clarity if need be. Thanks a lot for your help again!

I have used many ports in the 5000 range, but 8888 should work ok. You need to fix that ICMP deal.

But how to do it, can you suggest me some approach?

Unfortunately, I am not familiar with the Yun and how the bridge works. You might want to post a question on the Yun topic. Maybe the bridge needs to be set up before the Udp.begin call? I don't know.

Thanks for your help anyway man,on for this? i'm not sure if my arduino yun has received the packet or not, but i'm sure that the processing software has successfully sent out the UDP packets to the specified port. Could you suggest me some other forum where i could find a solution?

I think you are using an ethernet library for the ethernet shield, this can't work.

On the Yun the ethernet port is not directly connected with the mcu, you have to use it in the linux side with python scripts.

See here.

Yes Laku, i am directly using an ethernet library for my YUN board. You mean to say that in the Yun, this sort of application, like the send receive string will only and only work using python on the linux side? no other way?And what i've done till now by running codes on these 2 softwares is wrong? Thanks for your help till now, really appreciate it.