您的位置:首页 > 编程语言 > Go语言

tftp negotiation

2014-04-19 13:57 288 查看
tftp协议的实现 2012-09-16
17:56:04 http://blog.chinaunix.net/uid-26833883-id-3349499.html
外文讨论的option negotiation两篇文章。
http://reboot.pro/topic/3711-problem-with-option-negotation-and-pxe-booting/ http://www.911cd.net/forums//index.php?showtopic=15435&st=0 https://www.kernel.org/pub/software/network/tftp/tftp-hpa/ source code

在zlg i283单板的环境搭建中,和tftp杠上了。

window xp上,tftp32设置正常情况下,tftp传输断断续续,根本没法使用,经过尝试,uncheck option negotiation后,传输正常。

后来抓包发现传输的包序号不正常。刚开始以为是防火墙或者是其他网络服务包干扰引起。最后都一一排除,还是tftp协议本身的问题。

在ubuntu12.04上,安装tftpd-hpa并按照教程设置后,也是断断续续的。

方法:tftp协议流程参考tcpipguide. 网络上实际报文流程需要抓包来分析。然后 对比正常和非正常的tftp抓包结果看出是blksize差异导致的。xp情况下无option negotiation应答包。但ubuntu下不清楚如何取消此应答机制,只能通过修改-B 参数来限制客户端发起的大包传输。如何修改tftpd-hpa的参数,通过查看源码来了解到参数选项。然后去/etc/default/tftpd-hpa中修改TFTP_OPTIONS="-l -c -s"修改为“-l -c -s -B 558".
然后发起sudo /etc/init.d/tftpd-hpa restart即可。


netstat -a|grep tftp可以查看tftp服务是否打开。

另外,在使用nfs的过程中,很奇怪,需要修改成全双工100M的网卡设置,才可以使用,设置成自动检测则不行。

而在ubuntu中设置,可以通过mii-tool或者ethtool来修改和查看网卡参数。http://linux.chinaitlab.com/administer/838653.html

  ethtool -s DEVNAME

  [ speed 10|100|1000 ]

  [ duplex half|full ]

  [ port tp|aui|bnc|mii|fibre ]

  [ autoneg on|off ]

windows xp上的设置比较简单,直接去网卡设置里选择即可。

static struct option long_options[] = {

{ "ipv4", 0, NULL, '4' },

{ "ipv6", 0, NULL, '6' },

{ "create", 0, NULL, 'c' },

{ "secure", 0, NULL, 's' },

{ "permissive", 0, NULL, 'p' },

{ "verbose", 0, NULL, 'v' },

{ "verbosity", 1, NULL, OPT_VERBOSITY },

{ "version", 0, NULL, 'V' },

{ "listen", 0, NULL, 'l' },

{ "foreground", 0, NULL, 'L' },

{ "address", 1, NULL, 'a' },

{ "blocksize", 1, NULL, 'B' },

{ "user", 1, NULL, 'u' },

{ "umask", 1, NULL, 'U' },

{ "refuse", 1, NULL, 'r' },

{ "timeout", 1, NULL, 't' },

{ "retransmit", 1, NULL, 'T' },

{ "port-range", 1, NULL, 'R' },

{ "map-file", 1, NULL, 'm' },

{ "pidfile", 1, NULL, 'P' },

{ NULL, 0, NULL, 0 }

};
https://www.kernel.org/pub/software/network/tftp/tftp-hpa/ installed on ubuntu.here is the source code.
http://www.tcpipguide.com/free/t_TFTPOptionsandOptionNegotiation.htm
TFTP Options and Option Negotiation

(Page 1 of 4)

One of the difficulties that designers of simple protocols and applications seem to have is keeping them simple. Many protocols start out small
but over time, well-intentioned users suggest improvements that are added slowly but surely. Eventually, the program that was once “lean and mean” has become, well, shall we say, “well-marbled”. J In
the software industry, this is called “feature creep” and it has happened to many protocols and applications.
The temptation to add features is especially strong when the program or protocol has few to begin with. Given this, the maintainers of the TFTP protocol have done a good
job over the years of avoiding this pitfall. However, they did allow one new feature to be added to the protocol in 1995: the TFTP Option Extension, which describes how a TFTP client and server can negotiate options before transferring a
file.
The reason for adding this capability is that the original TFTP protocol provided no way at all for the client and server to exchange important control information prior
to sending a file. This limited the flexibility of the protocol to deal with special cases, such as the transfer of data over unusual network types. The TFTP option negotiation feature allows additional parameters to be exchanged between the client and server
which govern how data is transferred. It does this without significantly complicating the protocol, and is backward-compatible with normal TFTP. It is only used if both client and server support it, and one device trying to use the feature will not cause problems
if the other doesn't support it.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: