I'm sure I'm missing something simple here, but have been investigating this for a few days now and haven't spotted it yet. In the process of migrating a project from Teensy 4.0 with enc28j60 to Teensy 4.1 and native ethernet.
NativeEthernet and FNET are latest from vjmuzik github (today). Arduino environment is 1.8.13, Teensyduino is 1.55
Simple webserver that dumps 25K of text to a web page (mostly based on the webserver example in NativeEthernet) code:
Looking in chrome dev view the transfer is stalling and then resuming. I get the same from direct connection or via hub.
Looking with wireshark I see retransmissions occurring a lot (zipped pcap: View attachment ne_dump.zip).
Two different T4.1 boards with different ethernet jacks (one the standard ribbon connected one, the other a custom PCB with magjack) giving same results.
Any ideas gratefully received.
Regards
Simon
NativeEthernet and FNET are latest from vjmuzik github (today). Arduino environment is 1.8.13, Teensyduino is 1.55
Simple webserver that dumps 25K of text to a web page (mostly based on the webserver example in NativeEthernet) code:
Code:
#include <SPI.h>
#include <NativeEthernet.h>
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED
};
IPAddress ip(192, 168, 2, 202);
// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Ethernet WebServer Example");
// start the Ethernet connection and the server:
Ethernet.begin(mac, ip);
// Check for Ethernet hardware present
if (Ethernet.hardwareStatus() == EthernetNoHardware)
{
Serial.println("Ethernet shield was not found. Sorry, can't run without hardware. :(");
while (true) {
delay(1); // do nothing, no point running without Ethernet hardware
}
}
if (Ethernet.linkStatus() == LinkOFF)
{
Serial.println("Ethernet cable is not connected.");
}
// start the server
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void DumpText(EthernetClient& client)
{
for (int i = 0; i < 250; i++)
{
// 102 byte string (crlf)
client.println("0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789");
}
//25k dumped
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");
// dump html here
DumpText(client);
client.println("</html>");
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
} else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(10);
// close the connection:
client.close();
delay(10);
client.stop();
Serial.println("client disconnected");
}
}
Looking in chrome dev view the transfer is stalling and then resuming. I get the same from direct connection or via hub.
Looking with wireshark I see retransmissions occurring a lot (zipped pcap: View attachment ne_dump.zip).
Two different T4.1 boards with different ethernet jacks (one the standard ribbon connected one, the other a custom PCB with magjack) giving same results.
Any ideas gratefully received.
Regards
Simon