Allow Java library talk to PT - PTAnywhere/ptAnywhere-installation GitHub Wiki

The Java library which allows you to talk to Packet Tracer using IPC is called ptipc. You need to configure some authentication parameters in Ptipc before using it in any application.

In this page we will describe how to make the library communicate with Packet Tracer using a PT application.

Create a PT application

This section describes how to make an application for Packet Tracer called uk.ac.open.kmi.pt.example and the following secret password: insecurePassword.

( TODO automatize the following procedure using Ansible)

  1. Get a valid P12 certificate.
  2. Create a folder for your new application in the extensions folder of your Packet Tracer installation. In the next steps, we will refer to this folder as APP_FOLDER ($PT_PATH/extensions/sampleApp).
cd $PT_PATH/extensions
mkdir sampleApp

3. Create a XML file called sampleApp.xml describing the application in APP_FOLDER.

<?xml version="1.0" encoding = "iso-8859-1"?>
<!DOCTYPE PT_APP_META>
<PT_APP_META>
    <PT_VERSION>6.0.1</PT_VERSION>
    <IPC_VERSION>1.0</IPC_VERSION>
    <NAME>Sample application</NAME>
    <VERSION>1.0</VERSION>
    <ID>uk.ac.open.kmi.pt.example</ID>
    <DESCRIPTION>Sample application to allow to the Java library connect to Packet Tracer.</DESCRIPTION>
    <AUTHOR>Aitor Gomez-Goiri</AUTHOR>
    <CONTACT>[email protected]</CONTACT>
    <EXECUTABLE_PATH>sampleApp</EXECUTABLE_PATH>
    <KEY>insecurePassword</KEY>
    <SECURITY_SETTINGS>
        <PRIVILEGE>GET_NETWORK_INFO</PRIVILEGE>
        <PRIVILEGE>CHANGE_NETWORK_INFO</PRIVILEGE>
        <PRIVILEGE>SIMULATION_MODE</PRIVILEGE>
        <PRIVILEGE>MISC_GUI</PRIVILEGE>
        <PRIVILEGE>FILE</PRIVILEGE>
        <PRIVILEGE>CHANGE_PREFERENCES</PRIVILEGE>
        <PRIVILEGE>CHANGE_GUI</PRIVILEGE>
        <PRIVILEGE>ACTIVITY_WIZARD</PRIVILEGE>
        <PRIVILEGE>MULTIUSER</PRIVILEGE>
        <PRIVILEGE>IPC</PRIVILEGE>
        <PRIVILEGE>APPLICATION</PRIVILEGE>
    </SECURITY_SETTINGS>
    <LOADING>ON_DEMAND</LOADING>
    <SAVING>NEVER</SAVING>
    <INSTANCES>1</INSTANCES>
</PT_APP_META>
  • Note LOADING option affects how the ExApp is launched in Packet Tracer. Use ON_STARTUP to launch/open it automatically on startup. For this, you might require then to sign it and mark the publisher as trusted on Preferences > Publishers > Add.... Use ON_DEMAND if you don't need to launch your application from Packet Tracer (our case).

4. Create a PTA called sampleApp.pta in APP_FOLDER. This file is the encrypted version of the previous xml.

cd $PT_PATH/extensions
./meta sampleApp/sampleApp.pta sampleApp/sampleApp.xml
  • Do you need to sign it? Try adding the following parameter. (Note: this is required to launch it on startup, which is not the PTAnywhere case)
cd $PT_PATH/extensions
./meta sampleApp/sampleApp.pta sampleApp/sampleApp.xml -c ../ptserver-ou.p12
[ENTER] (for a certificate with an empty passphrase)

Configure Ptipc library

To configure the library, create a pt_cep.properties file under the resources folder of the library (src/main/resources if you have mavenified it).

This file should look like this:

# set PTMP parameters
pt.cep.ptmp.uid={c6fbf435-3234-48bb-af04-debc4e4cf9f3}
pt.cep.ptmp.signature=PTMP
pt.cep.ptmp.version=1

# set connection parameters
# set encoding to TEXT_ENCODING or BINARY_ENCODING
pt.cep.encoding=TEXT_ENCODING

# set encryption to NO_ENCRYPTION or XOR_ENCRYPTION
pt.cep.encryption=NO_ENCRYPTION
    
# set compression to NOT_COMPRESSED or ZLIB_COMPRESSED
pt.cep.compression=NOT_COMPRESSED
 
# set authentication to SIMPLE_AUTH, CLEAR_TEXT_AUTH or MD5_AUTH (currently only MD5_AUTH is supported)
pt.cep.authentication=MD5_AUTH

# set authentication parameters
pt.cep.auth.secret=insecurePassword
pt.cep.auth.application=uk.ac.open.kmi.pt.example
pt.cep.keepAlivePeriod=10
⚠️ **GitHub.com Fallback** ⚠️