简体   繁体   English

如何检查 TFTP 连接的连接状态?

[英]How to check status of connection of a TFTP connection?

I want to check whether or not this connection is made.我想检查是否建立了这种连接。 I am fairly new with node js and tftp so I am not sure how to check the connection.我对 node js 和 tftp 相当陌生,所以我不确定如何检查连接。 Can i return some kind of status?我可以返回某种状态吗?

var tftp= require('tftp');


var client = tftp.createClient({
    host: "192.168.0.184",
    port: 69
});

If you mean the Trivial File Transfer Protocol then it's based on UDP which is connection-less, so there's really no way to check the status of a "connection" that doesn't exist.如果您指的是普通文件传输协议,那么它基于无连接的UDP ,因此实际上无法检查不存在的“连接”的状态。

TFTP is basically a request-response type of protocol, so the only way to "check" a connection is to send a "request" and see if you get a "response" within a certain amount of time. TFTP 基本上是一种请求-响应类型的协议,因此“检查”连接的唯一方法是发送“请求”并查看是否在一定时间内得到“响应”。 If the response takes to long then something went wrong (dropped packet or something similar) and you have to start over.如果响应需要很长时间,那么出现问题(丢包或类似的东西),你必须重新开始。

Of course, if there's no-one listening on the other side then you can't even send the "request" and will get an error.当然,如果没有人在另一边收听,那么您甚至无法发送“请求”并且会收到错误消息。

Do you see any error messages when you try to create a getStream:当您尝试创建 getStream 时,您是否看到任何错误消息:

var get = client.createGetStream ("remote-file.txt");

I suggest you first check if the tftp server is up and working.我建议您首先检查 tftp 服务器是否已启动并正常工作。 Eg in ubuntu you can check that by:例如,在 ubuntu 中,您可以通过以下方式检查:

user@12345689:~$ sudo service tftpd-hpa status
● tftpd-hpa.service - LSB: HPA's tftp server
   Loaded: loaded (/etc/init.d/tftpd-hpa; bad; vendor preset: enabled)
   Active: active (running) since Tue 2020-05-12 19:29:40 PDT; 12h ago

Sometimes the firewall can get on the way有时防火墙可以阻止

user@12345689:~$ sudo service ufw status
● ufw.service - Uncomplicated firewall
   Loaded: loaded (/lib/systemd/system/ufw.service; enabled; vendor preset: enab
   Active: inactive (dead) since Wed 2020-05-13 07:30:16 PDT; 4min 22s ago

On the machine where you have tftp and on other remote machine you can test tftp by:在您拥有 tftp 的机器和其他远程机器上,您可以通过以下方式测试 tftp:

user@12345689:~$tftp
> get 10.0.0.50:remote-file.txt
received 2000 bytes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM