## 4 The Used Simulation Environment and Our Model Extensions
### Our Proposal: A Novel, CBR-Based Dynamic Channel Selection Model  
In the Middleware class of Artery, the initialization function was expanded with a new parser method to read the CBR threshold values from the XML file, and the whole channel-selection procedure was implemented here. A new _saPolicy_ data member was added to store the AID-channel pairs obtained from the SAM, and a channel load data member was obtained to store the current CBR. The real-time CBR value is processed in the _DccEntityBase_ class. A simple function was created to obtain the CBR value, which is normally stored in vectors. _SaService_ and _PaService_ were created to simulate SAM and PAM message types. Both were implemented according to _CaService_. In _SaService_, the basic channel information was stored statically. A new function was created to register advertisement information to the corresponding Middleware in the base class of all the service classes. When a SAM message is transmitted, in the _indicate_ function of the _SaService_, the SAM is parsed, and the advertisement information can be registered to the Middleware. Figure 1 shows the simplified structure of the abovementioned components of Artery. The green parts present newly created modules and functions. First, the MCO Policy XML file (_mcoPolicy.xml_) needs to be configured by specifying the Application ID (AID) of the applications we want to use and then the corresponding channel (Figure 2). Multiple channels can be assigned to a single AID, which allows the applications to switch channels at runtime because, from this file, they know they could use another channel as an alternative. After processing the XML file, the ID-channel number pairs are saved in the Middleware. In order to make the channel-change usage more modular, a Channel Change XML (_channelChange.xml_) data tag was created in the Middleware NED file. Here, we can provide an XML containing the ITS-AID of the service used in the simulation and the three corresponding CBR thresholds. The first CBR tag belongs to the primary CCH channel, the second to SCH1, and the third value to SCH2. This is processed like other XML files during the Middleware initialization and saved in _nDianmicMapping_, a newly created map type data member, which stores the specific AID and its related CBR values (Figure 3). Since the map type has approximately 40 bytes of overhead, a double typically requires 8 bytes, a vector has 24 bytes of overhead, and every element (which is a double) within it needs 8 bytes. Moreover, three AIDs with three CBR threshold values require around 288 bytes of memory to store them. <mco>  
<application id = \"146\" channel = \"180\" />  
<application id = \"146\" channel = \"178\" />  
<application id = \"146\" channel = \"176\" />  
<application id = \"39\" channel = \"180\" />  
<mco>  <application id = \"36\" cbr1 = \"0.6\" cbr2 = \"0.2\" cbr3 = \"0.8\" />  <application id = \"146\" cbr1 = \"0.6\" cbr2 = \"0.2\" cbr3 = \"0.8\" />  <application id = \"39\" cbr1 = \"0.6\" cbr2 = \"0.2\" cbr3 = \"0.8\" />  </mco>  
The dynamic channel-switching method was implemented in the Middleware. A new function was created called _dynamicChannel_, which selects the interface that satisfies the CBR constraints based on the _DataRequest_ parameter and then calls the request function of the associated Router class on this chosen interface to actually send the request. The _DataRequest_ parameter contains the most critical information about the transmission. It includes the destination and source ports and the GeoNet parameters. From the GeoNet data tag, ITS-AID data can be extracted, so the Middleware will know what kind of message it is. The Traffic Class field can also be found there. When _dynamicChannel_ is called, first, the ITS-AID is retrieved in the request parameter. Then, based on the given AID, it can select the channels to which this AID is assigned. After that, it sorts the resulting channels in order of priority. For the channel selection, the Middleware first looks at the DCC profile.