Problem with Telnet clients

Giganews Newsgroups
Subject: Problem with Telnet clients
Posted by:  A. Stern (ahCUT…@CUTvtr.net)
Date: Thu, 10 Feb 2005

Hi.

I'm working on an application which dynamically creates TIdTelnet
instances within threads in order to connect to some Telnet servers and
retrieve some data.

The clients achieve to connect to the servers but there's a problem
consisting in the servers closing the connections just after a small TCP
exchange.

I captured the TCP stream between one client and one server using
Ethereal (see below). I think the problem may be related to the client
acknowledging frame 258 but not accepting nor rejecting any of the
option commands. However, the client afterwards does respond to the
Telnet option commands but when the server has already began the data
transmision. It seems to me that this should not happen.

Below is the TCP stream capture and the Execute() function of the thread
where the client is created.

I'm using BCB 6.0 Enterprise Suite with Indy 8.0.25 on Windows 2000.

Any insight of what is happening and any help on how can I solve this
problem would be much appreciated.

Kind regards.

Andrés

---Begin of TCP stream capture---

Frame 255 (62 bytes on wire, 62 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 0, Ack: 0, Len: 0
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 0    (relative sequence number)
    Header length: 28 bytes
    Flags: 0x0002 (SYN)
    Window size: 65535
    Checksum: 0x9941 (correct)
    Options: (8 bytes)
        Maximum segment size: 1460 bytes
        NOP
        NOP
        SACK permitted

Frame 256 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 0, Ack: 1, Len: 0
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 0    (relative sequence number)
    Acknowledgement number: 1    (relative ack number)
    Header length: 24 bytes
    Flags: 0x0012 (SYN, ACK)
    Window size: 4096
    Checksum: 0x621c (correct)
    Options: (4 bytes)
        Maximum segment size: 512 bytes
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 255
        The RTT to ACK the segment was: 0.036577000 seconds

Frame 257 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 1, Ack: 1, Len: 0
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 1    (relative sequence number)
    Acknowledgement number: 1    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 65535
    Checksum: 0x8625 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 256
        The RTT to ACK the segment was: 0.000231000 seconds

Frame 258 (63 bytes on wire, 63 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 1, Ack: 1, Len: 9
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 1    (relative sequence number)
    Next sequence number: 10    (relative sequence number)
    Acknowledgement number: 1    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0018 (PSH, ACK)
    Window size: 4096
    Checksum: 0x5518 (correct)
Telnet
    Command: Don't Linemode
    Command: Will Echo
    Command: Will Suppress Go Ahead

Frame 260 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 1, Ack: 10, Len: 0
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 1    (relative sequence number)
    Acknowledgement number: 10    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 65526
    Checksum: 0x8625 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 258
        The RTT to ACK the segment was: 0.144145000 seconds

Frame 264 (61 bytes on wire, 61 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 10, Ack: 1, Len: 7
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 10    (relative sequence number)
    Next sequence number: 17    (relative sequence number)
    Acknowledgement number: 1    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0018 (PSH, ACK)
    Window size: 4096
    Checksum: 0x7aed (correct)
Telnet
    Data: User :

Frame 265 (57 bytes on wire, 57 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 1, Ack: 17, Len: 3
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 1    (relative sequence number)
    Next sequence number: 4    (relative sequence number)
    Acknowledgement number: 17    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0018 (PSH, ACK)
    Window size: 65519
    Checksum: 0x641d (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 264
        The RTT to ACK the segment was: 0.029088000 seconds
Telnet
    Command: Won't Linemode

Frame 266 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 17, Ack: 4, Len: 0
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 17    (relative sequence number)
    Acknowledgement number: 4    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 4093
    Checksum: 0x7615 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 265
        The RTT to ACK the segment was: 0.033957000 seconds

Frame 267 (68 bytes on wire, 68 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 4, Ack: 17, Len: 14
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 4    (relative sequence number)
    Next sequence number: 18    (relative sequence number)
    Acknowledgement number: 17    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0018 (PSH, ACK)
    Window size: 65519
    Checksum: 0x910f (correct)
Telnet
    Command: Do Echo
    Command: Don't Suppress Go Ahead
    Data: user\r\

Frame 268 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 17, Ack: 4, Len: 1
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 17    (relative sequence number)
    Next sequence number: 18    (relative sequence number)
    Acknowledgement number: 4    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0018 (PSH, ACK)
    Window size: 4096
    Checksum: 0x5409 (correct)
    SEQ/ACK analysis
Telnet
    Data: "

Frame 270 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 18, Ack: 18, Len: 0
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 18    (relative sequence number)
    Acknowledgement number: 18    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 4082
    Checksum: 0x7611 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 267
        The RTT to ACK the segment was: 0.033522000 seconds

Frame 272 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 18, Ack: 18, Len: 0
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 18    (relative sequence number)
    Acknowledgement number: 18    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0011 (FIN, ACK)
    Window size: 4088
    Checksum: 0x760a (correct)

Frame 273 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 18, Ack: 19, Len: 0
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 18    (relative sequence number)
    Acknowledgement number: 19    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 65518
    Checksum: 0x8613 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 272
        The RTT to ACK the segment was: 0.000345000 seconds

Frame 274 (54 bytes on wire, 54 bytes captured)
Ethernet II, Src: 00:08:a1:5a:ac:6c, Dst: 00:0a:f3:93:19:fc
Internet Protocol, Src Addr: aaa.aaa.aaa.aaa (Telnet client), Dst Addr:
bbb.bbb.bbb.bbb (Telnet server)
Transmission Control Protocol, Src Port: 3872 (3872), Dst Port: telnet
(23), Seq: 18, Ack: 19, Len: 0
    Source port: 3872 (3872)
    Destination port: telnet (23)
    Sequence number: 18    (relative sequence number)
    Acknowledgement number: 19    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0011 (FIN, ACK)
    Window size: 65518
    Checksum: 0x8612 (correct)

Frame 275 (60 bytes on wire, 60 bytes captured)
Ethernet II, Src: 00:0a:f3:93:19:fc, Dst: 00:08:a1:5a:ac:6c
Internet Protocol, Src Addr: bbb.bbb.bbb.bbb (Telnet server), Dst Addr:
aaa.aaa.aaa.aaa (Telnet client)
Transmission Control Protocol, Src Port: telnet (23), Dst Port: 3872
(3872), Seq: 19, Ack: 19, Len: 0
    Source port: telnet (23)
    Destination port: 3872 (3872)
    Sequence number: 19    (relative sequence number)
    Acknowledgement number: 19    (relative ack number)
    Header length: 20 bytes
    Flags: 0x0010 (ACK)
    Window size: 4088
    Checksum: 0x7609 (correct)
    SEQ/ACK analysis
        This is an ACK to the segment in frame: 274
        The RTT to ACK the segment was: 0.038152000 seconds

---End of TCP stream capture---

---Begin of Execute()---

void __fastcall ReadoutThread::Execute()
{
  AnsiString IP;
  IP = CuLAMainForm->UnsoModList->Strings[ModemIdx*5];
  IP.Delete(1,3);

  ATelnetClient = new TIdTelnet(NULL);
  ATelnetClient->OnDataAvailable = &ATelnetClientOnDataAvailable;
  ATelnetClient->OnConnected = &ATelnetClientOnConnected;
  ATelnetClient->OnDisconnected = &ATelnetClientOnDisconnected;
  ATelnetClient->Host = IP;

  ATelnetClient->Connect();

  while(ATelnetClient->Connected()){};

  delete ATelnetClient;
}

---End of Execute()---

Replies