Commit 47feb5a0 authored by garciay's avatar garciay
Browse files

Add a configuration port to the RSUsimulator

parent 679bb02b
Loading
Loading
Loading
Loading
+45 −30
Original line number Original line Diff line number Diff line
package org.etsi.its.adapter.ports;
package org.etsi.its.adapter.ports;


/**
 *  Upper Tester port implementation. This port is used to trigger IUT's upper interface
 *  
 *  @author     ETSI / STF424
 *  @version    $URL$
 *              $Id$
 *
 */

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.DatagramSocket;
@@ -43,13 +53,13 @@ public class ConfigTesterPort extends AdapterPort implements IPort, IObservable
            }
            }
            cfPeerPort = Integer.parseInt(matcher.group(2));
            cfPeerPort = Integer.parseInt(matcher.group(2));
        } else {
        } else {
    
            // FIXME
        }   
        }   
        running = true;
        
        
        // UDP socket for communication with UT
        // UDP socket for communication with Configuration module
        running = true;
        try {
        try {
            cfSocket = new DatagramSocket();
            cfSocket = new DatagramSocket(cfPeerPort + 1);
            cfThread = new UdpThread(cfSocket);
            cfThread = new UdpThread(cfSocket);
            cfThread.start();
            cfThread.start();
        } catch (Exception e) {
        } catch (Exception e) {
@@ -59,15 +69,19 @@ public class ConfigTesterPort extends AdapterPort implements IPort, IObservable
    
    
    @Override
    @Override
    public boolean send(final byte[] message) {
    public boolean send(final byte[] message) {
        
        DatagramPacket packet = new DatagramPacket(message, message.length, cfPeerAddress, cfPeerPort);
        try {
        try {
            ByteArrayOutputStream dataToSent = new ByteArrayOutputStream();
            dataToSent.write(message);
            byte[] output = dataToSent.toByteArray();
            DatagramPacket packet = new DatagramPacket(output, output.length, cfPeerAddress, cfPeerPort);
            cfSocket.send(packet);
            cfSocket.send(packet);
        } catch (IOException e) {
            
            return true;
        } catch (Exception e) {
            e.printStackTrace();
            e.printStackTrace();
            return false;
        } 
        } 
        return true;
        
        return false;
    }
    }


    @Override
    @Override
@@ -93,7 +107,7 @@ public class ConfigTesterPort extends AdapterPort implements IPort, IObservable
    
    
    /**
    /**
     * Indicates whether the port is still active. Setting this field to false will cause
     * Indicates whether the port is still active. Setting this field to false will cause
     * the UDP communication with Config Tester to be stopped
     * the UDP communication with Upper Tester to be stopped
     */
     */
    private volatile boolean running;
    private volatile boolean running;
    
    
@@ -124,6 +138,7 @@ public class ConfigTesterPort extends AdapterPort implements IPort, IObservable
            }
            }
            taSocket.close();
            taSocket.close();
        }
        }
    }
        
    } // End of class UdpThread
    
    
} // End of class ConfigTesterPort 
} // End of class ConfigTesterPort 
+7 −6
Original line number Original line Diff line number Diff line
@@ -62,6 +62,7 @@ public class CodecFactory {
            // initialize additional codec plugins
            // initialize additional codec plugins
            org.etsi.ttcn.codec.its.adapter.Plugin.init();
            org.etsi.ttcn.codec.its.adapter.Plugin.init();
            org.etsi.ttcn.codec.its.uppertester.Plugin.init();
            org.etsi.ttcn.codec.its.uppertester.Plugin.init();
            org.etsi.ttcn.codec.its.configtester.Plugin.init();
            org.etsi.ttcn.codec.its.geonetworking.Plugin.init();
            org.etsi.ttcn.codec.its.geonetworking.Plugin.init();
            org.etsi.ttcn.codec.its.btp.Plugin.init();
            org.etsi.ttcn.codec.its.btp.Plugin.init();
            org.etsi.ttcn.codec.its.security.Plugin.init();
            org.etsi.ttcn.codec.its.security.Plugin.init();
@@ -80,8 +81,8 @@ public class CodecFactory {
        //TERFactory.getInstance().logDebug("getExternalCodec: Search external codec for " + encoding);
        //TERFactory.getInstance().logDebug("getExternalCodec: Search external codec for " + encoding);
        codec = externalCodecs.get(encoding);
        codec = externalCodecs.get(encoding);
        if(codec != null) {
        if(codec != null) {
            TERFactory.getInstance().logDebug(String.format("%50s", encoding));
            //TERFactory.getInstance().logDebug(String.format("%50s", encoding));
            TERFactory.getInstance().logDebug(" ==> " + codec.getClass().getName());      
            //TERFactory.getInstance().logDebug(" ==> " + codec.getClass().getName());      
            return codec;
            return codec;
        }
        }
        return null;
        return null;
@@ -89,11 +90,11 @@ public class CodecFactory {
    
    
    public ICodec getCodec(MainCodec mainCodec, int classType, String encoding, String typeName) {
    public ICodec getCodec(MainCodec mainCodec, int classType, String encoding, String typeName) {


        TERFactory.getInstance().logDebug(String.format("%50s", typeName + "(" + encoding + ")"));
        //TERFactory.getInstance().logDebug(String.format("%50s", typeName + "(" + encoding + ")"));
        Class<? extends ICodec> cls = null;
        Class<? extends ICodec> cls = null;
        Class<?>[] ctorParams = {MainCodec.class};
        Class<?>[] ctorParams = {MainCodec.class};


        TERFactory.getInstance().logDebug("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName);
        //TERFactory.getInstance().logDebug("getCodec: Search internal codec for " + classType + '/' + encoding + '/' + typeName);
        cls = codecs.get(classType + '/' + encoding + '/' + typeName);
        cls = codecs.get(classType + '/' + encoding + '/' + typeName);
        if(cls == null) {
        if(cls == null) {
            cls = codecs.get(classType + '/' + encoding + '/');
            cls = codecs.get(classType + '/' + encoding + '/');
@@ -103,7 +104,7 @@ public class CodecFactory {
        }
        }


        if(cls != null) {
        if(cls != null) {
            TERFactory.getInstance().logDebug(" ==> " + cls.getName());
            //TERFactory.getInstance().logDebug(" ==> " + cls.getName());
            try {
            try {
                Constructor<? extends ICodec> ctor = cls.getConstructor(ctorParams);
                Constructor<? extends ICodec> ctor = cls.getConstructor(ctorParams);
                return ctor.newInstance(mainCodec);
                return ctor.newInstance(mainCodec);
@@ -113,7 +114,7 @@ public class CodecFactory {
            }
            }
        }
        }


        TERFactory.getInstance().logDebug(" ==> No codec found !");      
        //TERFactory.getInstance().logDebug(" ==> No codec found !");      
        return new Dummy(mainCodec);
        return new Dummy(mainCodec);
    }
    }


+22 −0
Original line number Original line Diff line number Diff line
package org.etsi.ttcn.codec.its.configtester;

import org.etsi.ttcn.codec.CodecBuffer;
import org.etsi.ttcn.codec.MainCodec;
import org.etsi.ttcn.codec.generic.Charstring;
import org.etsi.ttcn.tci.Type;

public class CfEvent extends Charstring {

	public CfEvent(MainCodec mainCodec) {
		super(mainCodec);
	}
	
	@Override
    protected void preDecode(CodecBuffer buf, Type decodingHypothesis) {
        // Set Length for CfEvent
        mainCodec.setHint("CfEventLen", new Integer(buf.getNbBytes()).toString());
        
        return;
    }

}
+23 −0
Original line number Original line Diff line number Diff line
/**
 * @author      ETSI / STF517 / Yann garcia
 * @version     $URL$
 *              $Id$
 */
package org.etsi.ttcn.codec.its.configtester;

import org.etsi.ttcn.tci.TciTypeClass;
import org.etsi.ttcn.codec.CodecFactory;

import org.etsi.ttcn.codec.generic.Record;
import org.etsi.ttcn.codec.generic.Boolean;

public class Plugin {

    public static void init() {
        // Basics
        CodecFactory cf = CodecFactory.getInstance();
        cf.setCodec(TciTypeClass.RECORD, "ConfigTester", "", Record.class);
        cf.setCodec(TciTypeClass.BOOLEAN, "ConfigTester", "", Boolean.class);
        cf.setCodec(TciTypeClass.CHARSTRING, "ConfigTester", "", CfEvent.class);
    }
}
 No newline at end of file
+12 −11
Original line number Original line Diff line number Diff line
# Debug level - Authorized values: OFF, ALL, INFO, SEVERE
# Debug level - Authorized values: OFF, ALL, INFO, SEVERE
DEBUG_ENABLED=ALL
DEBUG_ENABLED=ALL
# Define the port/layer configuration for CAM
# Define the port/layer configuration for CAM
#camPort=BTP/GN/ETH
camPort=BTP/GN/ETH
camPort=BTP/GN/CSG
#camPort=BTP/GN/CSG
# Define the port/layer configuration for DENM
# Define the port/layer configuration for DENM
denmPort=BTP/GN/ETH
denmPort=BTP/GN/ETH
# Define the port/layer configuration for MAPEM-SPATEM
# Define the port/layer configuration for MAPEM-SPATEM
@@ -19,16 +19,17 @@ geoNetworkingPort=ETH
ipv6OverGeoNetworkingPort=Debug
ipv6OverGeoNetworkingPort=Debug
# Define the port/layer configuration for CALM FNTP
# Define the port/layer configuration for CALM FNTP
#fntpPort=FNTP/ETH
#fntpPort=FNTP/ETH
fntpPort=FNTP/UdpIp
#fntpPort=FNTP/UdpIp
# Define the port/layer configuration for CALM FSAP
# Define the port/layer configuration for CALM FSAP
fsapPort=FSAP/UdpIp
#fsapPort=FSAP/UdpIp
fsapPort=FSAP/UdpIp
#fsapPort=FSAP/UdpIp


#UpperTesterSettings=192.168.42.1:12345
#UpperTesterSettings=192.168.42.1:12345
UpperTesterSettings=172.17.15.38:12345
UpperTesterSettings=172.17.15.38:12345
ConfigTesterSettings=172.17.15.39:12346


# Peer ITS station
# Peer ITS station
#LinkLayer_Peer=8BADF00D0099
#LinkLayer_Peer=8BADF00D0199


# Define the MAC address of the Ethernet interface connected to the IUT device
# Define the MAC address of the Ethernet interface connected to the IUT device
#       Home laptop VMWare MAC address
#       Home laptop VMWare MAC address
@@ -45,15 +46,15 @@ PcapFile=
# Define the Ethernet type value used by the IUT
# Define the Ethernet type value used by the IUT
IutEthernetTypeValue=0x8947
IutEthernetTypeValue=0x8947
# Node Ethernet addresses
# Node Ethernet addresses
LinkLayer_MTC=8BADF00D0000
LinkLayer_MTC=8BADF00D0100
# Link-Layer address of component NodeA
# Link-Layer address of component NodeA
LinkLayer_NodeA=8BADF00D0001
LinkLayer_NodeA=8BADF00D0101
# Link-Layer address of component NodeB
# Link-Layer address of component NodeB
LinkLayer_NodeB=8BADF00D0002
LinkLayer_NodeB=8BADF00D0102
# Link-Layer address of component NodeC
# Link-Layer address of component NodeC
LinkLayer_NodeC=8BADF00D0003
LinkLayer_NodeC=8BADF00D0103
# Link-Layer address of component NodeD
# Link-Layer address of component NodeD
LinkLayer_NodeD=8BADF00D0004
LinkLayer_NodeD=8BADF00D0104
# Interval between each beacon sent by TS (ms)
# Interval between each beacon sent by TS (ms)
TsBeaconInterval=1000
TsBeaconInterval=1000
# Latitude of Test System
# Latitude of Test System