Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > de.comp.lang.python > #5503

Re: tcp benchmark

From Ulli Horlacher <framstag@rus.uni-stuttgart.de>
Newsgroups de.comp.lang.python
Subject Re: tcp benchmark
Date 2019-06-22 08:25 +0000
Organization University of Stuttgart, FRG
Message-ID <qekolg$qad$1@news2.informatik.uni-stuttgart.de> (permalink)
References <qdh29s$jv1$1@news2.informatik.uni-stuttgart.de>

Show all headers | View raw


Ulli Horlacher <framstag@rus.uni-stuttgart.de> wrote:
> Ich habe ein Perl Programm geschrieben um tcp Durchsatz zu messen:
> 
> https://fex.belwue.de/fstools/tcpbm.html
> 
> Ich moechte nun gerne die Client Funktionalitaet in Python neu
> implementieren. Meine Python Kenntnisse sind aber nur rudimentaer.
> 
> Ich wuerde nun gerne vorab wissen, wie aufwaendig/kompliziert das wird.

War gar nicht so schwer :-)

Zuerst nochmal die original Perl Version:

framstag@fex:~/python: tcpbm localhost
sent:         49414 MB in  10 s =   4941 MB/s
received:     50528 MB in  10 s =   5052 MB/s


Dann die Neuimplementation in Python:

framstag@fex:~/python: ./tcpbm.py localhost
sent:         49847 MB in  10 s =   4984 MB/s
received:     49618 MB in  10 s =   4961 MB/s

Also fast gleich schnell. 
Interessant nun der Vergleich zu Standard tools in C, also nativem binary:
                    ^^^^^^^^^
                    
framstag@fex:~/python: iperf -s -N >/dev/null & sleep 1; iperf -c localhost -f M -t 10
------------------------------------------------------------
Client connecting to localhost, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[  3] local 127.0.0.1 port 42880 connected with 127.0.0.1 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0-10.0 sec  37925 MBytes  3792 MBytes/sec
                                   ^^^^^^^^^^^^^^^

framstag@fex:~/python: wget -O /dev/null http://localhost:591/tcpbm/20000.dd
--2019-06-22 10:13:58--  http://localhost:591/tcpbm/20000.dd
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:591... connected.
HTTP request sent, awaiting response... 200 OK
Length: 20971520000 (20G) [application/octet-stream]
Saving to: '/dev/null'

/dev/null 100%[====================================================================================>]  19.53G  2.04GB/s    in 9.7s

2019-06-22 10:14:07 (2.01 GB/s) - '/dev/null' saved [20971520000/20971520000]
                     ^^^^^^^^^
                     
framstag@fex:~/python: curl http://localhost:591/tcpbm/20000.dd >/dev/null
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5G  100 19.5G    0     0  3418M      0  0:00:05  0:00:05 --:--:-- 3425M
                                 ^^^^^

Python ist, was den tcp Durchsatz angeht, deutlich schneller als typische C Programme!
Erstaunlich!
Und das wo ich sicherlich ein schlechterer Programmierer bin als diejenige
die iperf, wget und curl geschrieben haben. 

Ich hab zum Test hier localhost verwendet, um zu verhindern, dass ein
langsamer Router das Ergenis verfaelscht. 


Wer sich fuer den Sourcecode interessiert:

https://fex.rus.uni-stuttgart.de/fop/f7YRRMqd/tcpbm.py

Ist sicherlich noch verbesserungsfaehig, ich bin Python Anfaenger :-)

-- 
Ullrich Horlacher              Server und Virtualisierung
Rechenzentrum TIK         
Universitaet Stuttgart         E-Mail: horlacher@tik.uni-stuttgart.de
Allmandring 30a                Tel:    ++49-711-68565868
70569 Stuttgart (Germany)      WWW:    http://www.tik.uni-stuttgart.de/

Back to de.comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

tcp benchmark Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2019-06-08 19:29 +0000
  Re: [Python-de] tcp benchmark Christopher Arndt <chris@chrisarndt.de> - 2019-06-08 22:04 +0200
  Re: tcp benchmark Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2019-06-22 08:25 +0000
    Re: tcp benchmark Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2019-06-23 07:52 +0000
      Re: tcp benchmark Wolfgang Strobl <news4@mystrobl.de> - 2019-06-23 19:37 +0200
    Re: [Python-de] tcp benchmark Peter Otten <__peter__@web.de> - 2019-06-23 15:33 +0200
      Re: [Python-de] tcp benchmark Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2019-06-23 18:22 +0000

csiph-web