|
The Network Simulator supports Telnet protocol for the Linux/Solaris devices in the device tree of the network simulator. You can also create your own SNMP devices with Telnet support. It enables execution of telnet commands on the simulated devices, from command line. To communicate with the simulated devices through telnet, you must log in to telnet by entering a valid user name and password.
1. Create a new network using the Linux/Solaris template devices. To create a new network, refer to Network Simulator Guide -> Creating a New Network.
(or)
Define your own SNMP devices in the device tree. Create a new network using the template devices. To create a new network, refer to Network Simulator Guide -> Creating a New Network.
The Network Simulator supports dynamic configuration of virtual ip addresses in Windows 2000/NT/XP and Linux/Solaris OS.
2. Right-click on the device in the network area and select the option Telnet -> Start Agent. This will automatically start the agent with the given IPAddress and at default port 2424.
3. To establish a telnet connection with the agent, go to command prompt and type: c:\> telnet <ip address> <port number>. Type the user name and password as root and public respectively.
4.The prompt displays the name of the device started. For example, if the device is a solaris device, the prompt will be displayed as follows:
[SunSolaris4@SunSolaris4 SunSolaris4]$
5. Type Help to list the commands that can be executed in this mode.
[SunSolaris4@SunSolaris4 SunSolaris4]$ help
exit
echo
date
help
ls
pwd
rm
free
cp
hostname
mkdir
mv
The commands supported in Linux and Solaris devices are given below. The script files (.py ) executed for these commands are available in <SimlatorHome>/network/<networkname>/<devicename>/telnet directory.
| Command Description |
Command |
|---|---|
|
Displays a list of files and sub directories in a directory. |
ls |
|
Displays the system date |
date |
|
Displays the system available memory |
free |
|
Displays messages |
echo |
|
Copies one or more files from the source location to another location |
cp <sourcefile> <destination> |
|
Moves one or more files from one directory to another directory |
mv <sourcefile> <destination> |
|
Creates a directory |
mkdir <directory> |
|
To change the telnet working directory to specified one |
cd <directory> |
|
Deletes a file |
rm <filename> |
|
To display the hostname of the device. |
hostname |
|
To display the current working directory |
pwd |
|
To close the telnet connection. |
exit |
The Telnet script API methods are added to the ScriptInterface to perform operations such as execute directory specific commands, execute global commands, execute display commands etc. from a JPython script. The script API methods are used within the Jython scripts to implement the telnet commands.
The Telnet script API methods are provided under <simulator
home>/examples/javadocs directory. The name of the script API
file is TELNET_SimScrIntf.html
1. getTelnetRootDir()
This method returns the current working directory of the telnet client.
|
public String getTelnetRootDir(); |
|
public String execDisplayCommand(String cmd); |
|
public String executeGlobalCmd(String cmd); |
|
public void executeTelnetCmd(String cmd); |
|
public void execGlobalTelnetCmd(String cmd); |
|
public boolean changeDirectory(String dir); |
|
public String getDeviceName(); |
|
public String getTelnetCommands(int dev); |
|
|
Note: Supports only those system commands that are supported in Java. |
The Network Simulator provides the option to define your own telnet commands and add the required script files to a specific device or to all the devices in the network. The script files can be defined using the Telnet script API methods.
1. Right-click on the Telnet device in the device tree and select the option Add Telnet Commands. The Telnet Script Configuration dialog is displayed, wherein you have to specify the device details and command details.
2. Specify the device details:
The name of the selected device, database name and the configuration name is displayed and is not configurable.
Specify any of the following options
Add command to device only : Adds the telnet command only to the selected device type in the device tree.
Add command to selected network: Adds the telnet command to the devices of same type, in the network selected in the network tree.
3. Specify the command details:
Command : Specify the exact command to be added.
Command Description : Specify the description of the command
Script File : Browse and select the script file to be configured for the command.
4. Click Add to add the command to the specified devices.
The Telnet script editor allows you to view and edit the script file configured for the telnet commands. It gives a list of all the telnet commands supported by the device. Selecting a command will display the script file configured for the command. You can view and edit the script file as per your requirement.
Right-click on the device in the network which supports Telnet protocol and select Telnet Commands Script. The telnet commands Script Editor is invoked. It displays the commands and the scripts implemented for the commands.
The icon shows that a script file is configured for the command. For example, for the command cd, the script file cd_cmd.py will be implemented when the complete command cd <WORD> is entered in the telnet console, where <WORD> is the directory name.
The following options are provided in the script editor to edit and save the changes or revert back.
Revert : To revert back the changes made in the current file.
Revert All : To revert back the changes made in all the files.
Save : To save the changes made in the current file.
Save All : To save the changes made in all the files
|