Telnet Protocol Support

 



 

Overview

 

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.

 

Starting Telnet

 

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

 

Commands Supported

 

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

 

 

Telnet Script API Methods

 

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();

 
2. execDisplayCommand(String cmd)
 
This method is used in the execution of commands that result in some output display. The output will be specific to the directory from where the command is being executed.
 
For example, the output of the command "ls" results in the display of files and sub directories in a specific directory.
 

public String execDisplayCommand(String cmd);

 
 
3. executeGlobalCmd(String cmd)
 
This method is used in the execution of commands that result in some output display. The output will remain globally similar, irrespective of the directory from where it is executed.
 
For example, the output of the  "echo" command will be the same, irrespective of the directory from where it is executed.
 

public String executeGlobalCmd(String cmd);

 
 
4. executeTelnetCmd(String cmd)
 
This method is used in the execution of commands that result in some action being executed in the system without any output display. The action executed will be within the specified directory.
 
For example, the output of the command "mkdir" creates a directory, within the specified directory.
 

public void executeTelnetCmd(String cmd);

 
 
5. execGlobalTelnetCmd(String cmd)
 
This method is used in the execution of commands that result in some action being executed in the system without any output display. The action will be globally executed and not confined to any specific directory .
 
For example, the output of the "cd <directory>" command changes the telnet working directory to specified one.
 

public void execGlobalTelnetCmd(String cmd);  

 
 
6. changeDirectory(String dir)
 
To method is used to change the current working directory.
 

public boolean changeDirectory(String dir);

 
7. getDeviceName()

This method gets the device name for which the request has come.
 

public String getDeviceName();

 
 
8.  getTelnetCommands(int dev)

This method returns all the commands supported by the device. For linux/solaris device, integer 1 must be specified and for Windows device integer 2 must be specified.
 

public String getTelnetCommands(int dev);

 

 

Note: Supports only those system commands that are supported in Java.

 
 

Adding Telnet Commands

 

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:

3. Specify the command details:

4. Click Add to add the command to the specified devices.

 

Editing Telnet Scripts

 

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



Copyright © 1996-2006, AdventNet Inc. All Rights Reserved.