Issuing Eggplant Network Emulator Commands

If you want to operate Eggplant Network from a command-line interface (CLI), you have two methods of sending commands:

  • From the command line using
  • Using the socket API

From the Command Line

If you want to control the Emulator from the command line, you can use the provided Python script, You can download this script from the Eggplant downloads page for Eggplant Network; the file is called API Client v2.1.0 ( You need an installed Python language interpreter to run the script. The scripts have been tested with both Python 2.x and Python 3.x.

You must also supply necessary parameters for the user and password you want to use, as well as the IP address of the Emulator you want to control. Finally, you include the task you want to perform.

In generic terms, that list of requirements looks like this:

$ python --host <Emulator IP address> --user <username> --password <password> --command [--options . . .]

You’ll be interested in the result of your commands, so sending the output to a file by adding >filename (and then scanning this file) or piping the output to another program is a good idea.

To see what commands you can use with the Emulator, see Starting, Stopping, and Listing Emulations from the Command Line and Additional Eggplant Network Emulator Commands.

The Socket API

If you use the direct TCP socket method, a script is not used and instead just the command and options are specified and sent through a socket.

There is a wrinkle, however: The communication must be done using Secure Sockets Layer (SSL), and this requirement creates a few extra steps. The first thing you need to do is to get the remote certificate for the SSL connection. Then you can issue commands. The two sections below detail these steps with Python source examples.

Get the Remote Certificate

You retrieve the SSL certificate from the Emulator and store it in a file where it can be used later. In our sample Python script, that is done like this:

def getRemoteCert(self):

certData = ssl.get_server_certificate((, self.port), ssl_version=ssl.PROTOCOL_TLSv1)


if not len(certData):

raise IneError('Unable to retrieve certificate from the server')



fpath = tempfile.gettempdir() + '/server.crt'

f = open(fpath, 'w')


self.cert =



raise IneError('Unable to store server certificate to establish SSL connection')

In summary, this process amounts to:

  1. Request the remote certificate from the Emulator with IP address and using port self.port (7292); the request uses the Python library method ssl.get_server_certificate with SSL version set to TLSv1.
  2. Store the certificate in a temp file with the name server.crt.

Issue Commands

After you have the certificate (which is clearly not necessary to do for each command), you can send commands to the Emulator.

The steps for sending commands, showing Python source examples, is as follows:

  1. Create a socket:

    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

  2. Wrap the socket with the SSL layer:

    sslsock = ssl.wrap_socket(s, ca_certs=self.cert, cert_reqs=ssl.CERT_REQUIRED,ssl_version=ssl.PROTOCOL _TLSv1)

  3. Connect the SSL socket on port 7292:

    sslsock.connect((, self.port))

  4. Send command and options:


  5. Read response:

    data = sslsock.recv(4096).decode()

  6. Process the response and check for errors (--error).
  7. If you have further commands to send, repeat steps 4 through 7.
  8. Finally, close the socket:



This topic was last updated on August 19, 2021, at 03:30:51 PM.

Eggplant icon | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant