Latest 4.2 SDK - Ethernet impressive news and maybe not so good news

I have been doing some performance testing with the new 4.2 Premium SDK on a Spider. I am seeing some great send speeds, the impressive news, and what appears to be a firmware exception.

The first performance testing involved sending from the Spider to a PC program. The PC was a virtual machine, running under Fusion on an IMac.

The Spider program, which used the Premium library, not Gadgeteer, got a network address via DHCP, and then established a connection to the PC program. After the connection was established, the Spider looped sending fixed length buffer to the PC.

The PC, with a 34KB input buffer, did a read to its 32KB buffer, counted bytes received, and every ten seconds calculated the bytes per second receive rate.

The results:
For a 1024 byte send buffer on the Spider, the PC receive rate was arount 590KBS, or 4.7 Mbs.
For a 8192 byte send buffer on the Spider, the PC rate was 1,175KBS, or 9.4 Mbs.
For a 16384 byte send buffer on the Spider, the PC rate was 1,245KBS, or ~10 Mbs.

These are impressive rates.

I then decided to see what the rate would be if I went with a small buffer. I choose
a 512 send buffer. No go. I am getting the following displayed on the
T35 LCS:

cps=0x200000df
pc=0x000049f0
ir=0x00000000
sp=0x4000efa8

Looks like a firmware exception?

Following are the programs I used for the test

PC PROGRAM

using System;
using System.Net;
using System.Net.Sockets;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TCPReceiver
{
    class Program
    {
        // Listening on port 20000
        // assumes Ethernet cable is inserted
        static void Main(string[] args)
        {
            TimeSpan tenSeconds = new TimeSpan(0, 0, 10);
            IPEndPoint listenEP = new IPEndPoint(IPAddress.Any, 20000);
            Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            listenSocket.Bind(listenEP);
            listenSocket.Listen(5);

            while (true)
            {
                Console.WriteLine("Waiting for connection...");
                Socket sessionSocket = listenSocket.Accept();
                Console.WriteLine("Connection from {0}", sessionSocket.RemoteEndPoint);
                byte[] buffer = new byte[1024];
                DateTime start = DateTime.Now;
                int totalBytesRead = 0;
                while (true)
                {
                    try
                    {
                        int bytesRead = sessionSocket.Receive(buffer);
                        if (bytesRead == 0)
                            break;
                        TimeSpan elapsed = DateTime.Now - start;
                        totalBytesRead += bytesRead;
                        if (elapsed >= tenSeconds)
                        {
                            int bytesPerSecond = (int)(totalBytesRead / (elapsed.TotalMilliseconds / 1000.0));
                            Console.WriteLine(bytesPerSecond);
                            totalBytesRead = 0;
                            start = DateTime.Now;
                        }
                    }
                    catch (Exception)
                    {
                        break;
                    }
                }
                Console.WriteLine("Connection terminated");
            }
        }
    }
}

Spider/EMX Program

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using GHI.Premium.Net;

namespace TCPTransmitter
{
    public class Program
    {
        // assumes cable is inserted to reduce code to minimum

        private static EthernetBuiltIn Eth1 = new EthernetBuiltIn();
        private static AutoResetEvent ipAddressReady = new AutoResetEvent(false);
        private static byte[] buffer = new byte[512];

        public static void Main()
        {
            Eth1.Open();
            NetworkInterfaceExtension.AssignNetworkingStackTo(Eth1);
            Eth1.NetworkAddressChanged += new NetworkInterfaceExtension.NetworkAddressChangedEventHandler(Eth1_NetworkAddressChanged);
            Eth1.NetworkInterface.EnableDhcp();

            // wait for ip address 
            ipAddressReady.WaitOne();
            Debug.Print("Got IP Address");

            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPAddress ipAddress = IPAddress.Parse("192.168.1.10");
            IPEndPoint remoteEP = new IPEndPoint(ipAddress, 20000);
            Debug.Print("Starting connect");
            socket.Connect(remoteEP);
            Debug.Print("Connected");

            int bytesSent = 0;
            while (true)
            {
                bytesSent += socket.Send(buffer);
            }
        }

        static void Eth1_NetworkAddressChanged(object sender, EventArgs e)
        {
            if (Eth1.NetworkInterface.IPAddress != "0.0.0.0")
                ipAddressReady.Set();
        }

    }
}

Thanks mike. We will investigate.

Confirmed! Was able to repro on my Spider, also fails with 640, but works with 768.

Nice catch Mike!