|
AdventNet Simulation Toolkit has implemented the TFTP client and server protocol, an optional facility that enables transfer of files between the TFTP client and the TFTP server. This facility enables the manager to configure an agent by changing the agent configuration files. The agent can use this facility to report any issues to the manager.
The file transfer can be done from the Network designer UI or using Jython scripts or through RMI at network startup or during runtime. The mode of transfer may be ascii or binary. The files transferred should have the 'public' access. TFTP uses UDP to transfer packets across the network.
Transferring Files From the Network Designer UI
The Network designer provides options to configure and start the TFTP server and transfer files between the client and the server.
Configuring TFTP server root directory
You can configure root directory for individual devices in the network. By default, a TFTP server will have the root directory below ./networks/<networkname>/tftp/<templatedevicename> for all the devices.
To configure root directory for individual devices,
Right-click on a device in the network either from the network area.
Select the option Device Info -> TFTP
The default root directory will be displayed as ./networks/<networkname>/tftp/<templatedevicename>. This can be configured as per your requirement.
Click OK to apply the changes.
To configure root directory in bulk based on the template devices, use the template device right-click menu option. Refer to Template Devices and Configurations - Telnet Parameters for more information.
Configuring Scripts to be Executed on File Upload or Download
You can configure Jython script files to be executed when a file is uploaded to the server or downloaded from the server. This facility can be used to inform the manager about a file transfer, by way of sending traps etc. You can configure different script files for individual servers or same script file for all the servers.
To configure scripts on individual devices,
Right-click on a device in the network either from the network tree or network area.
Select the option Device Info -> TFTP
To execute a script when a file is downloaded from the server, browse and select the script (.py file) in the Execute script on download combo box. This script file will be copied in ./networks/<networkname>/tftp/<templatedevicename>/<devicename> directory in the name TftpDownloadScript.py. The script will be executed whenever a file is downloaded from the TFTP server in the simulator.
To execute a script when a file is uploaded to the server, browse and select the script (.py file) in the Execute script on upload combo-box. This script file will be copied in ./networks/<networkname>/tftp/<templatedevicename>/<devicename> directory in the name TftpUploadScript.py. The script will be executed whenever a file is uploaded to the TFTP server in the simulator.
Click OK to apply the changes.
To configure upload/download scripts in bulk based on the template devices, use the template device right-click menu option. Refer to Template Devices and Configurations - Telnet Parameters for more information.
To start the TFTP server in individual devices,
Right-click on a device in the network either from the network tree or network area.
Select the option TFTP -> Start. This will start the server at the port specified in the TFTP Server Properties dialog. By default, the TFTP server starts at port 6969 with the root directory as ./networks/<networkname>/tftp/<templatedevicename>.
Transferring Files Between the Client and the Server
Right-click on a device in the network either from the network area.
Select the option TFTP Client. This will display the TFTP client dialog. Specify the following details in this dialog:
Server IP : Specify the TFTP server IP address (e.g., 200.201.202.1)
Port: The TFTP client talks to the standard TFTP port 6969 on the TFTP server by default. If the server is configured to use a non-standard port, you can specify it in this option.
Timeout: Specify the time to wait for a response between successive retransmits in milliseconds. The default is 5000 milliseconds.
Retries : Specify the number of retransmits. The default number of retries is 0.
Mode: By default, the transfer mode is binary (octet) . If you want ascii data to be transferred, then select the mode as netascii.
Command : Select the command as Download file to download a file from the server to the client. Select the command as Upload File to upload a file from the client to the server.
If the command is to download a file from the server, specify the source and target as follows:
Source : Specify the file name to be retrieved from the server with the relative path. The path specified must not be outside the root directory of the server, as specified in the TFTP server properties.
Target: Specify the file name with path, to save the downloaded data in the client.
If the command is to upload a file to the server, specify the source and target as follows:
Source : Specify the file name with path, to be retrieved from the client.
Target: Specify the file name with path, to upload the data in the server. The path specified must not be outside the root directory of the server as specified in the TFTP server properties.
Click Transfer to download or upload the files. The timeout value will be 5000 milliseconds by default and the retries will be 0 by default. If the file is transferred the message File Transferred will be displayed.
Click Close to exit the dialog.
To stop the TFTP server in individual devices,
Right-click on a device in the network either from the network tree or network area.
Select the option TFTP -> Stop. This will stop the TFTP server running at the specified port.
Transferring files from Jython Scripts and RMI
Simulation Toolkit has implemented methods in RMI and Jython script interface to start the TFTP server, transfer files between the client and server and stop the TFTP server, at agent runtime. These methods are defined in the following script APIs and RMI client APIs in <SimulatorHome>/examples/javadocs directory.
SNMPScriptInterface: Defines the methods that can be used to perform operations on a SNMP device, from a Jython script file.
TL1ScriptInterface: Defines the methods that can be used to perform operations on a TL1 device, from a Jython script file.
NetSimSnmpInterface: Defines the methods that can be used to perform operations on a SNMP agent via RMI.
NetSimTL1Interface: Defines the methods that can be used to perform operations on a TL1 agent via RMI.
This method can be used to start the TFTP server in the Network from any other agent, at runtime.
|
startTftpServer(String ipAddress, int port, String rootDir); |
where,
ipAddress - the ip address of the server
port - the port number where the server is started
rootDir - the root directory of the server.
Note : The files can be downloaded from or uploaded to the root directory or within its subdirectories.
Transferring Files between the Client and the Server
This method can be used to upload the 'source' file to the TFTP server running at the specified ip address and port number, to the 'target' file in ascii or binary mode using the 'tftp/ftp' protocol.
|
uploadFile(String ipAddress, int port, # String source, String target, int mode, String protocol); |
where,
ipAddress - The ip address at which the TFTP server is running
port - The port in the host at which the TFTP server is running
source - The source file name with path, to be retrieved from the client.
target - The file name with path, to upload the data in the server.
mode - The mode of transfer, 0 for netascii mode and 1 for octets mode
protocol - The protocol used to transfer the files, ftp/tftp
This method can be used to download the 'source' file from the TFTP server running at the specified ip address and port number, to the 'target' file in ascii or binary mode using the 'tftp/ftp' protocol.
|
downloadFile (String ipAddress, int port, # String source, String target, int mode, String protocol); |
where,
ipAddress - The ip address at which the TFTP server is running
port - The port in the host at which the TFTP server is running
source - The file name with path, to be retrieved from the server.
target - The file name with path, to download the data in the client.
mode - The mode of transfer, 0 for netascii mode and 1 for octets mode
protocol - The protocol used to transfer the files, ftp/tftp
This method can be used to stop the TFTP server from any other agent in the network, at runtime.
|
stopTftpServer(String ipAddress, int port); |
where,
ipAddress - ip address of the tftp server
port - the port number where the server is started
Checking if TFTP server is running at the specified port
This method can be used at runtime to check if the TFTP server is running at the specified ip address and port number.
|
isTftpRunning(String ipAddress, int port); |
Refer to section Managing Agents via RMI, to learn more about managing the agent via RMI.
Refer to section Configuring Network Behavior, to learn more about configuring behavior scripts.
|