This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Telnet messages are being dropped

0

Hello. I am using a Python3.3 script that uses a telnet connection from telnetlib library.

Now, I am using the write(command) and read() functions of this connection.

So, after wiresharking this simple code:

import telnetlib
import sys
def func1(IP,user,passw):
    t=telnetlib.Telnet(IP)
    t.write(user.encode('ascii')+b'\n')
    t.write(passw.encode('ascii')+b'\n')
    return t

def func2(t,command): t.write(command.encode('ascii')+b'\n') print(command)

user=sys.argv[1] passw=sys.argv[2] IP=sys.argv[3] t=func1(IP,user,passw) for i in range(6): func2(t, "message "+str(i))

I saw a weird behavior on Wireshark. After submitting the username and password, it send to the server a packet which contains only 2 messages out of six (within the ‘for loop’), and the next packet is also from my computer, resetting the telnet conection!

By adding a line to func2:

def func2(t,command):
t.write(command.encode('ascii')+b'\n')
t.read_eager()   #The new line
print(command)

Somehow it works fine.

Now, it should not be like that. If I am using the write(command) 10 times one after each other, not the way I used here, It works fine without any need of read().

Any idea?

The last two packets:

  no.    time       source  destination  protocol  info

1501 11.754366 A.B.C.A ..*.113 TELNET Telnet Data …

1502 11.760757 A.B.C.A ..*.113 TCP esimport > telnet [RST, ACK] Seq=40 Ack=7 Win=0 Len=0

asked 30 Oct ‘13, 04:30

itay_user's gravatar image

itay_user
1223
accept rate: 0%

edited 30 Oct ‘13, 04:58


One Answer:

0

this sounds more like a question for the developer of telnetlib (and/or a Python network programming forum) than for the Wireshark community, especially as did not provide a capture file !?!

Anyway: Can you post a capture file somewhere (google docs, dropbox, cloudshark.org). Maybe we can see something that helps you to debug your code.

answered 30 Oct '13, 06:02

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%