[Mono-list] Why is MONO network streaming much slower than .NET?

Hubert FONGARNAND informatique.internet at fiducial.fr
Mon Jun 18 05:32:53 EDT 2007


Hi,

I've ran your tests on my linux box...

Between Gentoo Linux on a 3Ghz PIV and Gentoo Linux on a 3Ghz Xeon in a
100Mbit/s ethernet (with a router in the middle)

Mono 1.2.4 -> Mono 1.2.4. : 
20000000 Bytes received (82,9530454655273MBit/s).
20000000 Bytes received (84,3471687291307MBit/s).
20000000 Bytes received (83,6054866100588MBit/s).
20000000 Bytes received (85,4498641614191MBit/s).
20000000 Bytes received (84,066551285325MBit/s).
20000000 Bytes received (83,0987524799784MBit/s).
20000000 Bytes received (82,9746839053487MBit/s).
20000000 Bytes received (75,9913065945256MBit/s).
20000000 Bytes received (84,3420555318636MBit/s).
20000000 Bytes received (84,7406908378895MBit/s).

~83Mbit/s

Thats acceptable no?



Le lundi 18 juin 2007 à 09:38 +0200, Hund a écrit :
> Hi, 
> is MONO network streaming slow?
>  
> First I built a very simple client/server program 
> to get a data stream over network.
> In both programs I used a TcpClient,
> a NetworkStream and a byte array (8kB chunks)
> to stream 20 MB of data.
>  
> Then I tested the transfer rate of the client/server
> program between different Linux/MONO (1.2.3.1) 
> and different Windows/.NET (2.0) hosts
> in a 100 Mbit/s ethernet.
>  
> The strange result: If MONO was involved 
> the speed was dramatically reduced.
> Only a .NET/.NET transfer showed a realistic
> rate.  
>  
> .NET --> MONO : 31...42 Mbit/s   LOW
> MONO --> MONO : 43...45 Mbit/s   LOW
> MONO --> .NET : 51...76 Mbit/s   LOW
> .NET --> .NET : 94 Mbit/s        O.K.
>  
> What's wrong here?
> Any suggestions or hints?
> Thanks in advance.
>  
> Cheers
> Andreas
> 
> =======================================================
>  
> 
> Sourcecodes:
>  
> // ******
> // Client
> // ******
>  
> using System;
> using System.IO;
> using System.Net.Sockets;
>  
> namespace SimpleStreamClient
> {
>   class SimpleStreamClient
>   {
>     public static void Main(string[] args) {
>       TcpClient client;
>       NetworkStream netStream;
>       byte[] buf = new byte[8192];
>       int bytesToReceive = buf.Length;
>       int receivedBytes = 0;
>       int bytesReceived = 0;
>  
>       for(int index = 0; index < 10; index++) {
>         client = new TcpClient(args[0], 14866);
>         netStream = client.GetStream();
>         DateTime startTime = DateTime.Now;
>         bytesReceived = 0;
>         
>         while(true) {
>           bytesToReceive = buf.Length;
>           
>           while(bytesToReceive > 0) {
>             receivedBytes = netStream.Read(buf, 0, bytesToReceive);
>             if(receivedBytes == 0) {
>               break;
>             }
>             bytesReceived += receivedBytes;
>             bytesToReceive -= receivedBytes;
>           }
>           if(receivedBytes == 0) {
>             break;
>           }
>         }
>         double rate = bytesReceived / (((TimeSpan)(DateTime.Now -
> startTime)).TotalMilliseconds * 1000) * 8;
>         Console.WriteLine(bytesReceived + " Bytes received (" + rate +
> "MBit/s).");
>       }
>     Console.ReadKey();
>     }
>   }
> }
>  
> 
> // ******
> // Server
> // ******
>  
> using System;
> using System.IO;
> using System.Net;
> using System.Net.Sockets;
>  
> namespace SimpleStreamServer
> {
>   class SimpleStreamServer
>   {
>     public static void Main(string[] args) {
>       TcpClient client;
>       NetworkStream netStream;
>       byte[] bigBuf = new byte[20000000];
>       MemoryStream ms = new MemoryStream(bigBuf);
>       byte[] buf = new byte[8192];
>       string host =
> Dns.GetHostEntry(args[0]).AddressList[0].ToString();
>       IPAddress ipAddr = IPAddress.Parse(host);
>       TcpListener listener = new TcpListener(ipAddr, 14866);
>       listener.Start();
>       
>       while(true) {
>         Console.WriteLine("Waiting for client ...");
>         client = listener.AcceptTcpClient();        
>         Console.WriteLine("New client!");        
>         netStream = client.GetStream();
>         ms.Seek(0, SeekOrigin.Begin);
>         int readBytes = 0;
>         while((readBytes = ms.Read(buf, 0, buf.Length)) != 0) {
>           netStream.Write(buf, 0, readBytes);
>         }
>         netStream.Flush();
>         client.Close();
>       }
>     }
>   }
> }
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
_______________________________________________
Ce message et les éventuels documents joints peuvent contenir des informations confidentielles.
Au cas où il ne vous serait pas destiné, nous vous remercions de bien vouloir le supprimer et en aviser immédiatement l'expéditeur. Toute utilisation de ce message non conforme à sa destination, toute diffusion ou publication, totale ou partielle et quel qu'en soit le moyen est formellement interdite.
Les communications sur internet n'étant pas sécurisées, l'intégrité de ce message n'est pas assurée et la société émettrice ne peut être tenue pour responsable de son contenu.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070618/465fe6bb/attachment-0001.html 


More information about the Mono-list mailing list