jDiameter

jDiameter

Following is example of Diameter client which could be used for testing.


1. (OPTIONAL) Install IDE NetBeans

2. Download and install Mobicent RestComm jDiameter

git clone https://github.com/RestComm/jdiameter.git
cd jdiameter/
mvn clean install

3. (OPTIONAL) Import jDiameter and jdiameter/examples/guide1 project into NetBeans

4. Work with jdiameter/examples/guide1 and modify the ExampleClient.java and ExampleServer.java, attached bellow are modified files.

ExampleClient.java

...private static final int commandCode = 316;private static final long applicationID = 16777251;......public static byte[] hexStringToByteArray(String s) {int len = s.length();byte[] data = new byte[len / 2];for (int i = 0; i < len; i += 2) {data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16));}return data;}
private void sendNextRequest(int enumType) throws InternalException, IllegalDiameterStateException, RouteException, OverloadException {Request r = this.session.createRequest(commandCode, this.authAppId, realmName, serverURI);// here we have all except our custom avps
// example how to remove AVPAvpSet requestAvps = r.getAvps();requestAvps.removeAvp(293);
// example how to add AVP IMSIbyte[] b = hexStringToByteArray("31313131313131313131313131313131");requestAvps.addAvp(1, b, true, false);// code , value , vendor, mandatory,protected,isUnsigned32// (Enumerated)Avp exchangeType = requestAvps.addAvp(exchangeTypeCode, (long) enumType, vendorID, true, false, true);
// code , value , vendor, mandatory,protected, isOctetStringAvp exchengeData = requestAvps.addAvp(exchangeDataCode, TO_SEND[toSendIndex++], vendorID, true, false, false);

// sendthis.session.send(r, this);dumpMessage(r,true); //dump info on console}...

5. Run ExampleServer and ExampleClient. Example of generated traffic is bellow.