Jump to content











Photo
- - - - -

How to check tftp server is running?


  • Please log in to reply
6 replies to this topic

#1 lune12

lune12
  • Members
  • 2 posts
  •  
    Israel

Posted 31 July 2008 - 08:29 AM

Hi all,

I have an application that transfer files using the tftp server tftpd32.
the user is requested to enter the tftp server IP.
Is there any command to check that a running tftp server exist on this IP?

Thanks,

#2 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 31 July 2008 - 11:09 AM

The quick way should be checking the result from sending a simple ping to the IP address but this doesn't help knowing if the service is running or not.

To check the service maybe you can try reading the error code outputted by TFTP.exe from windows when trying to download a file from a batch file (don't know if it is possible)

The adequate way to handle this procedure would be creating your own program to check the reliability of the TFTP server.

The protocol behavior is described here:

Details of a TFTP session

* The initiating host A sends an RRQ (read request) or WRQ (write request) packet to host B at the well-known port number 69, containing the filename and transfer mode.
* B replies with an ACK (acknowledgement) packet to WRQ and directly with a DATA packet to RRQ. Packet is sent from a freshly allocated ephemeral port, and all future packets to host B should be to this port.
* The source host sends numbered DATA packets to the destination host, all but the last containing a full-sized block of data. The destination host replies with numbered ACK packets for all DATA packets.
* The final DATA packet must contain less than a full-sized block of data to signal that it is the last. If the size of the transferred file is an exact multiple of the block-size, the source sends a final DATA packet containing 0 bytes of data

http://en.wikipedia....ansfer_Protocol

Meaning you would have to code your way to send a WRQ to the TFTP server on port 69 and check if an ACK is sent back.

:cheers:

#3 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7101 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 31 July 2008 - 04:05 PM

Wouldn't it be easier to send a "tftp get" for a small known file, say "serveris.up", and find out if the request errored out? :cheers:

jaclaz

#4 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 31 July 2008 - 04:55 PM

That's why I said:

To check the service maybe you can try reading the error code outputted by TFTP.exe from windows when trying to download a file from a batch file (don't know if it is possible)


I'm not an expert on batch files but would you care to try or "find" if tftp.exe from windows is capable of this?

:cheers:

#5 was_jaclaz

was_jaclaz

    Finder

  • Advanced user
  • 7101 posts
  • Location:Gone in the mist
  •  
    Italy

Posted 31 July 2008 - 06:20 PM

That's why I said:


I'm not an expert on batch files but would you care to try or "find" if tftp.exe from windows is capable of this?

:cheers:


EVERYTHING (almost) :cheers: is possible with BATCH files, why in my day ..... :cheers:

The output in Italian:

Y:\>tftp 10.2.7.1 get serveris.up
Tempo limite scaduto


The Batch:
@ECHO OFF

SET Smallfile=serveris.up

SET Address=

SET /P Address=TFTP Server Address? 

IF NOT DEFINED Address SET Address=10.2.7.1 

FOR /F "tokens=1,2,3 delims= " %%A IN ('tftp %Address% GET %Smallfile% 2^>^&1') DO (

SET Answer=%%A%%B%%C.

)



IF %Answer%==Tempolimitescaduto. ECHO NO tftp server on %Address%

The output of the batch:

Y:\>testtftp
TFTP Server Address?
NO tftp server on 10.2.7.1

Y:\>testtftp
TFTP Server Address? 10.2.7.9
NO tftp server on 10.2.7.9


It needs to be adapted to the user language, and of course it can be modified to change default server address or to interrogate a number of addresses, or whatever.

....and we LIKED it! :cheers:

jaclaz

#6 Brito

Brito

    Platinum Member

  • .script developer
  • 10616 posts
  • Location:boot.wim
  • Interests:I'm just a quiet simple person with a very quiet simple life living one day at a time..
  •  
    European Union

Posted 31 July 2008 - 10:25 PM

why in my day .....


Very true!

:cheers: :cheers:

#7 lune12

lune12
  • Members
  • 2 posts
  •  
    Israel

Posted 04 August 2008 - 11:32 AM

Thanks all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users