Too Much Traffic?

How much traffic can the ethernet shield handle? I had a few (maybe 5) people logging on at once and they were able to crash it, or at least got it to stop posting data. Is there a fix for this?

Code and function can be found here.

http://arduino.cc/forum/index.php/topic,88277.0.html

It will handle 4 connections, but "process" one connection at a time. The others must wait their turn. The 5th connection attempt will be ignored until the code has completed and closed a previous active connection.

So, if I understand correctly, the arduino is still functioning correctly (possibly) but I can not log in because lets say I am the 5th+ request and therefore being ignored.

As traffic dies down, I should be able to successfully log back on?

Thank you very much.

That is correct.

Also, if the network bogs down on the active connection (the one being serviced), the other three connections do not receive anything. They will show "connected" with the little whirring wheel. If the active connection takes too long, the other connections may start timing out.

When the active connection is closed, the next one in line will start getting stuff, but the one after that will still show "connected" with the whirring wheel. Now another connection can be established, but it won't start getting stuff yet (whirring wheel).

Some meta refresh server code that you can use for some traffic test. You can set the refresh to 0 and open any number of browser connections to the page to see how well the code handles the high connection load.

// arduino IDE 1.0
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84 in your brouser
// or http://zoomkat.no-ip.com:84 with dynamic IP service
// use the \ slash to escape the " in the html
// meta refresh set for 2 seconds

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

int x=0; //set refresh counter to 0
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102); // ip in lan
EthernetServer server(84); //server is using port 84

void setup()
{
  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //meta-refresh page every 2 seconds
          x=x+1;
          client.println("<HTML>");
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
          client.println("<BODY>");
          client.print("Zoomkat's meta-refresh test IDE 1.0");
          client.println("
");
                    
          client.print("page refresh number ");
          client.println(x); //current refresh count
          client.println("
");
          client.println("
");
          
          client.print("Zoomkat's arduino analog input values:");
          client.println("
");
          client.println("
");
          
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
            }
           break;
          client.println("</BODY>");
          client.println("</HTML>");
         }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

^^Thank you for this.

Something happened again today where it has stopped responding again. I don't think it is because of traffic. There was maybe a maximum 3 people hitting the IP. I will try your test code tonight to be sure.

Zoomkat, If my understanding is correct (and please correct me if I am wrong), I change the ethernet configuration parameters to be applicable to my set-up. I set the refresh rate to 0 in the void loop. Upload code. Then I can start opening tabs in my internet browser connecting to the arduino's IP. Each connection (tab) will act as a connection to that IP. I assume I can keep opening tabs until something goes wrong and that will be the maximum amount of traffic that my set-up can handle?

Thanks for your help.

Ok Zoomkat.... I have run the ol duino through the paces. This is what I found.

2 second refresh - went ok with up to five windows open. The sixth window caused everything to hault. Could not get the arduino to restart, even with unplugging it and resets.

0 second refresh - sometimes the board would hang in there with one window open and produce 600 refreshes a minute. I ran it that way for 3000 refreshes and closed and open the tab a few times and it seemed to pick up where it left off with no problem. Sometimes, it would get to 80-90 refreshes and then produce nothing but garbage. Closing the tab did nothing, it would either timeout with no response or continue producing garbage when the tab was reopened. Sometimes the garbage was just pages of ASCII characters. I had to unplug it a few times to get it going again.

Is this normal performance or no?

Sample garbage:

is 376

analog input 2 is 604

analog input 3 is 23

analog input 4 is 169

analog input 5 is 210

/>
page refresh number 98

Zoomkat's arduino analog input values:v="reHTTP/1.1 200 OK
Content-Type: text/html
-refresh test
Zoomkat's meta-refresh test IDE 1.0

page refresh number 62

Zoomkat's arduino analog input values:

analog input 0 is 146

analog input 1 is 379

analog input 2 is 603<br /

<

analog input 0 is 146

analog input 1 is 375

analog input 2 is 603

analog input 3 is 24

analog input 4 is 154

analog input 5ITLE />Zoomkat's meta-refresh test

I was just able to get 720 refreshes a minute from 6 open tabs using my public IP and the forwarded port. huh.

Then I kept opening tabs, I was able to get 12 tabs open! I don't really get why my board is finicky... I guess it may just be my code.

I had problems like that. Mine was due to the microSD SPI interface. It would run fine for a while, then garbage.
You might want to try this change.

void setup()
{
  // disable microSD SPI
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

Trying that right now...

Although it sucks to have the SD "turned off", I wanted to eventually use it to store web page pictures and jpgs...

When you want to use the microSD, then enable it. Then it won't interfere with the w5100.

void setup()
{
  // start microSD
  SD.begin(4);

  // start the server
  Ethernet.begin(mac, ip);
  // disable w5100 SPI
  digitalWrite(10,HIGH);
  server.begin();
}

Now you can use both w5100 and microSD.

I set the refresh rate to 0 in the void loop.

No, you have miss interpeted the code. The refresh rate is the 2 in the below line in the html code. This controls how quickly the browser request an update (every 2 seconds in this case). The x=x+1; in the bottom code is a page update counter that should not be changed. This just shows the number of pages served and is included with each page update. I use this number to count the current number of page updates. The number will increase to ~32k, at which time it will roll over and start counting down. I let this server code run on my arduino for several days using an instance of the IE browser to request page request, and the arduino served up 150k+ pages without issues. To test, load the meta refresh code on the arduino, then open a seperate browser instance, and connect to the arduino web page with that browser instance. Then minimize that browser instance and let it run in the background. Check the browser from time to time to see if the page is still loading, showing the current number of pages served. In my test by IE browser uploaded over 150k pages during the test over several days. To stress test the arduino connections, set the refresh time in the html code to 0 (refresh as fast as possible), and open more IE browser instances for the page and see how well they compete for the arduino update.

client.print("<meta http-equiv=\"refresh\" content=\"2\">");
x=x+1;

Yes, That is exactly what I did. I saw where the refresh was after I looked at the code for a couple minutes.

After running your code and realizing that the arduino can handle more than what I was throwing at it (even with the bad results), I'm trying Tim suggestions. We'll see if I have a conflict or not.