Cerberus family ethernet performance

There have been a couple questions recently about the performance of the Cerberus family ethernet solution. I did a bit of testing (simply sending empty buffers of different sizes over the network repeatedly) and I am happy to report that performance seems to top out at around 1mbit/sec. I can present the following numbers:

128 byte buffer: 25600 bytes in 40329 milliseconds (5 kbits/sec)
256 byte buffer: 51200 bytes in 531 milliseconds (753 kbits/sec)
512 byte buffer: 102400 bytes in 1017 milliseconds (786 kbits/sec)
1024 byte buffer: 204800 bytes in 1841 milliseconds (869 kbits/sec)
2048 byte buffer: 409600 bytes in 3494 milliseconds (916 kbits/sec)
4096 byte buffer: 819200 bytes in 8277 milliseconds (773 kbits/sec)
8192 byte buffer: 1638400 bytes in 13506 milliseconds (948 kbits/sec)

The 4096 number is an anomaly, probably GC related. It was not consistently reproducible. These numbers are for connecting, sending the stated amount of data (200 calls to Socket.Send()), and disconnecting. Overall, I’m quite pleased!

4 Likes

Performance test should always include the code used :slight_smile:

1 Like

Device-side code:


var sizes = new[] { 128, 256, 512, 1024, 2048, 4096, 8192 };
var iphe  = Dns.GetHostEntry("dsk-mark.home.4ldn.org");
var ep    = new IPEndPoint(iphe.AddressList[0], 12023);

foreach( var bsize in sizes )
{
	var s    = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
	var buf  = new byte[bsize];

	s.Connect(ep);

	for( var i = 0; i < 200; i++ )
		s.Send(buf);

	s.Close();
}

PC-side code:


var l   = new TcpListener(IPAddress.Any, 12023);
var buf = new byte[16384];

l.Start();

while( true )
{
	using( var s = l.AcceptSocket() )
	{
		Console.WriteLine("connection from {0}", s.RemoteEndPoint);
		var cnt  = 0;
		var t    = 0;
		var sw   = System.Diagnostics.Stopwatch.StartNew();

		do
		{
			t = s.Receive(buf, 0, buf.Length, SocketFlags.None);

			cnt += t;
		}
		while( t > 0 );

		sw.Stop();
		s.Close();

		Console.WriteLine("{0} bytes in {1} milliseconds ({2} kbits/sec)", cnt, sw.ElapsedMilliseconds, ((cnt * 8) / 1024) / sw.Elapsed.TotalSeconds);
	}
}

l.Stop();

Nothing very special here.

Hmm, I don’t understand the Console.WriteLine statement. Why is there HTML markup in there?

Lol. Think I see why. A forum bug. It should be something like “8 )”, right?

Yep 8)

Thanks for the test results. But please could you also test receive speed. I have a Panda II and noticed that sending is 4 times faster than receiving…

Thanks for sharing your results!

I’ll do that next.

Results for the receive test (speeds around 1.75 mbits/sec):

*** 524288 bytes in 2368 milliseconds (1729 kbits/sec)
*** 524288 bytes in 2361 milliseconds (1734 kbits/sec)
*** 524288 bytes in 2384 milliseconds (1718 kbits/sec)
*** 524288 bytes in 2374 milliseconds (1725 kbits/sec)
*** 524288 bytes in 2365 milliseconds (1731 kbits/sec)
*** 524288 bytes in 2359 milliseconds (1736 kbits/sec)
*** 524288 bytes in 2367 milliseconds (1730 kbits/sec)
*** 524288 bytes in 2369 milliseconds (1728 kbits/sec)
*** 524288 bytes in 2381 milliseconds (1720 kbits/sec)
*** 524288 bytes in 2366 milliseconds (1731 kbits/sec)
*** 524288 bytes in 2364 milliseconds (1732 kbits/sec)

server-side code:


var l   = new TcpListener(IPAddress.Any, 12023);
var buf = new byte[8192];

l.Start();

while( true )
{
	using( var s = l.AcceptSocket() )
	{
		for( var i = 0; i < 64; i++ )
			s.Send(buf, 0, buf.Length, SocketFlags.None);

		s.Close();
	}
}

l.Stop();

device-side code:


var st   = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
var buf  = new byte[16384];
var iphe = Dns.GetHostEntry("dsk-mark.home.4ldn.org");
var ep   = new IPEndPoint(iphe.AddressList[0], 12023);

st.Connect(new IPEndPoint(Dns.GetHostEntry("dsk-mark.home.4ldn.org").AddressList[0], 12022));
var ns = new NetworkStream(st);
var sw = new StreamWriter(ns);

sw.WriteLine("starting.");
sw.Flush();

while( true )
{
	Debug.GC(true);

	var s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

	s.Connect(ep);

	sw.WriteLine(string.Concat("connection from ", s.RemoteEndPoint));
	sw.Flush();

	var cnt  = 0;
	var t    = 0;
	var start = DateTime.Now.Ticks;

	do
	{
		t = s.Receive(buf, 0, buf.Length, SocketFlags.None);

		cnt += t;
	}
	while( t > 0 );

	var dur_ms = (DateTime.Now.Ticks - start) / TimeSpan.TicksPerMillisecond;

	s.Close();

	sw.WriteLine(string.Concat(cnt, " bytes in ", dur_ms, " milliseconds (", (((float)cnt * 8.0) / 1024.0) / ((float)dur_ms / 1000.0), " kbits/sec)"));
	sw.Flush();

	s.Close();
}

1 Like

Wow!

Thanks for sharing the results. Compared to the Panda II with WIzNET this is lightning fast!

The Panda II maximum values were:

10 kbyte/s (receiving)
40 kbyte/s (sending)

Best regards,

Alex

I dont’t want to bother you, but it would be very nice if you could compare the performance with mIP (A 100% Managed TCP/IP Stack for .NET MF). I really would like to know if there is much difference and if it is worth to use the native Ethernet firmware?

Thanks a lot!

mIP is set up quite differently, it doesn’t have a Socket class, so the test would need to be significantly different.

OK, I understand. Thanks. Maybe there is somebody out there who is using this stack and can post some performance statistics. It really would be interesting to see how much slower a manged driver is…