How can I modify the tftp timeout?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
  • (Edited)
I'd like to test if a tFTP server is up and if it's up I'm downloading some scripts on to the switch. Right now I'm trying to download a dummy file from the tFTP server using this command

    tftp get serverIP dummyFile.xsf

if the tftp server is up, I get a reply very fast that the file is not available. But if the server is down the timeout for the tftp command is 60 seconds. It is very long in my application. I'd like to decrease it to 5-6 seconds. Is this possible?

Is there any other method to find out if the server is up or not?


BTW, I've tried to ping the tFTP server but even when it's up I get this errPacket transmit error: Packet transmit error; Destination unreachable
Photo of Ali Askari

Ali Askari

  • 272 Points 250 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Brandon Clay

Brandon Clay, Escalation Support Engineer

  • 13,594 Points 10k badge 2x thumb
Hi Ali,

When you try to ping the TFTP server, are you using vr-default or vr-mgmt? In EXOS 'ping' defaults to vr-default, while tftp defaults to 'vr-mgmt'. I would suggest specifying vr-mgmt when you ping to see if that gets what you want.

ping vr vr-mgmt <IP_Address>

Photo of Ali Askari

Ali Askari

  • 272 Points 250 badge 2x thumb
Thanks Brandon. It is working now. But the problem is that I'm running the tFTP server on a Windows machine and right now even if the server is not up I get a reply to ping requests. 

Can I modify the tFTP timeout?
Photo of Henrique

Henrique, Employee

  • 10,342 Points 10k badge 2x thumb
Hi Ali, currently there is no native CLI option to modify the TFTP timeout.

An option would be creating a Python script to ping the server through MGMT vlan and only start the TFTP process if the server is up.

However this script might need to be created from scratch.

You can find some examples for Python scripts in the link below:

EXOS Python Scripts

Note: Python version 2.7.3 has been integrated into EXOS since EXOS 15.6.1
Photo of Ali Askari

Ali Askari

  • 272 Points 250 badge 2x thumb
Hi Henrique, thanks for your comment. I can write the python script but as I've explained to @Brandon my tFTP server is running on a Windows machine so if I ping the tFTP server and even if the server is not running I will get a reply to my ping requests, so ping is not useful in my case. 
Photo of OscarK

OscarK, ESE

  • 7,912 Points 5k badge 2x thumb
Using python you could use expect and the timeout option so it will fail if the command is not finished within that timeout.
Something like below but then you need to extend that a bit.

import pexpectimport exshexpect
exosPrompt = ' # '
Create an expect object. Pass in the prompt and the back end function to call:
p = exshexpect.exshspawn(exosPrompt, exsh.clicmd)
Use sendline to send commands to the backend function (in this case exsh.clicmd) :
p.sendline('tftp get <IP> <dummyfile>') <-
idx = p.expect([exosPrompt, pexpect.EOF, pexpect.TIMEOUT])
Photo of Matthew Hum

Matthew Hum, Principal Engineer, APAC

  • 1,542 Points 1k badge 2x thumb
Can I ask why you are doing this from a switch and not a server? It seems to me that it is much easier to write a script to test your tftp server and then send out notification (syslog/email) if the tftp server fails and put it on a cronjob.
Or even use nmap/nping or udpping to verify that your tftp server is up. that way you don't actually have to transfer any files.