开发者

Telnet performance in windows xp and Linux

I has a Library impelmented based on Python's telnetlib. And recently, i noticed that the performance in windows xp and Linux is so different.

below script, i design three operations, "get units", "just press enter", "get units with options"

"get units" has long string return, "get units with options" return shorter string, and "just press enter" will return shortest string.

let's guess, which will spend more time, seems 开发者_如何学Goit's order should be "get units", "get units with options", then "just press enter".

but actual result in windows xp is:

get units: 3.67200016975 s get units with options: 10.0319998264 s just press enter: 10.0 s

same test in Ubuntu: get units: 3.91432785988 get units with options: 2.86995506287 just press enter: 2.05337381363

it seems that windows xp has good performance on large IP packet, but for small packet, it is so bad.

i have tested it manually, using windows's telnet client, putty. Using wireshark to capture telnet data. And find that for small packet, packet delay is so long, about 0.2s

i have tried to change tcp window, but haven't help.

can anyone give some suggestions?

try:
    begin_g = time.time()
    for i in range(50):
        connection.write('ZUSI:OMU;')
        ret = connection.read_until('<')
        ret = connection.read_until('<')
    end_g = time.time()
    elapse_g = end_g-begin_g

    clean_begin_t = time.time()
    for i in range(50):
        ret = ipa.get_units()
    clean_end_t = time.time()
    elapse_c = clean_end_t-clean_begin_t

    begin_wu = time.time()
    for i in range(50):
        connection.write('')
        ret = connection.read_until_prompt()
    end_wu = time.time()
    elapse_wu = end_wu-begin_wu


Maybe it's delaying sending a short packet because of Nagle's algorithm.

You could test that by disabling the Nagle algorithm on the XP machine (Google for how to do that).


Thank you all. I have solve this problems. There are two algorithm: The Nagle algorithm, The delayed ACK algorithm. My problem is caused by "The delayed ACK algorithm". Unfortunately, it can not be set in Python. I have to modify register, set value to 1, and it works at all. But i think it is not good enough. Linux support TCP_QUICKACK. But Windows do not.

[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Tcpip \Parameters \Interfaces \{Adapter-id}]
TcpAckFrequency = 2 (Default=2, 1=Disables delayed ACK, 2-n = If n outstanding ACKs before timed interval, sent ACK)

More Info MS KB Q328890
More Info MS KB 815230 (XP/2003 needs hotfix or SP2 for it to work)
More Info MS KB 935458 (Vista needs hotfix or SP1 for it to work)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜