对半双工通信链路协商参数的Telnet

时间:2022-08-26 19:53:39

Our embedded system needs a Telnet (over serial) interface, due to hardware / legacy system it's working over a half-duplex link (RS485). Yes, I know - no, we can't change it, the industry likes it that way.

我们的嵌入式系统需要一个Telnet(通过串行)接口,由于硬件/遗留系统,它正在一个半双工链路上工作(RS485)。是的,我知道——不,我们不能改变它,行业喜欢这样。

The problem with this is that while we're sending a screenfull of text to the terminal, the user can be pushing buttons and sending data back up the wire.

这样做的问题是,当我们向终端发送一个满是文本的屏幕时,用户可以按下按钮并将数据发送回线路。

Telnet supports the IAC->GA (Go Ahead) command to signal to the user terminal it can begin sending data, but there is no info in any of the RFC's I've read about what tells the user terminal to stop sending data so we can refresh the screen.

Telnet支持IAC->GA (Go Ahead)命令向用户终端发送信号,它可以开始发送数据,但是在RFC的任何一个我读过的信息中,没有任何信息告诉用户终端停止发送数据,这样我们就可以刷新屏幕。

Unfortunately all of the RFC's beyond about 1973 assume that the SGA (Suppress Go Ahead) mode will be used so it gets very little mention. Unfortunately there seems to be no single RFC or other document that actually covers the entirety of the protocol.

不幸的是,在1973年以后的所有RFC都假设将使用SGA(压制前进)模式,所以很少提及它。不幸的是,似乎没有一个RFC或其他文档真正涵盖了整个协议。

Does anyone have any info / links that document the telnet protocol (or just the Go Ahead behaviour) more fully? I realise some of it is probably written on parchment with green stripes ;)

有人有任何信息/链接来更完整地记录telnet协议(或仅仅是Go Ahead行为)吗?我意识到有些可能是写在羊皮纸上的绿色条纹;

RE-Edit: Why the "off-topic" closure of this programming question? Telnet is layer 7 of the OSI model y'know...

重新编辑:为什么这个编程问题的“非主题”结束?Telnet是OSI模型的第7层。

1 个解决方案

#1


3  

Ahhh... RS-485... I remember it well! :-)

啊…rs - 485…我记得很清楚!:-)

The GA definition is broken (see http://tools.ietf.org/html/rfc596) but should be okay for a serial-line implementation because there is no break-up of packets.

GA定义被破坏了(参见http://tools.ietf.org/html/rfc596),但是对于串行实现来说应该没问题,因为包没有被破坏。

What you're asking for is a "reverse break":

你所要求的是“逆向突破”:

"Reverse break" is a means by which a computer connected to a terminal by a half-duplex path may regain control of the path for further typeout after previously having relinquished it.

“反向断路”是指通过半双工路径连接到终端的计算机在放弃路径后,可以重新获得对路径的控制,以便进行进一步的输入。

By it's very nature, a "break" (reverse or otherwise) must be out-of-band on a half-duplex connection since it needs to be able to be sent at any time.

从本质上讲,半双工连接上的“中断”(反向或其他)必须是带外的,因为它需要能够在任何时候发送。

EDIT: New info as a result of a chat: However, if you don't expect to be interrupting an actual transmission (RFC393, reverse-break case "b") and the side with the go-ahead token does not switch the hardware to "transmit" mode except when actually transmitting (RS-485 cannot receive when in this mode even if no data is being sent) and an occasional corrupted/truncated transmission is tolerable and the telnet program correctly implements this rather unusual corner-case, then sending this code in-band may be acceptable.

编辑:聊天后的新信息:然而,如果你不希望打断一个实际的传输(RFC393反向分手,例“b”)和批准的一面令牌不切换的硬件“传播”模式实际上除非传输(rs - 485不能接受当在这种模式下,即使没有数据发送)和偶尔的损坏/截断传播是可容忍的telnet程序正确地实现了这个不寻常的个别案例,然后发送这段代码带内是可以接受的。

Another way I can think to deal with this would be to hack the client side Telnet program to periodically send a "go-ahead" packet to the server even when it has nothing else to send. This would allow the server to do an update and do "go-ahead" in return; it's somewhat like "token ring". You wouldn't even have to delay -- when receiving "go-ahead", send all pending data (might be none) and then return the "go-ahead".

另一种处理这种情况的方法是攻击客户端Telnet程序,使其定期向服务器发送“go-ahead”数据包,即使服务器没有其他东西可以发送。这将允许服务器进行更新,并以“go-ahead”作为回报;有点像“代币戒指”。您甚至不必延迟——在接收“go-ahead”时,发送所有挂起的数据(可能没有),然后返回“go-ahead”。

Possible Alternative Solution:

可能的替代解决方案:

Since you control the ser->ip device as well, why not simply have a specialized protocol between the server and device?

既然您也控制了ser->ip设备,为什么不简单地在服务器和设备之间建立一个专门的协议呢?

  • server sends STX data stream ETX

    服务器发送STX数据流ETX

  • client send STX data stream ETX

    客户端发送STX数据流ETX

  • repeat with no delay

    重复,没有延迟

If either side has no data in its data buffer, then it's just an STX ETX pair effectively telling the other side to "go ahead". If nothing comes from the other side within 250ms, resend ETX

如果任何一方在其数据缓冲区中没有数据,那么它就是一个STX ETX对,有效地告诉另一方“继续”。如果在250毫秒内没有任何东西从另一侧发出,请重新发送ETX。

You could even extend this to have error detection by going STX data stream ETX CRC1 CRC2 with a NAK (instead of STX ...) reply in the case of a detected error, and causing a re-transmit of the entire last packet.

您甚至可以通过在检测到错误时使用NAK(而不是STX…)应答进行STX数据流ETX CRC1 CRC2来进行错误检测(而不是STX…),并导致整个最后一个包的重新传输,从而将其扩展为错误检测。

#1


3  

Ahhh... RS-485... I remember it well! :-)

啊…rs - 485…我记得很清楚!:-)

The GA definition is broken (see http://tools.ietf.org/html/rfc596) but should be okay for a serial-line implementation because there is no break-up of packets.

GA定义被破坏了(参见http://tools.ietf.org/html/rfc596),但是对于串行实现来说应该没问题,因为包没有被破坏。

What you're asking for is a "reverse break":

你所要求的是“逆向突破”:

"Reverse break" is a means by which a computer connected to a terminal by a half-duplex path may regain control of the path for further typeout after previously having relinquished it.

“反向断路”是指通过半双工路径连接到终端的计算机在放弃路径后,可以重新获得对路径的控制,以便进行进一步的输入。

By it's very nature, a "break" (reverse or otherwise) must be out-of-band on a half-duplex connection since it needs to be able to be sent at any time.

从本质上讲,半双工连接上的“中断”(反向或其他)必须是带外的,因为它需要能够在任何时候发送。

EDIT: New info as a result of a chat: However, if you don't expect to be interrupting an actual transmission (RFC393, reverse-break case "b") and the side with the go-ahead token does not switch the hardware to "transmit" mode except when actually transmitting (RS-485 cannot receive when in this mode even if no data is being sent) and an occasional corrupted/truncated transmission is tolerable and the telnet program correctly implements this rather unusual corner-case, then sending this code in-band may be acceptable.

编辑:聊天后的新信息:然而,如果你不希望打断一个实际的传输(RFC393反向分手,例“b”)和批准的一面令牌不切换的硬件“传播”模式实际上除非传输(rs - 485不能接受当在这种模式下,即使没有数据发送)和偶尔的损坏/截断传播是可容忍的telnet程序正确地实现了这个不寻常的个别案例,然后发送这段代码带内是可以接受的。

Another way I can think to deal with this would be to hack the client side Telnet program to periodically send a "go-ahead" packet to the server even when it has nothing else to send. This would allow the server to do an update and do "go-ahead" in return; it's somewhat like "token ring". You wouldn't even have to delay -- when receiving "go-ahead", send all pending data (might be none) and then return the "go-ahead".

另一种处理这种情况的方法是攻击客户端Telnet程序,使其定期向服务器发送“go-ahead”数据包,即使服务器没有其他东西可以发送。这将允许服务器进行更新,并以“go-ahead”作为回报;有点像“代币戒指”。您甚至不必延迟——在接收“go-ahead”时,发送所有挂起的数据(可能没有),然后返回“go-ahead”。

Possible Alternative Solution:

可能的替代解决方案:

Since you control the ser->ip device as well, why not simply have a specialized protocol between the server and device?

既然您也控制了ser->ip设备,为什么不简单地在服务器和设备之间建立一个专门的协议呢?

  • server sends STX data stream ETX

    服务器发送STX数据流ETX

  • client send STX data stream ETX

    客户端发送STX数据流ETX

  • repeat with no delay

    重复,没有延迟

If either side has no data in its data buffer, then it's just an STX ETX pair effectively telling the other side to "go ahead". If nothing comes from the other side within 250ms, resend ETX

如果任何一方在其数据缓冲区中没有数据,那么它就是一个STX ETX对,有效地告诉另一方“继续”。如果在250毫秒内没有任何东西从另一侧发出,请重新发送ETX。

You could even extend this to have error detection by going STX data stream ETX CRC1 CRC2 with a NAK (instead of STX ...) reply in the case of a detected error, and causing a re-transmit of the entire last packet.

您甚至可以通过在检测到错误时使用NAK(而不是STX…)应答进行STX数据流ETX CRC1 CRC2来进行错误检测(而不是STX…),并导致整个最后一个包的重新传输,从而将其扩展为错误检测。