Commit 454a04fc authored by garciay's avatar garciay
Browse files

Enhance AtsRSUSimulator to validate Test System & ATSs

parent 735f214b
Loading
Loading
Loading
Loading
+125 −0
Original line number Diff line number Diff line
#include "ConfigRsuSimulatorPort.hh"
//#include "ConfigRsuSimulatorLayerFactory.hh"
#include "loggers.hh"

namespace ItsRSUsSimulator__TestSystem {

  ConfigRsuSimulatorPort::ConfigRsuSimulatorPort(const char *par_port_name)
    : ConfigRsuSimulatorPort_BASE(par_port_name), _cfg_params(), _layer_params(), _layer(nullptr), _time_key("ConfigRsuSimulatorPort::outgoing_send") {
    // Nothing to do
  } // End of constructor
  
  ConfigRsuSimulatorPort::~ConfigRsuSimulatorPort()
  {
    loggers::get_instance().log(">>> ConfigRsuSimulatorPort::~ConfigRsuSimulatorPort");
    
    if (_layer != nullptr) {
      delete _layer;
    }
  } // End of destructor

  void ConfigRsuSimulatorPort::set_parameter(const char * parameter_name, const char * parameter_value)
  {
    loggers::get_instance().log("ConfigRsuSimulatorPort::set_parameter: %s=%s", parameter_name, parameter_value);
    _cfg_params.insert(std::pair<std::string, std::string>(std::string(parameter_name), std::string(parameter_value)));
  }

  /*void ConfigRsuSimulatorPort::Handle_Fd_Event(int fd, boolean is_readable,
    boolean is_writable, boolean is_error) {}*/

  void ConfigRsuSimulatorPort::Handle_Fd_Event_Error(int /*fd*/)
  {

  }

  void ConfigRsuSimulatorPort::Handle_Fd_Event_Writable(int /*fd*/)
  {

  }

  void ConfigRsuSimulatorPort::Handle_Fd_Event_Readable(int /*fd*/)
  {

  }

  /*void ConfigRsuSimulatorPort::Handle_Timeout(double time_since_last_call) {}*/

  void ConfigRsuSimulatorPort::user_map(const char * system_port)
  {
    loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_map: %s", system_port);
    // Build layer stack
    Params::iterator it = _cfg_params.find(std::string("params"));
    if (it != _cfg_params.end()) {
      loggers::get_instance().log("ConfigRsuSimulatorPort::user_map: %s", it->second.c_str());
      // Setup parameters
      Params::convert(_layer_params, it->second); // TODO This _layer_params seems to be useless
      // Create layer
      /*_layer = LayerStackBuilder::GetInstance()->createLayerStack(it->second.c_str());
      if (static_cast<ConfigRsuSimulatorLayer*>(_layer) == nullptr) {
	loggers::get_instance().error("ConfigRsuSimulatorPort::user_map: Invalid stack configuration: %s", it->second.c_str());
      }
      static_cast<ConfigRsuSimulatorLqyer*>(_layer)->addUpperPort(this);*/

    } else {
      loggers::get_instance().error("ConfigRsuSimulatorPort::user_map: No layers defined in configuration file");
    }
  } // End of user_map method
  
  void ConfigRsuSimulatorPort::user_unmap(const char * system_port)
  {
    loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_unmap: %s", system_port);

    // Reset layers
    if (_layer != nullptr) {
      delete _layer;
      _layer = nullptr;
    }
  } // End of user_unmap method

  void ConfigRsuSimulatorPort::user_start()
  {
    loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_start");

  } // End of user_start method

  void ConfigRsuSimulatorPort::user_stop()
  {
    loggers::get_instance().log(">>> ConfigRsuSimulatorPort::user_stop");

  } // End of user_stop method

  void ConfigRsuSimulatorPort::outgoing_send(const CfInitialize& send_par)
  {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
    /*float duration;
    loggers::get_instance().set_start_time(_time_key);
    Params params;
    static_cast<ConfigRsuSimulatorLayer *>(_layer)->sendMsg(send_par, params);
    loggers::get_instance().set_stop_time(_time_key, duration);*/
  }

  void ConfigRsuSimulatorPort::outgoing_send(const BOOLEAN& send_par)
  {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
  }
  
  void ConfigRsuSimulatorPort::outgoing_send(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par)
  {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::outgoing_send: payload=", send_par);
    
  }
  
  void ConfigRsuSimulatorPort::receiveMsg (const LibItsGeoNetworking__TypesAndValues::UtGnInitialize& p_ind, const Params& p_params) {
    loggers::get_instance().log_msg(">>> ConfigRsuSimulatorPort::receive_msg: ", p_ind);
    // Sanity check
    if (!p_ind.is_bound()) {
      return;
    }

    incoming_message(p_ind);
  }
  
} /* end of namespace */
+56 −0
Original line number Diff line number Diff line
#pragma once

#include "ItsRSUsSimulator_TestSystem.hh"

#include "Layer.hh"
#include "Params.hh"

namespace ItsRSUsSimulator__TestSystem {
  
  class ConfigRsuSimulatorPort : public ConfigRsuSimulatorPort_BASE {
    Params _cfg_params;
    Params _layer_params;
    Layer * _layer;
    std::string _time_key;
    
  public:
    ConfigRsuSimulatorPort(const char *par_port_name);
    ~ConfigRsuSimulatorPort();

    void set_parameter(const char *parameter_name, const char *parameter_value);
    void receiveMsg (const LibItsGeoNetworking__TypesAndValues::UtGnInitialize& p_ind, const Params& p_params);
  
    /*void send(const CfInitialize& send_par, const COMPONENT& destination_component);
    void send(const CfInitialize& send_par);
    void send(const CfInitialize_template& send_par, const COMPONENT& destination_component);
    void send(const CfInitialize_template& send_par);
    void send(const BOOLEAN& send_par, const COMPONENT& destination_component);
    void send(const BOOLEAN& send_par);
    void send(const BOOLEAN_template& send_par, const COMPONENT& destination_component);
    void send(const BOOLEAN_template& send_par);
    void send(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par, const COMPONENT& destination_component);
    void send(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par);
    void send(const LibItsGeoNetworking__TypesAndValues::UtGnResults_template& send_par, const COMPONENT& destination_component);
    void send(const LibItsGeoNetworking__TypesAndValues::UtGnResults_template& send_par);*/
  
  private:
    /* void Handle_Fd_Event(int fd, boolean is_readable,
       boolean is_writable, boolean is_error); */
    void Handle_Fd_Event_Error(int fd);
    void Handle_Fd_Event_Writable(int fd);
    void Handle_Fd_Event_Readable(int fd);
    /* void Handle_Timeout(double time_since_last_call); */

  protected:
    void user_map(const char *system_port);
    void user_unmap(const char *system_port);

    void user_start();
    void user_stop();

    void outgoing_send(const CfInitialize& send_par);
    void outgoing_send(const BOOLEAN& send_par);
    void outgoing_send(const LibItsGeoNetworking__TypesAndValues::UtGnResults& send_par);
  }; // End of class ConfigRsuSimulatorPort

}
+6 −3
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ LibItsGeoNetworking_Pics.PICS_GN_LOCAL_GN_ADDR := {
# GeoNetwoking only, no facility layer
#LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_any
# With facility layer
LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_btpA
LibItsGeoNetworking_Pixits.PX_GN_UPPER_LAYER := e_btpB

# Indicate which RSU to simulate
ItsRSUsSimulator_Pixits.PX_RSU_ID := 8;
@@ -113,10 +113,13 @@ LogEventTypes:= Yes
#     save_mode   : 1 to save sent packet, 0 otherwise

# Single GeoNetworking component port
system.geoNetworkingPort.params := "GN(ll_address=F8CAB8083918,latitude=43551050,longitude=10298730,beaconing=1,expiry=1000)/ETH(mac_src=0800275c4959,mac_bc=FFFFFFFFFFFF,eth_type=8947)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=and ether proto 0x8947)"
system.geoNetworkingPort.params := "GN(ll_address=F8CAB8083918,latitude=43551050,longitude=10298730,beaconing=0,device_mode=0,expiry=1000,secured_mode=1,certificate=CERT_TS_A,sec_db_path=/home/ubuntu/tmp/Yann)/ETH(mac_src=0800275c4959,mac_bc=FFFFFFFFFFFF,eth_type=8947)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=and ether proto 0x8947)"

# UpperTester port based on UDP
system.utPort.params := "UT/UDP(dst_ip=192.168.56.1,dst_port=12346,src_ip=192.168.156.4,src_port=12345)/ETH(mac_src=026f8338c1e5,mac_dst=0A0027000011,eth_type=0800)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=udp port 12346)"
#system.utPort.params := "UT/UDP(dst_ip=192.168.56.1,dst_port=12346,src_ip=192.168.156.4,src_port=12345)/ETH(mac_src=026f8338c1e5,mac_dst=0A0027000011,eth_type=0800)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=udp port 12346)"

# Config port based on UDP
system.cfPort.params := "CF/UDP(dst_ip=192.168.56.1,dst_port=12348,src_ip=192.168.156.4,src_port=12347)/ETH(mac_src=026f8338c1e5,mac_dst=0A0027000011,eth_type=0800)/PCAP(mac_src=0800275c4959,nic=enp0s8,filter=udp port 12348)"

[EXECUTE]
ItsRSUsSimulator_TestCases.TC_RSUSIMU_BV_01
+2 −2
Original line number Diff line number Diff line
@@ -104,7 +104,7 @@ module ItsRSUsSimulator_Functions {
            
            // Map
            map(self:acPort, system:acPort);
            //map(self:cfPort, system:cfPort);
            map(self:cfPort, system:cfPort);
            map(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Connect
@@ -132,7 +132,7 @@ module ItsRSUsSimulator_Functions {
            
            // Unmap
            unmap(self:acPort, system:acPort);
            //unmap(self:cfPort, system:cfPort);
            unmap(self:cfPort, system:cfPort);
            unmap(self:geoNetworkingPort, system:geoNetworkingPort);
            
            // Disconnect
+124 −122
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ module ItsRSUsSimulator_TestSystem {
    /**
     * @desc RSUsimulator configuration port
     */
        //port ConfigRsuSimulatorPort cfPort; 
    port ConfigRsuSimulatorPort cfPort; 
    /**
     * @desc RSU position
     */
@@ -103,7 +103,7 @@ module ItsRSUsSimulator_TestSystem {
     * @desc Test system component for ITS Network and Transport layer
     */
  type component ItsRSUsSimulatorSystem extends ItsGeoNetworkingSystem {
        //port ConfigRsuSimulatorPort cfPort; 
    port ConfigRsuSimulatorPort cfPort; 
  }
    
  type record of record {
@@ -113,9 +113,12 @@ module ItsRSUsSimulator_TestSystem {
    integer          detectionCounter
    } VehiclesSimulator;
    
    /*group configRsuSimulatorTypes {
  group configRsuSimulatorTypes {
        
        type record CfInitialize { };
    type record CfInitialize {
    } with {
      variant "FIELDORDER(msb)"
      }
        
    type charstring CfEvent;
        
@@ -127,20 +130,19 @@ module ItsRSUsSimulator_TestSystem {
                
  } with {
    variant ""
        encode "ConfigTester"
    }*/ // End of group configRsuSimulatorTypes 
  } // End of group configRsuSimulatorTypes 
    
  group configRsuSimulatorPort {
        
    /**
     * @desc Configuration RSUsimulator port
     */
        /*type port ConfigRsuSimulatorPort message {
    type port ConfigRsuSimulatorPort message {
      out 
                CfInitialize, CfResult; 
      CfInitialize, CfResult, UtGnResults; 
      in 
                CfEvent, CfEventInd
        }*/ // End of ConfigRsuSimulatorPort
      CfEvent, CfEventInd, UtGnInitialize
      } // End of ConfigRsuSimulatorPort
        
  } // End of group configRsuSimulatorPort