MTS_development_guide - MTS (Multi

advertisement
MTS documentation / User Manual / Development guide
Development Guide
For new
features
implementation
Version: %VERSION%
Version: %VERSION%
1/5
MTS documentation / User Manual / Development guide
Table of contents
1
2
3
4
5
Generalities .................................................................................................................... 3
Add system operations ................................................................................................... 3
Add new protocols .......................................................................................................... 3
Update protocols grammar ............................................................................................. 4
Build project using maven .............................................................................................. 5
Version: %VERSION%
2/5
MTS documentation / User Manual / Development guide
1
Generalities
In this document we will discuss how to add features to MTS. These features are:
Adding new protocols to MTS (ETHERNET protocol will be taken as example)
Adding new system operations (IP address conversion to hex string as example)
Update of protocol grammar (GTPv1 grammar update will be taken as example)
In a way to simplify further explanations, all java files used are under
com.devoteam.srit.xmlloader package. If not it will be explicitly describe.
This tutorial is not a step by step guide, you will have to take account of your personal needs
and adapt these step to your requirements.
Finally, this tutorial is not complete; if you add features that are not described here, please
feel free to fill this tutorial and send it back to our developers (emails can be found in
googlecode repository page).
2
Add system operations
In this part we will see how to add system operations to MTS like binary.equals,
string.equals, number.add, and so on …
As an example, we will add the following system operation: binary.fromIp
This operation take an IP address written in dotted decimal representation (aaa.bbb.ccc.ddd)
and convert it into hex string (e.g 172.16.21.112 will be convert into ac101570).
This is really simple; here is how to do it (files are in package described in Introduction):
I.
In file core.operations.basic.operators.PluggableParameterOperatorBinary.java:
a.
Add a string before constructor to declare your new operation; in this case the
string will be “binary.fromIp”
b.
In constructor, declare a new “PluggableName” using the string created
previously (just copy and paste previous lines and modify the string used to
create the PluggableName class)
c.
In function “operate”, add an if statement and put your algorithm in it
II.
Add a description for each system operation you added in file
src/main/conf/schemas/parameter_operation.xsd in a way to get manual correctly
generated
III.
Compile and run the application, test your new system operation to see if it act like it
should be
3
Add new protocols
In this part we will discuss how to add new protocols to MTS. As protocols are very different
from each other, this tutorial will have to be modifying according to the protocol you need to
implement. This part shows the main files and changes to do to have a working protocol
stack. To illustrate this, we will use the ETHERNET protocol, last protocol that has been
added to MTS. Here is the step to follow:
1.
In file src/main/conf/schemas/scenario.xml:
a.
Add an include clauses for the following files
i.
list_ethernet.xsd (list all operations for Ethernet protocol)
ii.
type_operations_ethernet.xsd (define all operations of Ethernet
protocol)
b.
After included clauses, declare the use of newly created files
i.
&listXX;
Version: %VERSION%
3/5
MTS documentation / User Manual / Development guide
2.
3.
4.
4
ii.
&type_operationsXX;
In directory src/main/conf/schemas:
a.
Create two XSD files and fill them with protocol grammar (use others XSD files
as examples)
i.
list_ethernet.xsd
ii.
type_operations_ethernet.xsd
In directory src/main/conf:
a.
Create a property file for the Ethernet protocol
i.
ethernet.properties and fill it like others properties files according to
your needs
In package com.devoteam.srit.xmlloader:
a.
Create a new package and name it ethernet
b.
In package ethernet newly created
i.
Create a java class named MsgEthernet that extends abstract class
named Msg
ii.
Create a java class named StackEthernet that extends abstract class
named Stack
iii.
Create a java class named ListenpointEthernet that extends abstract
class named Listenpoint
iv.
Eventually create a java class named ChannelEthernet that extends
abstract class named Channel if you need to
c.
In package core.protocol
i.
In file StackFactory.java
1.
Declare the Ethernet protocol and allow access to Ethernet
stack class previously created
2.
Declare Ethernet stack in getStack() function
3.
Declare Ethernet stack in getAllStack() function
d.
In package core
i.
In file scenario.java
1.
Add callback function relative to Ethernet operations
(sendMessageETHERNET, receiveMessageETHERNET …)
Update protocols grammar
In this part we will discuss how to modify protocols grammar. For the example, we will use
GTPv1 protocol and add the possibility to have a <pdu> tag that contains binary data (for 255
PDU type).
To update protocols grammar, you have to modify grammar files but also algorithm behind
parsing to handle correctly the modifications.
I.
II.
III.
In file type_operations_gtpp.xsd
a.
Add a <pdu> tag inside <sendMessageGTP> tag
In package gtp.data
a.
In file MessageGTP.java
i.
In constructor, add a piece of code to parse correctly the <pdu> tag
and build a byte array fill by user’s data
b.
Create a DataPDU.java class and implement the following methods:
i.
decodeFromArray(…)
ii.
getParameter(…)
iii.
parseFromXML(…)
iv.
encodeToArray(…)
v.
toXML()
vi.
toString()
In package gtp
a.
In file MsgGtp.java
Version: %VERSION%
4/5
MTS documentation / User Manual / Development guide
i.
5
Update of getByteDatas() to handle byte array created from parsing
Build project using maven
To build project using maven, please first check you java JRE and JDK version. Somme
compilation errors have been found with JRE 7 so please use JRE6 and JDK 1.6.
In order to get project compiled using maven, you have to:
- Launch maven-clean.bat in root folder of your svn repository
- Use xmlspy to generate correctly the documentation of the project before building the
jar file
- Launch maven-install.bat to generate target install folder (this will create a MTS jar
archive file and a mts directory that will hold MTS directories architecture as if it have
been installed using jar file previously created)
Version: %VERSION%
5/5
Download