Go Down

Topic: w5100 Sheild Socket Status (Read 1 time) previous topic - next topic

Jeremy-arduino

Hello,
I am using this bit of code from SurferTim to debug some things:
Code: [Select]
void ShowSockStatus()
{
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    Serial.print(F("Socket#"));
    Serial.print(i);
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(":0x"));
    Serial.print(s,16);
    Serial.print(F(" "));
    Serial.print(W5100.readSnPORT(i));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      Serial.print(dip[j],10);
      if (j<3) Serial.print(".");
    }
    Serial.print(F("("));
    Serial.print(W5100.readSnDPORT(i));
    Serial.println(F(")"));
  }
Serial.println();
}

and it prints like this:
Socket#0:0x22 8888 D:xxx.xxx.xxx.86(123)
Socket#1:0x0 1150 D:xxx.xxx.xxx.86(80)
Socket#2:0x0 0 D:0.0.0.0(0)
Socket#3:0x0 0 D:0.0.0.0(0)

The listening port starts out at 1025 for my GET Requests. Then for every GET Request, that number gets incremented. What happens when it reaches 65535? Will it roll over? Will it crash? Why does it increment for every GET Request?

SurferTim

I noticed it changing, but never paid attention to where it stops or starts over. I ran my client code for several days and it downloaded a webpage over 150,000 times, but I wasn't paying too much attention to the socket, except to insure I wasn't losing any. If I do that again, I'll check it to see what it does about the local port.

Jeremy-arduino

#2
Mar 26, 2014, 06:13 am Last Edit: Mar 26, 2014, 06:17 am by Jeremy-arduino Reason: 1
Ok, yeah I never got that many requests in, as my sockets all got clogged... I wrote another function to reinitialize the Ethernet card if I get a failed connection. Everything seems to come back up correctly now, but I fought for a while because the Arduino would stall anytime after a reinitialize and then the ntp sync time function was called... Finally figured out that I needed to call "EthernetUDP Udp;" again... I have the new code loaded on two units, an uno and a mega. I should know shortly if it will manage failed connections and reinitializing the w5100 by itself...  Do you think it's possible that it could be network congestion that causes the failed connections, and then that in turn causes me to lose sockets? That's the pattern I see in the serial monitor...

pylon

Quote
Do you think it's possible that it could be network congestion that causes the failed connections, and then that in turn causes me to lose sockets?


Is your network already congested? The W5100 isn't able to produce the congestion. What do you mean by loosing sockets? The W5100 only has 4 of them, if you really loose some you run out of them in no time :).

SurferTim

Quote
Do you think it's possible that it could be network congestion that causes the failed connections, and then that in turn causes me to lose sockets? That's the pattern I see in the serial monitor...

I create congestion and failed connections to test my code. I have not lost a socket in over a year.

Jeremy-arduino

Ok, I don't claim to know what all is going on but in looking at my serial output, I would lose a socket every time I got a failed connection.  Also, I am not running this on a home network. I have these units running at the tv station where I work, and there is definitely a lot of network activity. Lots of huge video transfers going on all the time. Another thing, I'm not sure how much of the traffic is monitored and routed back to cooperate on the east coast, but that could be another bottle neck...

Go Up