├── .gitignore ├── .idea └── .gitignore ├── CMakeLists.txt ├── INFO.yaml ├── LICENSE ├── README.md ├── doc └── oran-interface.rst ├── examples ├── CMakeLists.txt ├── e2sim-integration-example.cc ├── encode-decode-indication.cc ├── l3-rrc-example.cc ├── oran-interface-example.cc ├── ric-control-function-desc.cc ├── ric-indication-messages.cc └── test-wrappers.cc ├── helper ├── indication-message-helper.cc ├── indication-message-helper.h ├── lte-indication-message-helper.cc ├── lte-indication-message-helper.h ├── mmwave-indication-message-helper.cc ├── mmwave-indication-message-helper.h ├── oran-interface-helper.cc └── oran-interface-helper.h └── model ├── asn1c-types.cc ├── asn1c-types.h ├── function-description.cc ├── function-description.h ├── kpm-function-description.cc ├── kpm-function-description.h ├── kpm-indication.cc ├── kpm-indication.h ├── oran-interface.cc ├── oran-interface.h ├── ric-control-function-description.cc ├── ric-control-function-description.h ├── ric-control-message.cc └── ric-control-message.h /.gitignore: -------------------------------------------------------------------------------- 1 | .vscode/settings.json 2 | .vscode/c_cpp_properties.json 3 | build/** -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Datasource local storage ignored files 5 | /dataSources/ 6 | /dataSources.local.xml 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | check_include_file_cxx(stdint.h HAVE_STDINT_H) 2 | if(HAVE_STDINT_H) 3 | add_definitions(-DHAVE_STDINT_H) 4 | endif() 5 | 6 | set(examples_as_tests_sources) 7 | if(${ENABLE_EXAMPLES}) 8 | set(examples_as_tests_sources 9 | #test/oran-interface-examples-test-suite.cc 10 | ) 11 | endif() 12 | 13 | #include_directories(/usr/local/include/e2sim) 14 | #link_directories(/usr/local/lib) 15 | #link_libraries(e2sim) 16 | 17 | find_external_library(DEPENDENCY_NAME e2sim 18 | HEADER_NAME e2sim.hpp 19 | LIBRARY_NAME e2sim 20 | SEARCH_PATHS /usr/local/include/e2sim) 21 | 22 | if(!${e2sim_FOUND}) 23 | message(WARNING "e2sim is required by oran-interface and was not found" ) 24 | return () 25 | endif() 26 | 27 | include_directories(${e2sim_INCLUDE_DIRS}) 28 | message(STATUS "dirs found: ${e2sim_INCLUDE_DIRS}" ) 29 | message(STATUS "libraries found: ${e2sim_LIBRARIES}" ) 30 | 31 | build_lib( 32 | LIBNAME oran-interface 33 | SOURCE_FILES model/oran-interface.cc 34 | helper/oran-interface-helper.cc 35 | model/asn1c-types.cc 36 | model/function-description.cc 37 | model/kpm-indication.cc 38 | model/kpm-function-description.cc 39 | model/ric-control-message.cc 40 | model/ric-control-function-description.cc 41 | helper/oran-interface-helper.cc 42 | helper/indication-message-helper.cc 43 | helper/lte-indication-message-helper.cc 44 | helper/mmwave-indication-message-helper.cc 45 | HEADER_FILES model/oran-interface.h 46 | helper/oran-interface-helper.h 47 | model/asn1c-types.h 48 | model/function-description.h 49 | model/kpm-indication.h 50 | model/kpm-function-description.h 51 | model/ric-control-message.h 52 | model/ric-control-function-description.h 53 | helper/indication-message-helper.h 54 | helper/lte-indication-message-helper.h 55 | helper/mmwave-indication-message-helper.h 56 | LIBRARIES_TO_LINK 57 | ${libcore} 58 | ${e2sim_LIBRARIES} 59 | ) 60 | 61 | -------------------------------------------------------------------------------- /INFO.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | project: 'sim/ns3-o-ran-e2' 3 | project_creation_date: '2022-05-12' 4 | project_category: '' 5 | lifecycle_state: 'Incubation' 6 | project_lead: &sim_ptl 7 | name: 'Alex Stancu' 8 | email: 'alexandru.stancu@highstreet-technologies.com' 9 | id: 'alex.stancu' 10 | company: 'highstreet technologies GmbH' 11 | timezone: 'Europe/Bucharest' 12 | primary_contact: *sim_ptl 13 | issue_tracking: 14 | type: 'jira' 15 | url: 'https://jira.o-ran-sc.org/projects/SIM' 16 | key: 'SIM' 17 | mailing_list: 18 | type: 'groups.io' 19 | url: 'https://lists.o-ran-sc.org/g/main' 20 | tag: '<[sim]>' 21 | realtime_discussion: 22 | type: 'irc' 23 | server: 'freenode.net' 24 | channel: '#o-ran-sc' 25 | meetings: 26 | - type: 'zoom' 27 | agenda: '' 28 | url: '' 29 | server: 'n/a' 30 | channel: 'n/a' 31 | repeats: 'weekly' 32 | time: '' 33 | repositories: 34 | - 'sim/ns3-o-ran-e2' 35 | committers: 36 | - <<: *sim_ptl 37 | - name: 'Michele Polese' 38 | email: 'michele.polese@gmail.com' 39 | company: 'Northeastern University, Boston MA' 40 | id: 'mychele' 41 | timezone: 'America/New_York' 42 | - name: 'Andrea Lacava' 43 | email: 'lacava.a@northeastern.edu' 44 | company: 'Northeastern University, Boston MA' 45 | id: 'thecave3' 46 | timezone: 'America/New_York' 47 | - name: 'Tommaso Zugno' 48 | email: 'tommasozugno@gmail.com' 49 | company: 'University of Padova' 50 | id: 'tommasozugno' 51 | timezone: 'Europe/Rome' 52 | tsc: 53 | approval: "https://wiki.o-ran-sc.org/display/TOC#ORANSCTechnical\ 54 | OversightCommittee(TOC)-20220427" 55 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ns3-o-ran-e2 aka ns-O-RAN 2 | 3 | ================================ 4 | 5 | This ns-3 module enables the support for running multiple terminations of an O-RAN-compliant E2 interface inside the simulation process. 6 | This module has been developed by a team at the [Institute for the Wireless Internet of Things (WIoT)](https://wiot.northeastern.edu) at Northeastern University, in collaboration with Sapienza University of Rome, the University of Padova and with support from Mavenir. 7 | 8 | ## How to use 9 | 10 | This module can be used with an extension of the [ns3-mmWave module](https://github.com/wineslab/ns-o-ran-ns3-mmwave). 11 | This repository must be cloned in the `contrib` folder. 12 | Moreover, our custom version of the [e2sim library](https://github.com/wineslab/o-ran-e2sim) must be installed. 13 | Please refer to this [quick start guide](https://openrangym.com/tutorials/ns-o-ran) that presents a tutorial to bridge ns-O-RAN and Colosseum RIC (i.e., OSC RIC bronze reduced) ns-O-RAN. 14 | 15 | Additional material: 16 | 17 | - Framework presentation https://openrangym.com/ran-frameworks/ns-o-ran 18 | - Tutorial OSC RIC version E ns-O-RAN connection https://www.nsnam.org/tutorials/consortium23/oran-tutorial-slides-wns3-2023.pdf 19 | - Recording of the tutorial OSC RIC version E done at the WNS3 2023 https://vimeo.com/867704832 20 | - xApp repositories working with ns-O-RAN: 21 | - https://github.com/wineslab/ns-o-ran-scp-ric-app-kpimon 22 | - https://github.com/wineslab/ns-o-ran-xapp-rc 23 | - Gymnasium Environment wrapper for ns-O-RAN https://github.com/wineslab/ns-o-ran-gym-environment 24 | 25 | ## References 26 | 27 | More information can be found in the technical paper: 28 | 29 | > A. Lacava, M. Bordin, M. Polese, R. Sivaraj, T. Zugno, F. Cuomo, and T. Melodia. "ns-O-RAN: Simulating O-RAN 5G Systems in ns-3", Proceedings of the 2023 Workshop on ns-3 (2023), [DOI:10.1145/3592149.3592161](https://dl.acm.org/doi/abs/10.1145/3592149.3592161) 30 | 31 | If you use the scenario-one.cc or the traffic steering implementation please cite: 32 | 33 | >A. Lacava, M. Polese, R. Sivaraj, R. Soundrarajan, B. Bhati, T. Singh, T. Zugno, F. Cuomo, and T. Melodia. "Programmable and Customized Intelligence for Traffic Steering in 5G Networks Using Open RAN Architectures", IEEE Transactions on Mobile Computing (2024), [DOI:10.1109/TMC.2023.3266642](https://doi.org/10.1109/TMC.2023.3266642) [pdf](https://ieeexplore.ieee.org/document/10102369) [bibtex](https://ece.northeastern.edu/wineslab/wines_bibtex/andrea/LacavaAMC22.txt) 34 | 35 | ## Authors 36 | 37 | The ns3-o-ran-e2 module is the result of the development effort carried out by different people. The main contributors are: 38 | 39 | - Andrea Lacava, Northeastern University and Sapienza University of Rome 40 | - Michele Polese, Northeastern University 41 | - Tommaso Zugno, University of Padova 42 | - Rajarajan Sivaraj and team, Mavenir 43 | 44 | We welcome contributions through pull requests. 45 | -------------------------------------------------------------------------------- /doc/oran-interface.rst: -------------------------------------------------------------------------------- 1 | Example Module Documentation 2 | ---------------------------- 3 | 4 | .. include:: replace.txt 5 | .. highlight:: cpp 6 | 7 | .. heading hierarchy: 8 | ------------- Chapter 9 | ************* Section (#.#) 10 | ============= Subsection (#.#.#) 11 | ############# Paragraph (no number) 12 | 13 | This is a suggested outline for adding new module documentation to |ns3|. 14 | See ``src/click/doc/click.rst`` for an example. 15 | 16 | The introductory paragraph is for describing what this code is trying to 17 | model. 18 | 19 | For consistency (italicized formatting), please use |ns3| to refer to 20 | ns-3 in the documentation (and likewise, |ns2| for ns-2). These macros 21 | are defined in the file ``replace.txt``. 22 | 23 | Model Description 24 | ***************** 25 | 26 | The source code for the new module lives in the directory ``contrib/oran-interface``. 27 | 28 | Add here a basic description of what is being modeled. 29 | 30 | Design 31 | ====== 32 | 33 | Briefly describe the software design of the model and how it fits into 34 | the existing ns-3 architecture. 35 | 36 | Scope and Limitations 37 | ===================== 38 | 39 | What can the model do? What can it not do? Please use this section to 40 | describe the scope and limitations of the model. 41 | 42 | References 43 | ========== 44 | 45 | Add academic citations here, such as if you published a paper on this 46 | model, or if readers should read a particular specification or other work. 47 | 48 | Usage 49 | ***** 50 | 51 | This section is principally concerned with the usage of your model, using 52 | the public API. Focus first on most common usage patterns, then go 53 | into more advanced topics. 54 | 55 | Building New Module 56 | =================== 57 | 58 | Include this subsection only if there are special build instructions or 59 | platform limitations. 60 | 61 | Helpers 62 | ======= 63 | 64 | What helper API will users typically use? Describe it here. 65 | 66 | Attributes 67 | ========== 68 | 69 | What classes hold attributes, and what are the key ones worth mentioning? 70 | 71 | Output 72 | ====== 73 | 74 | What kind of data does the model generate? What are the key trace 75 | sources? What kind of logging output can be enabled? 76 | 77 | Advanced Usage 78 | ============== 79 | 80 | Go into further details (such as using the API outside of the helpers) 81 | in additional sections, as needed. 82 | 83 | Examples 84 | ======== 85 | 86 | What examples using this new code are available? Describe them here. 87 | 88 | Troubleshooting 89 | =============== 90 | 91 | Add any tips for avoiding pitfalls, etc. 92 | 93 | Validation 94 | ********** 95 | 96 | Describe how the model has been tested/validated. What tests run in the 97 | test suite? How much API and code is covered by the tests? Again, 98 | references to outside published work may help here. 99 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(examples 2 | e2sim-integration-example 3 | l3-rrc-example 4 | oran-interface-example 5 | encode-decode-indication 6 | ric-control-function-desc 7 | ric-indication-messages 8 | test-wrappers 9 | ) 10 | foreach( 11 | example 12 | ${examples} 13 | ) 14 | build_lib_example( 15 | NAME ${example} 16 | SOURCE_FILES ${example}.cc 17 | LIBRARIES_TO_LINK ${liboran-interface} 18 | ) 19 | endforeach() -------------------------------------------------------------------------------- /examples/e2sim-integration-example.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | 28 | extern "C" { 29 | // #include "OCUCP-PF-Container.h" 30 | #include "OCTET_STRING.h" 31 | #include "asn_application.h" 32 | // #include "E2SM-KPM-IndicationMessage.h" 33 | // #include "FQIPERSlicesPerPlmnListItem.h" 34 | // #include "E2SM-KPM-RANfunction-Description.h" 35 | // #include "E2SM-KPM-IndicationHeader-Format1.h" 36 | // #include "E2SM-KPM-IndicationHeader.h" 37 | // #include "Timestamp.h" 38 | #include "E2AP-PDU.h" 39 | #include "RICsubscriptionRequest.h" 40 | #include "RICsubscriptionResponse.h" 41 | #include "RICactionType.h" 42 | #include "ProtocolIE-Field.h" 43 | #include "ProtocolIE-SingleContainer.h" 44 | #include "InitiatingMessage.h" 45 | } 46 | 47 | #include "e2sim.hpp" 48 | 49 | using namespace ns3; 50 | 51 | int 52 | main (int argc, char *argv[]) 53 | { 54 | E2Sim e2sim; 55 | e2sim.run_loop (argc, argv); 56 | 57 | Simulator::Run (); 58 | Simulator::Destroy (); 59 | return 0; 60 | } 61 | -------------------------------------------------------------------------------- /examples/encode-decode-indication.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | #include 28 | #include 29 | #include 30 | #include "ProtocolIE-Field.h" 31 | #include "CellResourceReportListItem.h" 32 | #include "ServedPlmnPerCellListItem.h" 33 | #include "EPC-DU-PM-Container.h" 34 | #include "FGC-DU-PM-Container.h" 35 | #include "PerQCIReportListItem.h" 36 | 37 | using namespace ns3; 38 | NS_LOG_COMPONENT_DEFINE ("EncodeDecodeIndication"); 39 | 40 | std::string DecodeOctectString(OCTET_STRING_t* octetString){ 41 | int size = octetString->size; 42 | char out[size + 1]; 43 | std::memcpy (out, octetString->buf, size); 44 | out[size] = '\0'; 45 | 46 | return std::string (out); 47 | } 48 | 49 | void 50 | readPfDuContainer (ODU_PF_Container_t *oDU) 51 | { 52 | int count = oDU->cellResourceReportList.list.count; 53 | if (count <= 0) { 54 | NS_LOG_ERROR("[E2SM] received empty ODU list"); 55 | return; 56 | } 57 | 58 | for (int i = 0; i < count; i++) 59 | { 60 | CellResourceReportListItem_t *report = oDU->cellResourceReportList.list.array[i]; 61 | // NS_LOG_UNCOND ("CellResourceReportListItem " << i); 62 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_CellResourceReportListItem, report)); 63 | NS_LOG_UNCOND ("NRCGI"); 64 | NS_LOG_UNCOND ("Buf PlmNID: " << report->nRCGI.pLMN_Identity.buf); 65 | NS_LOG_UNCOND ("String PlmNID: " << std::string (DecodeOctectString(&report->nRCGI.pLMN_Identity))); 66 | 67 | // TODO Decode the report->nRCGI.nRCellIdentity to a std::string 68 | // It's a bitstring I don't know how to do it 69 | 70 | long ulTotalOfAvailablePRBs = *(report->ul_TotalofAvailablePRBs); 71 | long dlTotalOfAvailablePRBs = *(report->dl_TotalofAvailablePRBs); 72 | NS_LOG_UNCOND ("UL Total of Available PRBs: " << ulTotalOfAvailablePRBs); 73 | NS_LOG_UNCOND("DL Total of Available PRBs: " << dlTotalOfAvailablePRBs); 74 | 75 | for (int j = 0; j < report->servedPlmnPerCellList.list.count; j++) 76 | { 77 | ServedPlmnPerCellListItem_t *servedPlmnPerCell = report->servedPlmnPerCellList.list.array[j]; 78 | NS_LOG_UNCOND ("ServedPLMNPerCell " << j << " with PlmNID: " << DecodeOctectString(&servedPlmnPerCell->pLMN_Identity)); 79 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_ServedPlmnPerCellListItem, servedPlmnPerCell)); 80 | 81 | FGC_DU_PM_Container_t* fgcDuPmContainer = servedPlmnPerCell->du_PM_5GC; 82 | if (fgcDuPmContainer != NULL) 83 | { 84 | NS_LOG_UNCOND ("5GC DU PM Container"); 85 | NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_FGC_DU_PM_Container, fgcDuPmContainer)); 86 | } 87 | 88 | EPC_DU_PM_Container_t *epcDuPmContainer = servedPlmnPerCell->du_PM_EPC; 89 | if(epcDuPmContainer != NULL) 90 | { 91 | NS_LOG_UNCOND ("EPC DU PM Container"); 92 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_EPC_DU_PM_Container, epcDuPmContainer)); 93 | 94 | for (int z = 0; z < epcDuPmContainer->perQCIReportList_du.list.count; z++) 95 | { 96 | PerQCIReportListItem_t * perQCIReportItem = epcDuPmContainer->perQCIReportList_du.list.array[z]; 97 | long dlPrbUsage = *perQCIReportItem->dl_PRBUsage; 98 | long ulPrbUsage = *perQCIReportItem->ul_PRBUsage; 99 | long qci = perQCIReportItem->qci; 100 | 101 | NS_LOG_UNCOND ("QCI " << qci << ", dlPrbUsage: " << dlPrbUsage 102 | << ", ulPrbUsage: " << ulPrbUsage); 103 | } 104 | } 105 | 106 | } 107 | 108 | } 109 | } 110 | 111 | void 112 | readPfCuContainer (OCUCP_PF_Container_t *oCU_CP) 113 | { 114 | // Decode the values in container and create a variable for each decoded values and then print on screen with UNCOND 115 | NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_OCUCP_PF_Container, oCU_CP)); 116 | NS_LOG_UNCOND ("OCUCP_PF_Container_t"); 117 | long numActiveUes = *oCU_CP->cu_CP_Resource_Status.numberOfActive_UEs; 118 | NS_LOG_UNCOND (numActiveUes); 119 | } 120 | 121 | void 122 | readPfCuContainer (OCUUP_PF_Container_t *oCU_UP) 123 | { 124 | } 125 | 126 | void 127 | ProcessIndicationMessage (E2SM_KPM_IndicationMessage_t *indMsg) 128 | { 129 | if (indMsg->present == E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1) 130 | { 131 | NS_LOG_UNCOND ("Format 1 present\n"); 132 | 133 | E2SM_KPM_IndicationMessage_Format1_t *e2SmIndicationMessageFormat1 = indMsg->choice.indicationMessage_Format1; 134 | 135 | // extract RAN container, which is where we put our payload 136 | std::vector serving_cell_payload_vec; 137 | std::vector neighbor_cell_payload_vec; 138 | for (int i = 0; i < e2SmIndicationMessageFormat1->pm_Containers.list.count; i++){ 139 | PM_Containers_Item_t *pmContainer = e2SmIndicationMessageFormat1->pm_Containers.list.array[i]; 140 | // NS_LOG_UNCOND ("PM Container"); 141 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_PM_Containers_Item, pmContainer)); 142 | PF_Container_t *pfContainer = pmContainer->performanceContainer; 143 | switch (pfContainer->present) 144 | { 145 | case PF_Container_PR_NOTHING: 146 | NS_LOG_ERROR ("PF Container is empty"); 147 | break; 148 | case PF_Container_PR_oDU: 149 | // NS_LOG_UNCOND ("oDU PF Container"); 150 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_PF_Container, pfContainer)); 151 | readPfDuContainer (pfContainer->choice.oDU); 152 | break; 153 | case PF_Container_PR_oCU_CP: 154 | // NS_LOG_UNCOND ("oCU CP PF Container"); 155 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_PF_Container, pfContainer)); 156 | readPfCuContainer (pfContainer->choice.oCU_CP); 157 | break; 158 | 159 | case PF_Container_PR_oCU_UP: 160 | // NS_LOG_UNCOND ("oCU UP PF Container"); 161 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_PF_Container, pfContainer)); 162 | readPfCuContainer (pfContainer->choice.oCU_UP); 163 | break; 164 | 165 | default: 166 | NS_LOG_ERROR ("PF Container not supported"); 167 | break; 168 | } 169 | } 170 | 171 | // // combine content of vectors, there should be a single entry in the vector anyway 172 | // std::ostringstream serving_cell_payload_oss; 173 | // std::copy(serving_cell_payload_vec.begin(), serving_cell_payload_vec.end() - 1, std::ostream_iterator(serving_cell_payload_oss, ", ")); 174 | // serving_cell_payload_oss << serving_cell_payload_vec.back(); 175 | // std::string serving_cell_payload = serving_cell_payload_oss.str(); 176 | // 177 | // std::ostringstream neighbor_cell_payload_oss; 178 | // std::copy(neighbor_cell_payload_vec.begin(), neighbor_cell_payload_vec.end() - 1, std::ostream_iterator(neighbor_cell_payload_oss, ", ")); 179 | // neighbor_cell_payload_oss << neighbor_cell_payload_vec.back(); 180 | // std::string neighbor_cell_payload = neighbor_cell_payload_oss.str(); 181 | // 182 | // NS_LOG_UNCOND( "String conversion: serving_Cell_RF_Type %s, neighbor_Cell_RF: %s\n", serving_cell_payload.c_str(), neighbor_cell_payload.c_str()); 183 | // 184 | // // assemble final payload 185 | // if (serving_cell_payload.length() > 0 && neighbor_cell_payload.length() > 0) { 186 | // payload = serving_cell_payload + ", " + neighbor_cell_payload; 187 | // } 188 | // else if (serving_cell_payload.length() > 0 && neighbor_cell_payload.length() == 0) { 189 | // payload = serving_cell_payload; 190 | // } 191 | // else if (serving_cell_payload.length() == 0 && neighbor_cell_payload.length() > 0) { 192 | // payload = neighbor_cell_payload; 193 | // } 194 | // else { 195 | // payload = ""; 196 | // } 197 | // 198 | // NS_LOG_UNCOND( "Payload from RIC Indication message: %s\n", payload.c_str()); 199 | } 200 | else 201 | { 202 | NS_LOG_UNCOND ("No payload received in RIC Indication message (or was unable to decode " 203 | "received payload\n"); 204 | } 205 | // add_gnb_to_vector_unique(gnb_id); 206 | // 207 | // if (payload.length() > 0) { 208 | // // add gnb id to payload 209 | // payload += "\n{\"gnb_id\": \"" + std::string(reinterpret_cast(gnb_id)) + "\"}"; 210 | // 211 | // NS_LOG_UNCOND( "Sending RIC Indication message to agent\n"); 212 | // send_socket(payload.c_str()); 213 | // } 214 | // else if (payload.length() <= 0) { 215 | // NS_LOG_UNCOND( "Received empty payload\n"); 216 | // } 217 | // else { 218 | // NS_LOG_UNCOND( "Returned empty agent IP\n"); 219 | // } 220 | } 221 | 222 | void 223 | DecodeIndicationMessage (Ptr msg) 224 | { 225 | asn_dec_rval_t decode_result; 226 | E2SM_KPM_IndicationMessage_t *indMsg = 0; 227 | 228 | decode_result = aper_decode_complete (NULL, &asn_DEF_E2SM_KPM_IndicationMessage, 229 | (void **) &indMsg, msg->m_buffer, msg->m_size); 230 | 231 | if (decode_result.code == RC_OK) 232 | { 233 | NS_LOG_UNCOND ("Decode OKAY"); 234 | // NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_E2SM_KPM_IndicationMessage, indMsg)); 235 | ProcessIndicationMessage (indMsg); 236 | } 237 | else 238 | { 239 | ASN_STRUCT_FREE (asn_DEF_E2SM_KPM_IndicationMessage, indMsg); 240 | NS_LOG_UNCOND ("DECODE NOT OKAY"); 241 | } 242 | } 243 | 244 | /** 245 | * Create and encode RIC Indication messages. 246 | * Prints the encoded messages in XML format. 247 | */ 248 | 249 | int 250 | main (int argc, char *argv[]) 251 | { 252 | // LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 253 | LogComponentEnable ("KpmIndication", LOG_LEVEL_INFO); 254 | 255 | std::string plmId = "111"; 256 | std::string gnbId = "1"; 257 | uint16_t nrCellId = 5; 258 | 259 | uint64_t timestamp = 1630068655325; 260 | 261 | NS_LOG_UNCOND ("----------- Begin of Kpm Indication header -----------"); 262 | 263 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues; 264 | headerValues.m_plmId = plmId; 265 | headerValues.m_gnbId = gnbId; 266 | headerValues.m_nrCellId = nrCellId; 267 | headerValues.m_timestamp = timestamp; 268 | 269 | Ptr header = Create (KpmIndicationHeader::GlobalE2nodeType::eNB, headerValues); 270 | 271 | NS_LOG_UNCOND ("----------- End of the Kpm Indication header -----------"); 272 | 273 | NS_LOG_UNCOND ("----------- Start decode of Header -----------"); 274 | asn_dec_rval_t decode_header_result; 275 | E2SM_KPM_IndicationHeader_t *indHdr = 0; 276 | decode_header_result = aper_decode_complete(NULL, &asn_DEF_E2SM_KPM_IndicationHeader, (void **)&indHdr, header->m_buffer, 277 | header->m_size); 278 | if(decode_header_result.code == RC_OK) { 279 | NS_LOG_UNCOND ("Decode OKAY"); 280 | NS_LOG_UNCOND (xer_fprint (stderr, &asn_DEF_E2SM_KPM_IndicationHeader, indHdr)); 281 | } 282 | else { 283 | ASN_STRUCT_FREE(asn_DEF_E2SM_KPM_IndicationHeader, indHdr); 284 | NS_LOG_UNCOND ("DECODE NOT OKAY"); 285 | } 286 | NS_LOG_UNCOND ("----------- End test of decode header -----------"); 287 | 288 | 289 | NS_LOG_UNCOND ("----------- Begin test of the DU message -----------"); 290 | KpmIndicationMessage::KpmIndicationMessageValues msgValues3; 291 | msgValues3.m_cellObjectId = "NRCellCU"; 292 | 293 | Ptr oDuContainerVal = Create (); 294 | Ptr cellResRep = Create (); 295 | cellResRep->m_plmId = "111"; 296 | // std::stringstream ss; 297 | // ss << std::hex << 1340012; 298 | cellResRep->m_nrCellId = 2; 299 | cellResRep->dlAvailablePrbs = 6; 300 | cellResRep->ulAvailablePrbs = 6; 301 | 302 | Ptr cellResRep2 = Create (); 303 | cellResRep2->m_plmId = "444"; 304 | cellResRep2->m_nrCellId = 3; 305 | cellResRep2->dlAvailablePrbs = 5; 306 | cellResRep2->ulAvailablePrbs = 5; 307 | 308 | Ptr servedPlmnPerCell = Create (); 309 | servedPlmnPerCell->m_plmId = "121"; 310 | servedPlmnPerCell->m_nrCellId = 3; 311 | 312 | Ptr servedPlmnPerCell2 = Create (); 313 | servedPlmnPerCell2->m_plmId = "121"; 314 | servedPlmnPerCell2->m_nrCellId = 2; 315 | 316 | Ptr epcDuVal = Create (); 317 | epcDuVal->m_qci = 1; 318 | epcDuVal->m_dlPrbUsage = 1; 319 | epcDuVal->m_ulPrbUsage = 2; 320 | 321 | Ptr epcDuVal2 = Create (); 322 | epcDuVal2->m_qci = 1; 323 | epcDuVal2->m_dlPrbUsage = 3; 324 | epcDuVal2->m_ulPrbUsage = 4; 325 | 326 | servedPlmnPerCell->m_perQciReportItems.insert (epcDuVal); 327 | servedPlmnPerCell->m_perQciReportItems.insert (epcDuVal2); 328 | servedPlmnPerCell2->m_perQciReportItems.insert (epcDuVal); 329 | servedPlmnPerCell2->m_perQciReportItems.insert (epcDuVal2); 330 | cellResRep->m_servedPlmnPerCellItems.insert (servedPlmnPerCell2); 331 | cellResRep->m_servedPlmnPerCellItems.insert (servedPlmnPerCell); 332 | cellResRep2->m_servedPlmnPerCellItems.insert (servedPlmnPerCell2); 333 | cellResRep2->m_servedPlmnPerCellItems.insert (servedPlmnPerCell); 334 | 335 | oDuContainerVal->m_cellResourceReportItems.insert (cellResRep); 336 | oDuContainerVal->m_cellResourceReportItems.insert (cellResRep2); 337 | 338 | Ptr ue5DummyValues = Create ("UE-5"); 339 | ue5DummyValues->AddItem ("DRB.EstabSucc.5QI.UEID", 6); 340 | ue5DummyValues->AddItem ("DRB.RelActNbr.5QI.UEID", 7); 341 | msgValues3.m_ueIndications.insert (ue5DummyValues); 342 | 343 | msgValues3.m_pmContainerValues = oDuContainerVal; 344 | Ptr msg = Create (msgValues3); 345 | 346 | NS_LOG_UNCOND ("----------- End test of the DU message -----------"); 347 | 348 | NS_LOG_UNCOND ("----------- Start decode of DU message -----------"); 349 | DecodeIndicationMessage (msg); 350 | NS_LOG_UNCOND ("----------- End test of decode DU message -----------"); 351 | 352 | return 0; 353 | } 354 | -------------------------------------------------------------------------------- /examples/l3-rrc-example.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | 28 | using namespace ns3; 29 | 30 | NS_LOG_COMPONENT_DEFINE ("L3RrcExample"); 31 | 32 | Ptr 33 | CreateL3RrcUeSpecificSinrServing (long servingCellId, long physCellId, long sinr) 34 | { 35 | Ptr l3RrcMeasurement = Create (RRCEvent_b1); 36 | Ptr servingCellMeasurements = 37 | Create (ServingCellMeasurements_PR_nr_measResultServingMOList); 38 | 39 | Ptr measResultNr = Create (physCellId); 40 | Ptr measQuantityResultWrap = Create (); 41 | measQuantityResultWrap->AddSinr (sinr); 42 | measResultNr->AddCellResults (MeasResultNr::SSB, measQuantityResultWrap->GetPointer ()); 43 | Ptr measResultServMo = 44 | Create (servingCellId, measResultNr->GetValue ()); 45 | servingCellMeasurements->AddMeasResultServMo (measResultServMo->GetPointer ()); 46 | l3RrcMeasurement->AddServingCellMeasurement (servingCellMeasurements->GetPointer ()); 47 | return l3RrcMeasurement; 48 | } 49 | 50 | Ptr 51 | CreateL3RrcUeSpecificSinrNeigh (long neighCellId, long sinr) 52 | { 53 | Ptr l3RrcMeasurement = Create (RRCEvent_b1); 54 | Ptr measResultNr = Create (neighCellId); 55 | Ptr measQuantityResultWrap = Create (); 56 | measQuantityResultWrap->AddSinr (sinr); 57 | measResultNr->AddCellResults (MeasResultNr::SSB, measQuantityResultWrap->GetPointer ()); 58 | 59 | l3RrcMeasurement->AddMeasResultNRNeighCells ( 60 | measResultNr->GetPointer ()); // MAX 8 UE per message (standard) 61 | 62 | return l3RrcMeasurement; 63 | } 64 | 65 | 66 | // The memory leaks occurring in this file are wanted because L3-RRC is usually freed after use in the Ric Indication Message 67 | 68 | int 69 | main (int argc, char *argv[]) 70 | { 71 | LogComponentEnableAll (LOG_PREFIX_ALL); 72 | LogComponentEnable ("L3RrcExample", LOG_LEVEL_ALL); 73 | LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 74 | 75 | // 1 UE-specific (L3) SINR from NR serving cells 76 | NS_LOG_INFO ("1 UE-specific (L3) SINR from NR serving cells"); 77 | Ptr l3RrcMeasurement1 = CreateL3RrcUeSpecificSinrServing (1, 1, 10); 78 | xer_fprint (stderr, &asn_DEF_L3_RRC_Measurements, l3RrcMeasurement1->GetPointer ()); 79 | 80 | // 2 UE-specific (L3) SINR from NR neighboring cells 81 | NS_LOG_INFO ("2 UE-specific (L3) SINR from NR neighboring cells"); 82 | Ptr l3RrcMeasurement2 = CreateL3RrcUeSpecificSinrNeigh (2, 20); 83 | 84 | // 3 UE-specific (L3) SINR report from NR neighboring cells 85 | NS_LOG_INFO ("3 UE-specific (L3) SINR report from NR neighboring cells"); 86 | long neighCellId3 = 3; 87 | long sinr3 = 30; 88 | 89 | Ptr measResultNr3 = Create (neighCellId3); 90 | Ptr measQuantityResultWrap3 = Create (); 91 | measQuantityResultWrap3->AddSinr (sinr3); 92 | measResultNr3->AddCellResults (MeasResultNr::SSB, measQuantityResultWrap3->GetPointer ()); 93 | 94 | l3RrcMeasurement2->AddMeasResultNRNeighCells (measResultNr3->GetPointer ()); 95 | 96 | xer_fprint (stderr, &asn_DEF_L3_RRC_Measurements, l3RrcMeasurement2->GetPointer ()); 97 | 98 | // 4 UE-specific (L3) SINR from LTE serving cells 99 | NS_LOG_INFO ("4 UE-specific (L3) SINR from LTE serving cells"); 100 | long eutraPhysCellId4 = 4; 101 | long servCellId4 = 4; 102 | long sinr4 = 40; 103 | Ptr l3RrcMeasurement4 = 104 | CreateL3RrcUeSpecificSinrServing (servCellId4, eutraPhysCellId4, sinr4); 105 | xer_fprint (stderr, &asn_DEF_L3_RRC_Measurements, l3RrcMeasurement4->GetPointer ()); 106 | 107 | 108 | // 5 UE-specific (L3) SINR from LTE neighboring cells 109 | NS_LOG_INFO ("5 UE-specific (L3) SINR from LTE neighboring cells"); 110 | long neighCellId5 = 5; 111 | long sinr5 = 50; 112 | Ptr l3RrcMeasurement3 = Create (RRCEvent_a5); 113 | Ptr measResultEutra5 = Create (neighCellId5); 114 | measResultEutra5->AddSinr (sinr5); 115 | l3RrcMeasurement3->AddMeasResultEUTRANeighCells (measResultEutra5->GetPointer ()); 116 | xer_fprint (stderr, &asn_DEF_L3_RRC_Measurements, l3RrcMeasurement3->GetPointer ()); 117 | 118 | 119 | return 0; 120 | } 121 | -------------------------------------------------------------------------------- /examples/oran-interface-example.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | #include "encode_e2apv1.hpp" 28 | #include 29 | 30 | 31 | using namespace ns3; 32 | 33 | Ptr e2Term; 34 | // TODO create getters for these parameters in e2Term 35 | std::string plmId = "111"; 36 | uint16_t cellId = 1; 37 | const std::string gnb = std::to_string (cellId); 38 | 39 | /** 40 | * Creates an empty RIC Report message and send it to the RIC 41 | * 42 | * \param params the RIC Subscription Request parameters 43 | */ 44 | static void BuildAndSendReportMessage (E2Termination::RicSubscriptionRequest_rval_s params) 45 | { 46 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues; 47 | headerValues.m_plmId = plmId; 48 | headerValues.m_gnbId = cellId; 49 | headerValues.m_nrCellId = cellId; 50 | 51 | Ptr header = Create (KpmIndicationHeader::GlobalE2nodeType::gNB, headerValues); 52 | 53 | KpmIndicationMessage::KpmIndicationMessageValues msgValues; 54 | 55 | Ptr cuUpValues = Create (); 56 | cuUpValues->m_plmId = plmId; 57 | cuUpValues->m_pDCPBytesUL = 100; 58 | cuUpValues->m_pDCPBytesDL = 100; 59 | msgValues.m_pmContainerValues = cuUpValues; 60 | 61 | Ptr ue0DummyValues = Create ("UE-0"); 62 | ue0DummyValues->AddItem ("DRB.PdcpSduVolumeDl_Filter.UEID", 6); 63 | ue0DummyValues->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", 7); 64 | ue0DummyValues->AddItem ("Tot.PdcpSduNbrDl.UEID", 8); 65 | ue0DummyValues->AddItem ("DRB.PdcpPduNbrDl.Qos.UEID", 9); 66 | ue0DummyValues->AddItem ("DRB.IPThpDl.UEID", 10.0); 67 | ue0DummyValues->AddItem ("DRB.IPLateDl.UEID", 11.0); 68 | msgValues.m_ueIndications.insert (ue0DummyValues); 69 | 70 | Ptr ue1DummyValues = Create ("UE-1");; 71 | ue1DummyValues->AddItem ("DRB.PdcpSduVolumeDl_Filter.UEID", 6); 72 | ue1DummyValues->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", 7); 73 | ue1DummyValues->AddItem ("Tot.PdcpSduNbrDl.UEID", 8); 74 | ue1DummyValues->AddItem ("DRB.PdcpPduNbrDl.Qos.UEID", 9); 75 | ue1DummyValues->AddItem ("DRB.IPThpDl.UEID", 10.0); 76 | ue1DummyValues->AddItem ("DRB.IPLateDl.UEID", 11.0); 77 | msgValues.m_ueIndications.insert (ue1DummyValues); 78 | 79 | Ptr msg = Create (msgValues); 80 | 81 | E2AP_PDU *pdu_cuup_ue = new E2AP_PDU; 82 | encoding::generate_e2apv1_indication_request_parameterized(pdu_cuup_ue, 83 | params.requestorId, 84 | params.instanceId, 85 | params.ranFuncionId, 86 | params.actionId, 87 | 1, // TODO sequence number 88 | (uint8_t*) header->m_buffer, // buffer containing the encoded header 89 | header->m_size, // size of the encoded header 90 | (uint8_t*) msg->m_buffer, // buffer containing the encoded message 91 | msg->m_size); // size of the encoded message 92 | e2Term->SendE2Message (pdu_cuup_ue); 93 | delete pdu_cuup_ue; 94 | 95 | } 96 | 97 | /** 98 | * KPM Subscription Request callback. 99 | * This function is triggered whenever a RIC Subscription Request for 100 | * the KPM RAN Function is received. 101 | * 102 | * \param pdu request message 103 | */ 104 | static void KpmSubscriptionCallback (E2AP_PDU_t* sub_req_pdu) 105 | { 106 | NS_LOG_UNCOND ("\n\nReceived RIC Subscription Request"); 107 | 108 | E2Termination::RicSubscriptionRequest_rval_s params = e2Term->ProcessRicSubscriptionRequest (sub_req_pdu); 109 | NS_LOG_UNCOND ("requestorId " << +params.requestorId << 110 | ", instanceId " << +params.instanceId << 111 | ", ranFuncionId " << +params.ranFuncionId << 112 | ", actionId " << +params.actionId); 113 | 114 | BuildAndSendReportMessage (params); 115 | } 116 | 117 | /** 118 | * RIC Control Message callback. 119 | * This function is triggered whenever a RIC Control Message is received. 120 | * 121 | * \param pdu request message 122 | */ 123 | static void 124 | RicControlMessageCallback (E2AP_PDU_t *ric_ctrl_pdu) 125 | { 126 | NS_LOG_UNCOND ("\n\nReceived RIC Control Message"); 127 | 128 | RicControlMessage msg = RicControlMessage (ric_ctrl_pdu); 129 | // TODO log something 130 | } 131 | 132 | 133 | int 134 | main (int argc, char *argv[]) 135 | { 136 | LogComponentEnable ("E2Termination", LOG_LEVEL_ALL); 137 | // LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 138 | // LogComponentEnable ("RicControlMessage", LOG_LEVEL_ALL); 139 | e2Term = CreateObject ("10.0.2.10", 36422, 38472, gnb, plmId); 140 | e2Term->Start (); 141 | bool use = true; 142 | if (use){ 143 | 144 | Ptr kpmFd = Create (); 145 | e2Term->RegisterKpmCallbackToE2Sm (200, kpmFd, &KpmSubscriptionCallback); 146 | Ptr rcFd = Create (); 147 | e2Term->RegisterSmCallbackToE2Sm (300, rcFd, &RicControlMessageCallback); 148 | 149 | E2Termination::RicSubscriptionRequest_rval_s params; 150 | params.actionId = 0; 151 | params.instanceId = 1; 152 | params.ranFuncionId = 2; 153 | params.requestorId = 1; 154 | BuildAndSendReportMessage (params); 155 | } 156 | 157 | return 0; 158 | } 159 | -------------------------------------------------------------------------------- /examples/ric-control-function-desc.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | 28 | using namespace ns3; 29 | 30 | 31 | 32 | int 33 | main (int argc, char *argv[]) 34 | { 35 | LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 36 | LogComponentEnable ("RicControlMessage", LOG_LEVEL_ALL); 37 | Ptr rcFd = Create (); 38 | 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /examples/ric-indication-messages.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | #include 28 | 29 | using namespace ns3; 30 | 31 | /** 32 | * Create and encode RIC Indication messages. 33 | * Prints the encoded messages in XML format. 34 | */ 35 | int 36 | main (int argc, char *argv[]) 37 | { 38 | // LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 39 | LogComponentEnable ("KpmIndication", LOG_LEVEL_INFO); 40 | LogComponentEnable ("KpmFunctionDescription", LOG_LEVEL_INFO); 41 | 42 | std::string plmId = "111"; 43 | std::string gnbId = "1"; 44 | uint16_t nrCellId = 5; 45 | 46 | uint64_t timestamp = 1630068655325; 47 | // "12:58:04.123456"; 48 | uint64_t timestamp2 = 1630068679511; 49 | // "12:58:05.123457"; 50 | uint64_t timestamp3 = 1630068680196; 51 | // "12:58:06.123458"; 52 | uint64_t timestamp4 = 1630068681372; 53 | // "12:58:07.123459"; 54 | 55 | NS_LOG_UNCOND ("----------- Begin of Kpm Indication header -----------"); 56 | 57 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues; 58 | headerValues.m_plmId = plmId; 59 | headerValues.m_gnbId = gnbId; 60 | headerValues.m_nrCellId = nrCellId; 61 | headerValues.m_timestamp = timestamp; 62 | 63 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues2; 64 | headerValues2.m_plmId = plmId; 65 | headerValues2.m_gnbId = gnbId; 66 | headerValues2.m_nrCellId = nrCellId; 67 | headerValues2.m_timestamp = timestamp2; 68 | 69 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues3; 70 | headerValues3.m_plmId = plmId; 71 | headerValues3.m_gnbId = gnbId; 72 | headerValues3.m_nrCellId = nrCellId; 73 | headerValues3.m_timestamp = timestamp3; 74 | 75 | KpmIndicationHeader::KpmRicIndicationHeaderValues headerValues4; 76 | headerValues4.m_plmId = plmId; 77 | headerValues4.m_gnbId = gnbId; 78 | headerValues4.m_nrCellId = nrCellId; 79 | headerValues4.m_timestamp = timestamp4; 80 | 81 | Ptr header = Create (KpmIndicationHeader::GlobalE2nodeType::eNB, headerValues); 82 | Ptr header2 = Create (KpmIndicationHeader::GlobalE2nodeType::gNB, headerValues2); 83 | Ptr header3 = Create (KpmIndicationHeader::GlobalE2nodeType::ng_eNB, headerValues3); 84 | Ptr header4 = Create (KpmIndicationHeader::GlobalE2nodeType::en_gNB, headerValues4); 85 | 86 | NS_LOG_UNCOND ("----------- End of the Kpm Indication header -----------"); 87 | 88 | KpmIndicationMessage::KpmIndicationMessageValues msgValues1; 89 | 90 | NS_LOG_UNCOND ("----------- Begin of the CU-UP message -----------"); 91 | 92 | // Begin example CU-UP 93 | // uncomment this to test CU-UP 94 | 95 | Ptr cuUpValues = Create (); 96 | cuUpValues->m_plmId = plmId; 97 | cuUpValues->m_pDCPBytesUL = 100; 98 | cuUpValues->m_pDCPBytesDL = 100; 99 | 100 | Ptr ue0DummyValues = Create ("UE-0"); 101 | ue0DummyValues->AddItem ("DRB.PdcpSduVolumeDl_Filter.UEID", 6); 102 | ue0DummyValues->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", 7); 103 | ue0DummyValues->AddItem ("Tot.PdcpSduNbrDl.UEID", 8); 104 | ue0DummyValues->AddItem ("DRB.PdcpPduNbrDl.Qos.UEID", 9); 105 | ue0DummyValues->AddItem ("DRB.IPThpDl.UEID", 10.0); 106 | ue0DummyValues->AddItem ("DRB.IPLateDl.UEID", 11.0); 107 | msgValues1.m_ueIndications.insert (ue0DummyValues); 108 | 109 | Ptr ue1DummyValues = Create ("UE-1"); 110 | ue1DummyValues->AddItem ("DRB.PdcpSduVolumeDl_Filter.UEID", 6); 111 | ue1DummyValues->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", 7); 112 | ue1DummyValues->AddItem ("Tot.PdcpSduNbrDl.UEID", 8); 113 | ue1DummyValues->AddItem ("DRB.PdcpPduNbrDl.Qos.UEID", 9); 114 | ue1DummyValues->AddItem ("DRB.IPThpDl.UEID", 10.0); 115 | ue1DummyValues->AddItem ("DRB.IPLateDl.UEID", 11.0); 116 | msgValues1.m_ueIndications.insert(ue1DummyValues); 117 | msgValues1.m_pmContainerValues = cuUpValues; 118 | 119 | Ptr msg = Create (msgValues1); 120 | 121 | NS_LOG_UNCOND ("----------- End of the CU-UP message -----------"); 122 | 123 | NS_LOG_UNCOND ("----------- Begin of the CU-CP message -----------"); 124 | KpmIndicationMessage::KpmIndicationMessageValues msgValues2; 125 | msgValues2.m_cellObjectId = "NRCellCU"; 126 | Ptr cuCpValues = Create (); 127 | cuCpValues->m_numActiveUes = 100; 128 | 129 | Ptr ue2DummyValues = 130 | Create ("UE-2"); 131 | ue2DummyValues->AddItem ("DRB.EstabSucc.5QI.UEID", 6); 132 | ue2DummyValues->AddItem ("DRB.RelActNbr.5QI.UEID", 7); 133 | msgValues2.m_ueIndications.insert (ue2DummyValues); 134 | 135 | Ptr ue3DummyValues = 136 | Create ("UE-3"); 137 | ue3DummyValues->AddItem ("DRB.EstabSucc.5QI.UEID", 6); 138 | ue3DummyValues->AddItem ("DRB.RelActNbr.5QI.UEID", 7); 139 | msgValues2.m_ueIndications.insert (ue3DummyValues); 140 | 141 | Ptr ue4DummyValues = 142 | Create ("UE-4"); 143 | 144 | Ptr l3RrcMeasurement = Create (RRCEvent_b1); 145 | Ptr servingCellMeasurements = 146 | Create (ServingCellMeasurements_PR_nr_measResultServingMOList); 147 | 148 | Ptr measResultNr = Create (39); 149 | Ptr measQuantityResultWrap = Create (); 150 | measQuantityResultWrap->AddSinr (20); 151 | measResultNr->AddCellResults (MeasResultNr::SSB, measQuantityResultWrap->GetPointer ()); 152 | Ptr measResultServMo = 153 | Create (10, measResultNr->GetValue ()); 154 | servingCellMeasurements->AddMeasResultServMo (measResultServMo->GetPointer ()); 155 | l3RrcMeasurement->AddServingCellMeasurement (servingCellMeasurements->GetPointer ()); 156 | 157 | ue4DummyValues->AddItem> ("calla",l3RrcMeasurement); 158 | ue4DummyValues->AddItem ("DRB.RelActNbr.5QI.UEID", 7); 159 | msgValues2.m_ueIndications.insert (ue4DummyValues); 160 | msgValues2.m_pmContainerValues = cuCpValues; 161 | 162 | Ptr msg2 = Create (msgValues2); 163 | NS_LOG_UNCOND ("----------- End of the CU-CP message -----------"); 164 | 165 | NS_LOG_UNCOND ("----------- Begin test of the DU message -----------"); 166 | KpmIndicationMessage::KpmIndicationMessageValues msgValues3; 167 | msgValues3.m_cellObjectId = "NRCellCU"; 168 | 169 | Ptr oDuContainerVal = Create (); 170 | Ptr cellResRep = Create (); 171 | cellResRep->m_plmId = "111"; 172 | // std::stringstream ss; 173 | // ss << std::hex << 1340012; 174 | cellResRep->m_nrCellId = 2; 175 | cellResRep->dlAvailablePrbs = 6; 176 | cellResRep->ulAvailablePrbs = 6; 177 | 178 | Ptr cellResRep2 = Create (); 179 | cellResRep2->m_plmId = "444"; 180 | cellResRep2->m_nrCellId = 3; 181 | cellResRep2->dlAvailablePrbs = 5; 182 | cellResRep2->ulAvailablePrbs = 5; 183 | 184 | Ptr servedPlmnPerCell = Create (); 185 | servedPlmnPerCell->m_plmId = "121"; 186 | servedPlmnPerCell->m_nrCellId = 3; 187 | 188 | Ptr servedPlmnPerCell2 = Create (); 189 | servedPlmnPerCell2->m_plmId = "121"; 190 | servedPlmnPerCell2->m_nrCellId = 2; 191 | 192 | Ptr epcDuVal = Create (); 193 | epcDuVal->m_qci = 1; 194 | epcDuVal->m_dlPrbUsage = 1; 195 | epcDuVal->m_ulPrbUsage = 2; 196 | 197 | Ptr epcDuVal2 = Create (); 198 | epcDuVal2->m_qci = 1; 199 | epcDuVal2->m_dlPrbUsage = 3; 200 | epcDuVal2->m_ulPrbUsage = 4; 201 | 202 | servedPlmnPerCell->m_perQciReportItems.insert (epcDuVal); 203 | servedPlmnPerCell->m_perQciReportItems.insert (epcDuVal2); 204 | servedPlmnPerCell2->m_perQciReportItems.insert (epcDuVal); 205 | servedPlmnPerCell2->m_perQciReportItems.insert (epcDuVal2); 206 | cellResRep->m_servedPlmnPerCellItems.insert (servedPlmnPerCell2); 207 | cellResRep->m_servedPlmnPerCellItems.insert (servedPlmnPerCell); 208 | cellResRep2->m_servedPlmnPerCellItems.insert (servedPlmnPerCell2); 209 | cellResRep2->m_servedPlmnPerCellItems.insert (servedPlmnPerCell); 210 | 211 | oDuContainerVal->m_cellResourceReportItems.insert (cellResRep); 212 | oDuContainerVal->m_cellResourceReportItems.insert (cellResRep2); 213 | 214 | Ptr ue5DummyValues = Create ("UE-5"); 215 | ue5DummyValues->AddItem ("DRB.EstabSucc.5QI.UEID", 6); 216 | ue5DummyValues->AddItem ("DRB.RelActNbr.5QI.UEID", 7); 217 | msgValues3.m_ueIndications.insert (ue5DummyValues); 218 | 219 | msgValues3.m_pmContainerValues = oDuContainerVal; 220 | Ptr msg3 = Create (msgValues3); 221 | 222 | NS_LOG_UNCOND ("----------- End test of the DU message -----------"); 223 | 224 | NS_LOG_UNCOND ("----------- Begin test of the KpmFunctionDescription -----------"); 225 | Ptr fd = Create (); 226 | NS_LOG_UNCOND ("----------- End test of the KpmFunctionDescription -----------"); 227 | 228 | return 0; 229 | } 230 | -------------------------------------------------------------------------------- /examples/test-wrappers.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "ns3/core-module.h" 26 | #include "ns3/oran-interface.h" 27 | #include 28 | 29 | using namespace ns3; 30 | 31 | /** 32 | * Test field for the wrappers and their functions 33 | */ 34 | int 35 | main (int argc, char *argv[]) 36 | { 37 | // LogComponentEnable ("Asn1Types", LOG_LEVEL_ALL); 38 | std::string test = "test"; 39 | // Ptr one = Create (test, test.size ()); 40 | // Ptr due = Create (test, test.size ()); 41 | // Ptr snssai = Create ("test"); 42 | 43 | // std::cout << due->DecodeContent() << std::endl; 44 | 45 | std::vector> nrCellIds; 46 | for (uint16_t i = 0; i < 20; i++) 47 | { 48 | nrCellIds.push_back(Create (i)); 49 | NS_LOG_UNCOND ("Count: " << i << " , value: "); 50 | xer_fprint (stdout, &asn_DEF_BIT_STRING, nrCellIds[i]->GetPointer ()); 51 | } 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /helper/indication-message-helper.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | 27 | namespace ns3 { 28 | 29 | IndicationMessageHelper::IndicationMessageHelper (IndicationMessageType type, bool isOffline, 30 | bool reducedPmValues) 31 | : m_type (type), m_offline (isOffline), m_reducedPmValues (reducedPmValues) 32 | { 33 | 34 | if (!m_offline) 35 | { 36 | switch (type) 37 | { 38 | case IndicationMessageType::CuUp: 39 | m_cuUpValues = Create (); 40 | break; 41 | 42 | case IndicationMessageType::CuCp: 43 | m_cuCpValues = Create (); 44 | m_msgValues.m_cellObjectId = "NRCellCU"; 45 | break; 46 | 47 | case IndicationMessageType::Du: 48 | m_duValues = Create (); 49 | break; 50 | 51 | default: 52 | 53 | break; 54 | } 55 | } 56 | } 57 | 58 | void 59 | IndicationMessageHelper::FillBaseCuUpValues (std::string plmId) 60 | { 61 | NS_ABORT_MSG_IF (m_type != IndicationMessageType::CuUp, "Wrong function for this object"); 62 | m_cuUpValues->m_plmId = plmId; 63 | m_msgValues.m_pmContainerValues = m_cuUpValues; 64 | } 65 | 66 | void 67 | IndicationMessageHelper::FillBaseCuCpValues (uint16_t numActiveUes) 68 | { 69 | NS_ABORT_MSG_IF (m_type != IndicationMessageType::CuCp, "Wrong function for this object"); 70 | m_cuCpValues->m_numActiveUes = numActiveUes; 71 | m_msgValues.m_pmContainerValues = m_cuCpValues; 72 | } 73 | 74 | IndicationMessageHelper::~IndicationMessageHelper () 75 | { 76 | } 77 | 78 | Ptr 79 | IndicationMessageHelper::CreateIndicationMessage () 80 | { 81 | return Create (m_msgValues); 82 | } 83 | 84 | } // namespace ns3 -------------------------------------------------------------------------------- /helper/indication-message-helper.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef INDICATION_MESSAGE_HELPER_H 26 | #define INDICATION_MESSAGE_HELPER_H 27 | 28 | #include 29 | 30 | namespace ns3 { 31 | 32 | class IndicationMessageHelper : public Object 33 | { 34 | public: 35 | enum class IndicationMessageType { CuCp = 0, CuUp = 1, Du = 2 }; 36 | IndicationMessageHelper (IndicationMessageType type, bool isOffline, bool reducedPmValues); 37 | 38 | ~IndicationMessageHelper (); 39 | 40 | Ptr CreateIndicationMessage (); 41 | 42 | bool const & 43 | IsOffline () const 44 | { 45 | return m_offline; 46 | } 47 | 48 | protected: 49 | void FillBaseCuUpValues (std::string plmId); 50 | 51 | void FillBaseCuCpValues (uint16_t numActiveUes); 52 | 53 | IndicationMessageType m_type; 54 | bool m_offline; 55 | bool m_reducedPmValues; 56 | KpmIndicationMessage::KpmIndicationMessageValues m_msgValues; 57 | Ptr m_cuUpValues; 58 | Ptr m_cuCpValues; 59 | Ptr m_duValues; 60 | }; 61 | 62 | } // namespace ns3 63 | 64 | #endif /* INDICATION_MESSAGE_HELPER_H */ -------------------------------------------------------------------------------- /helper/lte-indication-message-helper.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | 26 | #include 27 | 28 | namespace ns3 { 29 | 30 | LteIndicationMessageHelper::LteIndicationMessageHelper (IndicationMessageType type, bool isOffline, 31 | bool reducedPmValues) 32 | : IndicationMessageHelper (type, isOffline, reducedPmValues) 33 | { 34 | NS_ABORT_MSG_IF (type == IndicationMessageType::Du, 35 | "Wrong type for LTE Indication Message, expected CuUp or CuCp"); 36 | } 37 | 38 | void 39 | LteIndicationMessageHelper::AddCuUpUePmItem (std::string ueImsiComplete, long txBytes, 40 | long txDlPackets, double pdcpThroughput, 41 | double pdcpLatency) 42 | { 43 | Ptr ueVal = Create (ueImsiComplete); 44 | 45 | if (!m_reducedPmValues) 46 | { 47 | // UE-specific PDCP SDU volume from LTE eNB. Unit is Mbits 48 | ueVal->AddItem ("DRB.PdcpSduVolumeDl_Filter.UEID", txBytes); 49 | 50 | // UE-specific number of PDCP SDUs from LTE eNB 51 | ueVal->AddItem ("Tot.PdcpSduNbrDl.UEID", txDlPackets); 52 | 53 | // UE-specific Downlink IP combined EN-DC throughput from LTE eNB. Unit is kbps 54 | ueVal->AddItem ("DRB.PdcpSduBitRateDl.UEID", pdcpThroughput); 55 | 56 | //UE-specific Downlink IP combined EN-DC throughput from LTE eNB 57 | ueVal->AddItem ("DRB.PdcpSduDelayDl.UEID", pdcpLatency); 58 | } 59 | 60 | m_msgValues.m_ueIndications.insert (ueVal); 61 | } 62 | 63 | void 64 | LteIndicationMessageHelper::AddCuUpCellPmItem (double cellAverageLatency) 65 | { 66 | if (!m_reducedPmValues) 67 | { 68 | Ptr cellVal = Create (); 69 | cellVal->AddItem ("DRB.PdcpSduDelayDl", cellAverageLatency); 70 | m_msgValues.m_cellMeasurementItems = cellVal; 71 | } 72 | } 73 | 74 | void 75 | LteIndicationMessageHelper::FillCuUpValues (std::string plmId, long pdcpBytesUl, long pdcpBytesDl) 76 | { 77 | m_cuUpValues->m_pDCPBytesUL = pdcpBytesUl; 78 | m_cuUpValues->m_pDCPBytesDL = pdcpBytesDl; 79 | FillBaseCuUpValues (plmId); 80 | } 81 | 82 | void 83 | LteIndicationMessageHelper::FillCuCpValues (uint16_t numActiveUes) 84 | { 85 | FillBaseCuCpValues (numActiveUes); 86 | } 87 | 88 | void 89 | LteIndicationMessageHelper::AddCuCpUePmItem (std::string ueImsiComplete, long numDrb, 90 | long drbRelAct) 91 | { 92 | 93 | Ptr ueVal = Create (ueImsiComplete); 94 | if (!m_reducedPmValues) 95 | { 96 | ueVal->AddItem ("DRB.EstabSucc.5QI.UEID", numDrb); 97 | ueVal->AddItem ("DRB.RelActNbr.5QI.UEID", drbRelAct); // not modeled in the simulator 98 | } 99 | m_msgValues.m_ueIndications.insert (ueVal); 100 | } 101 | 102 | LteIndicationMessageHelper::~LteIndicationMessageHelper () 103 | { 104 | } 105 | 106 | } // namespace ns3 -------------------------------------------------------------------------------- /helper/lte-indication-message-helper.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef LTE_INDICATION_MESSAGE_HELPER_H 26 | #define LTE_INDICATION_MESSAGE_HELPER_H 27 | 28 | #include 29 | 30 | namespace ns3 { 31 | 32 | class LteIndicationMessageHelper : public IndicationMessageHelper 33 | { 34 | public: 35 | LteIndicationMessageHelper (IndicationMessageType type, bool isOffline, bool reducedPmValues); 36 | 37 | ~LteIndicationMessageHelper (); 38 | 39 | void FillCuUpValues (std::string plmId, long pdcpBytesUl, long pdcpBytesDl); 40 | 41 | void AddCuUpUePmItem (std::string ueImsiComplete, long txBytes, long txDlPackets, 42 | double pdcpThroughput, double pdcpLatency); 43 | 44 | void AddCuUpCellPmItem (double cellAverageLatency); 45 | 46 | void FillCuCpValues (uint16_t numActiveUes); 47 | 48 | void AddCuCpUePmItem (std::string ueImsiComplete, long numDrb, long drbRelAct); 49 | 50 | private: 51 | }; 52 | 53 | } // namespace ns3 54 | 55 | #endif /* LTE_INDICATION_MESSAGE_HELPER_H */ -------------------------------------------------------------------------------- /helper/mmwave-indication-message-helper.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | 27 | namespace ns3 { 28 | 29 | MmWaveIndicationMessageHelper::MmWaveIndicationMessageHelper (IndicationMessageType type, 30 | bool isOffline, bool reducedPmValues) 31 | : IndicationMessageHelper (type, isOffline, reducedPmValues) 32 | { 33 | } 34 | 35 | void 36 | MmWaveIndicationMessageHelper::AddCuUpUePmItem (std::string ueImsiComplete, 37 | long txPdcpPduBytesNrRlc, long txPdcpPduNrRlc) 38 | { 39 | Ptr ueVal = Create (ueImsiComplete); 40 | if (!m_reducedPmValues) 41 | { 42 | // UE-specific PDCP PDU volume transmitted to NR gNB (Unit is Kbits) 43 | ueVal->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", txPdcpPduBytesNrRlc); 44 | 45 | // UE-specific number of PDCP PDUs split with NR gNB 46 | ueVal->AddItem ("DRB.PdcpPduNbrDl.Qos.UEID", txPdcpPduNrRlc); 47 | } 48 | 49 | m_msgValues.m_ueIndications.insert (ueVal); 50 | } 51 | 52 | void 53 | MmWaveIndicationMessageHelper::FillCuUpValues (std::string plmId) 54 | { 55 | FillBaseCuUpValues (plmId); 56 | } 57 | 58 | void 59 | MmWaveIndicationMessageHelper::FillCuCpValues (uint16_t numActiveUes) 60 | { 61 | FillBaseCuCpValues (numActiveUes); 62 | } 63 | 64 | void 65 | MmWaveIndicationMessageHelper::FillDuValues (std::string cellObjectId) 66 | { 67 | m_msgValues.m_cellObjectId = cellObjectId; 68 | m_msgValues.m_pmContainerValues = m_duValues; 69 | } 70 | 71 | void 72 | MmWaveIndicationMessageHelper::AddDuUePmItem ( 73 | std::string ueImsiComplete, long macPduUe, long macPduInitialUe, long macQpsk, long mac16Qam, 74 | long mac64Qam, long macRetx, long macVolume, long macPrb, long macMac04, long macMac59, 75 | long macMac1014, long macMac1519, long macMac2024, long macMac2529, long macSinrBin1, 76 | long macSinrBin2, long macSinrBin3, long macSinrBin4, long macSinrBin5, long macSinrBin6, 77 | long macSinrBin7, long rlcBufferOccup, double drbThrDlUeid) 78 | { 79 | 80 | Ptr ueVal = Create (ueImsiComplete); 81 | if (!m_reducedPmValues) 82 | { 83 | ueVal->AddItem ("TB.TotNbrDl.1.UEID", macPduUe); 84 | ueVal->AddItem ("TB.TotNbrDlInitial.UEID", macPduInitialUe); 85 | ueVal->AddItem ("TB.TotNbrDlInitial.Qpsk.UEID", macQpsk); 86 | ueVal->AddItem ("TB.TotNbrDlInitial.16Qam.UEID", mac16Qam); 87 | ueVal->AddItem ("TB.TotNbrDlInitial.64Qam.UEID", mac64Qam); 88 | ueVal->AddItem ("TB.ErrTotalNbrDl.1.UEID", macRetx); 89 | ueVal->AddItem ("QosFlow.PdcpPduVolumeDL_Filter.UEID", macVolume); 90 | ueVal->AddItem ("RRU.PrbUsedDl.UEID", (long) std::ceil (macPrb)); 91 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin1.UEID", macMac04); 92 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin2.UEID", macMac59); 93 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin3.UEID", macMac1014); 94 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin4.UEID", macMac1519); 95 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin5.UEID", macMac2024); 96 | ueVal->AddItem ("CARR.PDSCHMCSDist.Bin6.UEID", macMac2529); 97 | ueVal->AddItem ("L1M.RS-SINR.Bin34.UEID", macSinrBin1); 98 | ueVal->AddItem ("L1M.RS-SINR.Bin46.UEID", macSinrBin2); 99 | ueVal->AddItem ("L1M.RS-SINR.Bin58.UEID", macSinrBin3); 100 | ueVal->AddItem ("L1M.RS-SINR.Bin70.UEID", macSinrBin4); 101 | ueVal->AddItem ("L1M.RS-SINR.Bin82.UEID", macSinrBin5); 102 | ueVal->AddItem ("L1M.RS-SINR.Bin94.UEID", macSinrBin6); 103 | ueVal->AddItem ("L1M.RS-SINR.Bin127.UEID", macSinrBin7); 104 | ueVal->AddItem ("DRB.BufferSize.Qos.UEID", rlcBufferOccup); 105 | } 106 | 107 | // This value is not requested anymore, so it has been removed from the delivery, but it will be still logged; 108 | // ueVal->AddItem ("DRB.UEThpDlPdcpBased.UEID", drbThrDlPdcpBasedUeid); 109 | 110 | ueVal->AddItem ("DRB.UEThpDl.UEID", drbThrDlUeid); 111 | 112 | m_msgValues.m_ueIndications.insert (ueVal); 113 | } 114 | 115 | void 116 | MmWaveIndicationMessageHelper::AddDuCellPmItem ( 117 | long macPduCellSpecific, long macPduInitialCellSpecific, long macQpskCellSpecific, 118 | long mac16QamCellSpecific, long mac64QamCellSpecific, double prbUtilizationDl, 119 | long macRetxCellSpecific, long macVolumeCellSpecific, long macMac04CellSpecific, 120 | long macMac59CellSpecific, long macMac1014CellSpecific, long macMac1519CellSpecific, 121 | long macMac2024CellSpecific, long macMac2529CellSpecific, long macSinrBin1CellSpecific, 122 | long macSinrBin2CellSpecific, long macSinrBin3CellSpecific, long macSinrBin4CellSpecific, 123 | long macSinrBin5CellSpecific, long macSinrBin6CellSpecific, long macSinrBin7CellSpecific, 124 | long rlcBufferOccupCellSpecific, long activeUeDl) 125 | { 126 | Ptr cellVal = Create (); 127 | 128 | if (!m_reducedPmValues) 129 | { 130 | cellVal->AddItem ("TB.TotNbrDl.1", macPduCellSpecific); 131 | cellVal->AddItem ("TB.TotNbrDlInitial", macPduInitialCellSpecific); 132 | } 133 | 134 | cellVal->AddItem ("TB.TotNbrDlInitial.Qpsk", macQpskCellSpecific); 135 | cellVal->AddItem ("TB.TotNbrDlInitial.16Qam", mac16QamCellSpecific); 136 | cellVal->AddItem ("TB.TotNbrDlInitial.64Qam", mac64QamCellSpecific); 137 | cellVal->AddItem ("RRU.PrbUsedDl", (long) std::ceil (prbUtilizationDl)); 138 | 139 | if (!m_reducedPmValues) 140 | { 141 | cellVal->AddItem ("TB.ErrTotalNbrDl.1", macRetxCellSpecific); 142 | cellVal->AddItem ("QosFlow.PdcpPduVolumeDL_Filter", macVolumeCellSpecific); 143 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin1", macMac04CellSpecific); 144 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin2", macMac59CellSpecific); 145 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin3", macMac1014CellSpecific); 146 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin4", macMac1519CellSpecific); 147 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin5", macMac2024CellSpecific); 148 | cellVal->AddItem ("CARR.PDSCHMCSDist.Bin6", macMac2529CellSpecific); 149 | cellVal->AddItem ("L1M.RS-SINR.Bin34", macSinrBin1CellSpecific); 150 | cellVal->AddItem ("L1M.RS-SINR.Bin46", macSinrBin2CellSpecific); 151 | cellVal->AddItem ("L1M.RS-SINR.Bin58", macSinrBin3CellSpecific); 152 | cellVal->AddItem ("L1M.RS-SINR.Bin70", macSinrBin4CellSpecific); 153 | cellVal->AddItem ("L1M.RS-SINR.Bin82", macSinrBin5CellSpecific); 154 | cellVal->AddItem ("L1M.RS-SINR.Bin94", macSinrBin6CellSpecific); 155 | cellVal->AddItem ("L1M.RS-SINR.Bin127", macSinrBin7CellSpecific); 156 | cellVal->AddItem ("DRB.BufferSize.Qos", rlcBufferOccupCellSpecific); 157 | } 158 | 159 | cellVal->AddItem ("DRB.MeanActiveUeDl",activeUeDl); 160 | 161 | m_msgValues.m_cellMeasurementItems = cellVal; 162 | } 163 | 164 | void 165 | MmWaveIndicationMessageHelper::AddDuCellResRepPmItem (Ptr cellResRep) 166 | { 167 | m_duValues->m_cellResourceReportItems.insert (cellResRep); 168 | } 169 | 170 | void 171 | MmWaveIndicationMessageHelper::AddCuCpUePmItem (std::string ueImsiComplete, long numDrb, 172 | long drbRelAct, 173 | Ptr l3RrcMeasurementServing, 174 | Ptr l3RrcMeasurementNeigh) 175 | { 176 | 177 | Ptr ueVal = Create (ueImsiComplete); 178 | if (!m_reducedPmValues) 179 | { 180 | ueVal->AddItem ("DRB.EstabSucc.5QI.UEID", numDrb); 181 | ueVal->AddItem ("DRB.RelActNbr.5QI.UEID", drbRelAct); // not modeled in the simulator 182 | } 183 | 184 | ueVal->AddItem> ("HO.SrcCellQual.RS-SINR.UEID", l3RrcMeasurementServing); 185 | ueVal->AddItem> ("HO.TrgtCellQual.RS-SINR.UEID", l3RrcMeasurementNeigh); 186 | 187 | m_msgValues.m_ueIndications.insert (ueVal); 188 | } 189 | 190 | MmWaveIndicationMessageHelper::~MmWaveIndicationMessageHelper () 191 | { 192 | } 193 | 194 | } // namespace ns3 -------------------------------------------------------------------------------- /helper/mmwave-indication-message-helper.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef MMWAVE_INDICATION_MESSAGE_HELPER_H 26 | #define MMWAVE_INDICATION_MESSAGE_HELPER_H 27 | 28 | #include 29 | 30 | namespace ns3 { 31 | 32 | class MmWaveIndicationMessageHelper : public IndicationMessageHelper 33 | { 34 | public: 35 | MmWaveIndicationMessageHelper (IndicationMessageType type, bool isOffline, bool reducedPmValues); 36 | 37 | ~MmWaveIndicationMessageHelper (); 38 | 39 | void FillCuUpValues (std::string plmId); 40 | 41 | void AddCuUpUePmItem (std::string ueImsiComplete, long txPdcpPduBytesNrRlc, long txPdcpPduNrRlc); 42 | 43 | void FillCuCpValues (uint16_t numActiveUes); 44 | 45 | void FillDuValues (std::string cellObjectId); 46 | 47 | void AddDuUePmItem (std::string ueImsiComplete, long macPduUe, long macPduInitialUe, long macQpsk, 48 | long mac16Qam, long mac64Qam, long macRetx, long macVolume, long macPrb, 49 | long macMac04, long macMac59, long macMac1014, long macMac1519, 50 | long macMac2024, long macMac2529, long macSinrBin1, long macSinrBin2, 51 | long macSinrBin3, long macSinrBin4, long macSinrBin5, long macSinrBin6, 52 | long macSinrBin7, long rlcBufferOccup, double drbThrDlUeid); 53 | 54 | void AddDuCellPmItem ( 55 | long macPduCellSpecific, long macPduInitialCellSpecific, long macQpskCellSpecific, 56 | long mac16QamCellSpecific, long mac64QamCellSpecific, double prbUtilizationDl, 57 | long macRetxCellSpecific, long macVolumeCellSpecific, long macMac04CellSpecific, 58 | long macMac59CellSpecific, long macMac1014CellSpecific, long macMac1519CellSpecific, 59 | long macMac2024CellSpecific, long macMac2529CellSpecific, long macSinrBin1CellSpecific, 60 | long macSinrBin2CellSpecific, long macSinrBin3CellSpecific, long macSinrBin4CellSpecific, 61 | long macSinrBin5CellSpecific, long macSinrBin6CellSpecific, long macSinrBin7CellSpecific, 62 | long rlcBufferOccupCellSpecific, long activeUeDl); 63 | void AddDuCellResRepPmItem (Ptr cellResRep); 64 | void AddCuCpUePmItem (std::string ueImsiComplete, long numDrb, long drbRelAct, 65 | Ptr l3RrcMeasurementServing, 66 | Ptr l3RrcMeasurementNeigh); 67 | 68 | private: 69 | }; 70 | 71 | } // namespace ns3 72 | 73 | #endif /* MMWAVE_INDICATION_MESSAGE_HELPER_H */ -------------------------------------------------------------------------------- /helper/oran-interface-helper.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include "oran-interface-helper.h" 26 | 27 | namespace ns3 { 28 | 29 | /* ... */ 30 | 31 | 32 | } 33 | 34 | -------------------------------------------------------------------------------- /helper/oran-interface-helper.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef ORAN_INTERFACE_HELPER_H 26 | #define ORAN_INTERFACE_HELPER_H 27 | 28 | #include "ns3/oran-interface.h" 29 | 30 | namespace ns3 { 31 | 32 | /* ... */ 33 | 34 | } 35 | 36 | #endif /* ORAN_INTERFACE_HELPER_H */ 37 | 38 | -------------------------------------------------------------------------------- /model/asn1c-types.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef ASN1C_TYPES_H 26 | #define ASN1C_TYPES_H 27 | 28 | #include "ns3/object.h" 29 | #include 30 | 31 | extern "C" { 32 | #include "OCTET_STRING.h" 33 | #include "BIT_STRING.h" 34 | #include "PM-Info-Item.h" 35 | #include "SNSSAI.h" 36 | #include "RRCEvent.h" 37 | #include "L3-RRC-Measurements.h" 38 | #include "ServingCellMeasurements.h" 39 | #include "MeasResultNeighCells.h" 40 | #include "MeasResultNR.h" 41 | #include "MeasResultEUTRA.h" 42 | #include "MeasResultPCell.h" 43 | #include "MeasResultListEUTRA.h" 44 | #include "MeasResultListNR.h" 45 | #include "MeasResultServMO.h" 46 | #include "MeasResultServMOList.h" 47 | #include "MeasQuantityResults.h" 48 | #include "ResultsPerSSB-Index.h" 49 | #include "ResultsPerCSI-RS-Index.h" 50 | #include "E2SM-RC-ControlMessage-Format1.h" 51 | #include "RANParameter-Item.h" 52 | #include "RANParameter-ValueType.h" 53 | #include "RANParameter-ELEMENT.h" 54 | #include "RANParameter-STRUCTURE.h" 55 | } 56 | 57 | namespace ns3 { 58 | 59 | /** 60 | * Wrapper for class for OCTET STRING 61 | */ 62 | class OctetString : public SimpleRefCount 63 | { 64 | public: 65 | OctetString (std::string value, size_t size); 66 | OctetString (void *value, size_t size); 67 | ~OctetString (); 68 | OCTET_STRING_t *GetPointer (); 69 | OCTET_STRING_t GetValue (); 70 | std::string DecodeContent (); 71 | 72 | private: 73 | void CreateBaseOctetString (size_t size); 74 | OCTET_STRING_t *m_octetString; 75 | }; 76 | 77 | /** 78 | * Wrapper for class for BIT STRING 79 | */ 80 | class BitString : public SimpleRefCount 81 | { 82 | public: 83 | BitString (std::string value, size_t size); 84 | BitString (std::string value, size_t size, size_t bits_unused); 85 | ~BitString (); 86 | BIT_STRING_t *GetPointer (); 87 | BIT_STRING_t GetValue (); 88 | // TODO maybe a to string or a decode method should be created 89 | 90 | private: 91 | BIT_STRING_t *m_bitString; 92 | }; 93 | 94 | class NrCellId : public SimpleRefCount 95 | { 96 | public: 97 | NrCellId (uint16_t value); 98 | virtual ~NrCellId (); 99 | BIT_STRING_t *GetPointer (); 100 | BIT_STRING_t GetValue (); 101 | 102 | private: 103 | Ptr m_bitString; 104 | }; 105 | 106 | /** 107 | * Wrapper for class for S-NSSAI 108 | */ 109 | class Snssai : public SimpleRefCount 110 | { 111 | public: 112 | Snssai (std::string sst); 113 | Snssai (std::string sst, std::string sd); 114 | ~Snssai (); 115 | SNSSAI_t *GetPointer (); 116 | SNSSAI_t GetValue (); 117 | 118 | private: 119 | OCTET_STRING_t *m_sst; 120 | OCTET_STRING_t *m_sd; 121 | SNSSAI_t *m_sNssai; 122 | }; 123 | 124 | /** 125 | * Wrapper for class for MeasQuantityResults_t 126 | */ 127 | class MeasQuantityResultsWrap : public SimpleRefCount 128 | { 129 | public: 130 | MeasQuantityResultsWrap (); 131 | ~MeasQuantityResultsWrap (); 132 | MeasQuantityResults_t *GetPointer (); 133 | MeasQuantityResults_t GetValue (); 134 | void AddRsrp (long rsrp); 135 | void AddRsrq (long rsrq); 136 | void AddSinr (long sinr); 137 | 138 | private: 139 | MeasQuantityResults_t *m_measQuantityResults; 140 | }; 141 | 142 | /** 143 | * Wrapper for class for ResultsPerCSI_RS_Index_t 144 | */ 145 | class ResultsPerCsiRsIndex : public SimpleRefCount 146 | { 147 | public: 148 | ResultsPerCsiRsIndex (long csiRsIndex, MeasQuantityResults_t *csiRsResults); 149 | ResultsPerCsiRsIndex (long csiRsIndex); 150 | ResultsPerCSI_RS_Index_t *GetPointer (); 151 | ResultsPerCSI_RS_Index_t GetValue (); 152 | 153 | private: 154 | ResultsPerCSI_RS_Index_t *m_resultsPerCsiRsIndex; 155 | }; 156 | 157 | /** 158 | * Wrapper for class for ResultsPerSSB_Index_t 159 | */ 160 | class ResultsPerSSBIndex : public SimpleRefCount 161 | { 162 | public: 163 | ResultsPerSSBIndex (long ssbIndex, MeasQuantityResults_t *ssbResults); 164 | ResultsPerSSBIndex (long ssbIndex); 165 | ResultsPerSSB_Index_t *GetPointer (); 166 | ResultsPerSSB_Index_t GetValue (); 167 | 168 | private: 169 | ResultsPerSSB_Index_t *m_resultsPerSSBIndex; 170 | }; 171 | 172 | /** 173 | * Wrapper for class for MeasResultNR_t 174 | */ 175 | class MeasResultNr : public SimpleRefCount 176 | { 177 | public: 178 | enum ResultCell { SSB = 0, CSI_RS = 1 }; 179 | MeasResultNr (long physCellId); 180 | MeasResultNr (); 181 | ~MeasResultNr (); 182 | MeasResultNR_t *GetPointer (); 183 | MeasResultNR_t GetValue (); 184 | void AddCellResults (ResultCell cell, MeasQuantityResults_t *results); 185 | void AddPerSsbIndexResults (ResultsPerSSB_Index_t *resultsSsbIndex); 186 | void AddPerCsiRsIndexResults (ResultsPerCSI_RS_Index_t *resultsCsiRsIndex); 187 | void AddPhyCellId (long physCellId); 188 | 189 | private: 190 | MeasResultNR_t *m_measResultNr; 191 | bool m_shouldFree; 192 | }; 193 | 194 | /** 195 | * Wrapper for class for MeasResultEUTRA_t 196 | */ 197 | class MeasResultEutra : public SimpleRefCount 198 | { 199 | public: 200 | MeasResultEutra (long eutraPhysCellId, long rsrp, long rsrq, long sinr); 201 | MeasResultEutra (long eutraPhysCellId); 202 | MeasResultEUTRA_t *GetPointer (); 203 | MeasResultEUTRA_t GetValue (); 204 | void AddRsrp (long rsrp); 205 | void AddRsrq (long rsrq); 206 | void AddSinr (long sinr); 207 | 208 | private: 209 | MeasResultEUTRA_t *m_measResultEutra; 210 | }; 211 | 212 | /** 213 | * Wrapper for class for MeasResultPCell_t 214 | */ 215 | class MeasResultPCellWrap : public SimpleRefCount 216 | { 217 | public: 218 | MeasResultPCellWrap (long eutraPhysCellId, long rsrpResult, long rsrqResult); 219 | MeasResultPCellWrap (long eutraPhysCellId); 220 | MeasResultPCell_t *GetPointer (); 221 | MeasResultPCell_t GetValue (); 222 | void AddRsrpResult (long rsrpResult); 223 | void AddRsrqResult (long rsrqResult); 224 | 225 | private: 226 | MeasResultPCell_t *m_measResultPCell; 227 | }; 228 | 229 | /** 230 | * Wrapper for class for MeasResultServMO_t 231 | */ 232 | class MeasResultServMo : public SimpleRefCount 233 | { 234 | public: 235 | MeasResultServMo (long servCellId, MeasResultNR_t measResultServingCell, 236 | MeasResultNR_t *measResultBestNeighCell); 237 | MeasResultServMo (long servCellId, MeasResultNR_t measResultServingCell); 238 | MeasResultServMO_t *GetPointer (); 239 | MeasResultServMO_t GetValue (); 240 | 241 | private: 242 | MeasResultServMO_t *m_measResultServMo; 243 | }; 244 | 245 | /** 246 | * Wrapper for class for ServingCellMeasurements_t 247 | */ 248 | class ServingCellMeasurementsWrap : public SimpleRefCount 249 | { 250 | public: 251 | ServingCellMeasurementsWrap (ServingCellMeasurements_PR present); 252 | ServingCellMeasurements_t *GetPointer (); 253 | ServingCellMeasurements_t GetValue (); 254 | void AddMeasResultPCell (MeasResultPCell_t *measResultPCell); 255 | void AddMeasResultServMo (MeasResultServMO_t *measResultServMO); 256 | 257 | private: 258 | ServingCellMeasurements_t *m_servingCellMeasurements; 259 | MeasResultServMOList_t *m_nr_measResultServingMOList; 260 | }; 261 | 262 | /** 263 | * Wrapper for class for L3 RRC Measurements 264 | */ 265 | class L3RrcMeasurements : public SimpleRefCount 266 | { 267 | public: 268 | int MAX_MEAS_RESULTS_ITEMS = 8; // Maximum 8 per UE (standard) 269 | L3RrcMeasurements (RRCEvent_t rrcEvent); 270 | L3RrcMeasurements (L3_RRC_Measurements_t *l3RrcMeasurements); 271 | ~L3RrcMeasurements (); 272 | L3_RRC_Measurements_t *GetPointer (); 273 | L3_RRC_Measurements_t GetValue (); 274 | 275 | void AddMeasResultEUTRANeighCells (MeasResultEUTRA_t *measResultItemEUTRA); 276 | void AddMeasResultNRNeighCells (MeasResultNR_t *measResultItemNR); 277 | void AddServingCellMeasurement (ServingCellMeasurements_t *servingCellMeasurements); 278 | void AddNeighbourCellMeasurement (long neighCellId, long sinr); 279 | 280 | static Ptr CreateL3RrcUeSpecificSinrServing (long servingCellId, 281 | long physCellId, long sinr); 282 | 283 | static Ptr CreateL3RrcUeSpecificSinrNeigh (); 284 | 285 | // TODO change definition and return the values (to be used for decoding) 286 | static void ExtractMeasurementsFromL3RrcMeas (L3_RRC_Measurements_t *l3RrcMeasurements); 287 | 288 | /** 289 | * Returns the input SINR on a 0-127 scale 290 | * 291 | * Refer to 3GPP TS 38.133 V17.2.0(2021-06), Table 10.1.16.1-1: SS-SINR and CSI-SINR measurement report mapping 292 | * 293 | * @param sinr 294 | * @return double 295 | */ 296 | static double ThreeGppMapSinr (double sinr); 297 | 298 | private: 299 | void addMeasResultNeighCells (MeasResultNeighCells_PR present); 300 | L3_RRC_Measurements_t *m_l3RrcMeasurements; 301 | MeasResultListEUTRA_t *m_measResultListEUTRA; 302 | MeasResultListNR_t *m_measResultListNR; 303 | int m_measItemsCounter; 304 | }; 305 | 306 | /** 307 | * Wrapper for class for PM_Info_Item_t 308 | */ 309 | class MeasurementItem : public SimpleRefCount 310 | { 311 | public: 312 | MeasurementItem (std::string name, long value); 313 | MeasurementItem (std::string name, double value); 314 | MeasurementItem (std::string name, Ptr value); 315 | ~MeasurementItem (); 316 | PM_Info_Item_t *GetPointer (); 317 | PM_Info_Item_t GetValue (); 318 | 319 | private: 320 | MeasurementItem (std::string name); 321 | void CreateMeasurementValue (MeasurementValue_PR measurementValue_PR); 322 | // Main struct to be compiled 323 | PM_Info_Item_t *m_measurementItem; 324 | 325 | // Accessory structs that we must track to release memory after use 326 | MeasurementTypeName_t *m_measName; 327 | MeasurementValue_t *m_pmVal; 328 | MeasurementType_t *m_pmType; 329 | }; 330 | 331 | /** 332 | * Wrapper for class for RANParameter_Item_t 333 | */ 334 | class RANParameterItem : public SimpleRefCount 335 | { 336 | public: 337 | enum ValueType{ Nothing = 0, Int = 1, OctectString = 2 }; 338 | RANParameterItem (RANParameter_Item_t *ranParameterItem); 339 | ~RANParameterItem (); 340 | RANParameter_Item_t *GetPointer (); 341 | RANParameter_Item_t GetValue (); 342 | 343 | ValueType m_valueType; 344 | long m_valueInt; 345 | Ptr m_valueStr; 346 | 347 | static std::vector 348 | ExtractRANParametersFromRANParameter (RANParameter_Item_t *ranParameterItem); 349 | 350 | private: 351 | // Main struct 352 | RANParameter_Item_t *m_ranParameterItem; 353 | BOOLEAN_t *m_keyFlag; 354 | }; 355 | 356 | } // namespace ns3 357 | #endif /* ASN1C_TYPES_H */ 358 | -------------------------------------------------------------------------------- /model/function-description.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | namespace ns3 { 31 | 32 | NS_LOG_COMPONENT_DEFINE ("FunctionDescription"); 33 | 34 | FunctionDescription::FunctionDescription () 35 | { 36 | // E2SM_KPM_RANfunction_Description_t *descriptor = new E2SM_KPM_RANfunction_Description_t (); 37 | // FillAndEncodeKpmFunctionDescription (descriptor); 38 | // ASN_STRUCT_FREE_CONTENTS_ONLY (asn_DEF_E2SM_KPM_RANfunction_Description, descriptor); 39 | // delete descriptor; 40 | m_size = 0; 41 | } 42 | 43 | FunctionDescription::~FunctionDescription () 44 | { 45 | free (m_buffer); 46 | m_size = 0; 47 | } 48 | 49 | // TODO improve 50 | // void 51 | // FunctionDescription::Encode (E2SM_KPM_RANfunction_Description_t *descriptor) 52 | // { 53 | // asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking 54 | // // encode the structure into the e2smbuffer 55 | // asn_encode_to_new_buffer_result_s encodedMsg = asn_encode_to_new_buffer ( 56 | // opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_RANfunction_Description, descriptor); 57 | 58 | // if (encodedMsg.result.encoded < 0) 59 | // { 60 | // NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Header, errno: " 61 | // << strerror (errno) << ", failed_type " << encodedMsg.result.failed_type->name 62 | // << ", structure_ptr " << encodedMsg.result.structure_ptr); 63 | // } 64 | 65 | // m_buffer = encodedMsg.buffer; 66 | // m_size = encodedMsg.result.encoded; 67 | // } 68 | 69 | } // namespace ns3 70 | -------------------------------------------------------------------------------- /model/function-description.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef FUNCTION_DESCRIPTION_H 26 | #define FUNCTION_DESCRIPTION_H 27 | 28 | #include "ns3/object.h" 29 | 30 | // extern "C" { 31 | // #include "E2SM-KPM-RANfunction-Description.h" 32 | // #include "E2SM-KPM-IndicationHeader.h" 33 | // #include "E2SM-KPM-IndicationMessage.h" 34 | // #include "RAN-Container.h" 35 | // #include "PF-Container.h" 36 | // #include "OCUUP-PF-Container.h" 37 | // #include "PF-ContainerListItem.h" 38 | // #include "asn1c-types.h" 39 | // } 40 | 41 | namespace ns3 { 42 | 43 | class FunctionDescription : public SimpleRefCount 44 | { 45 | public: 46 | FunctionDescription (); 47 | ~FunctionDescription (); 48 | 49 | void* m_buffer; 50 | size_t m_size; 51 | 52 | // TODO improve the abstraction 53 | // private: 54 | // virtual void Encode (E2SM_KPM_RANfunction_Description_t* descriptor); 55 | }; 56 | 57 | } 58 | 59 | #endif /* FUNCTION_DESCRIPTION_H */ 60 | -------------------------------------------------------------------------------- /model/kpm-function-description.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | extern "C" { 30 | #include "RIC-EventTriggerStyle-Item.h" 31 | #include "RIC-ReportStyle-Item.h" 32 | } 33 | 34 | namespace ns3 { 35 | 36 | NS_LOG_COMPONENT_DEFINE ("KpmFunctionDescription"); 37 | 38 | KpmFunctionDescription::KpmFunctionDescription () 39 | { 40 | E2SM_KPM_RANfunction_Description_t *descriptor = new E2SM_KPM_RANfunction_Description_t (); 41 | FillAndEncodeKpmFunctionDescription (descriptor); 42 | ASN_STRUCT_FREE_CONTENTS_ONLY (asn_DEF_E2SM_KPM_RANfunction_Description, descriptor); 43 | delete descriptor; 44 | } 45 | 46 | KpmFunctionDescription::~KpmFunctionDescription () 47 | { 48 | free (m_buffer); 49 | m_size = 0; 50 | } 51 | 52 | void 53 | KpmFunctionDescription::Encode (E2SM_KPM_RANfunction_Description_t *descriptor) 54 | { 55 | asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking 56 | // encode the structure into the e2smbuffer 57 | asn_encode_to_new_buffer_result_s encodedMsg = asn_encode_to_new_buffer ( 58 | opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_RANfunction_Description, descriptor); 59 | 60 | if (encodedMsg.result.encoded < 0) 61 | { 62 | NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Header, errno: " 63 | << strerror (errno) << ", failed_type " << encodedMsg.result.failed_type->name 64 | << ", structure_ptr " << encodedMsg.result.structure_ptr); 65 | } 66 | 67 | m_buffer = encodedMsg.buffer; 68 | m_size = encodedMsg.result.encoded; 69 | } 70 | 71 | void 72 | KpmFunctionDescription::FillAndEncodeKpmFunctionDescription ( 73 | E2SM_KPM_RANfunction_Description_t *ranfunc_desc) 74 | { 75 | std::string shortNameBuffer = "ORAN-WG3-KPM"; 76 | uint8_t *descriptionBuffer = (uint8_t *) "KPM monitor"; 77 | uint8_t *oidBuffer = (uint8_t *) "OID123"; // this is optional, dummy value 78 | 79 | Ptr shortName = Create (shortNameBuffer, shortNameBuffer.size ()); 80 | 81 | ranfunc_desc->ranFunction_Name.ranFunction_ShortName = shortName->GetValue (); 82 | 83 | long *inst = (long *) calloc (1, sizeof (long)); 84 | 85 | // ranfunc_desc->ranFunction_Name.ranFunction_Description = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); 86 | ranfunc_desc->ranFunction_Name.ranFunction_Description.buf = 87 | (uint8_t *) calloc (1, strlen ((char *) descriptionBuffer)); 88 | memcpy (ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, descriptionBuffer, 89 | strlen ((char *) descriptionBuffer)); 90 | ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen ((char *) descriptionBuffer); 91 | ranfunc_desc->ranFunction_Name.ranFunction_Instance = inst; 92 | 93 | // ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); 94 | ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf = 95 | (uint8_t *) calloc (1, strlen ((char *) oidBuffer)); 96 | memcpy (ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, oidBuffer, 97 | strlen ((char *) oidBuffer)); 98 | ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen ((char *) oidBuffer); 99 | 100 | RIC_EventTriggerStyle_Item_t *trigger_style = 101 | (RIC_EventTriggerStyle_Item_t *) calloc (1, sizeof (RIC_EventTriggerStyle_Item_t)); 102 | trigger_style->ric_EventTriggerStyle_Type = 1; 103 | uint8_t *eventTriggerStyleNameBuffer = (uint8_t *) "Periodic report"; 104 | // trigger_style->ric_EventTriggerStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); 105 | trigger_style->ric_EventTriggerStyle_Name.buf = 106 | (uint8_t *) calloc (1, strlen ((char *) eventTriggerStyleNameBuffer)); 107 | memcpy (trigger_style->ric_EventTriggerStyle_Name.buf, eventTriggerStyleNameBuffer, 108 | strlen ((char *) eventTriggerStyleNameBuffer)); 109 | trigger_style->ric_EventTriggerStyle_Name.size = strlen ((char *) eventTriggerStyleNameBuffer); 110 | trigger_style->ric_EventTriggerFormat_Type = 1; 111 | 112 | ranfunc_desc->ric_EventTriggerStyle_List = 113 | (E2SM_KPM_RANfunction_Description:: 114 | E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List *) 115 | calloc (1, sizeof (E2SM_KPM_RANfunction_Description:: 116 | E2SM_KPM_RANfunction_Description__ric_EventTriggerStyle_List)); 117 | 118 | ASN_SEQUENCE_ADD (&ranfunc_desc->ric_EventTriggerStyle_List->list, trigger_style); 119 | 120 | RIC_ReportStyle_Item_t *report_style1 = 121 | (RIC_ReportStyle_Item_t *) calloc (1, sizeof (RIC_ReportStyle_Item_t)); 122 | report_style1->ric_ReportStyle_Type = 1; 123 | 124 | uint8_t *reportStyleNameBuffer = 125 | (uint8_t *) "O-CU-CP Measurement Container for the EPC connected deployment"; 126 | 127 | // report_style1->ric_ReportStyle_Name = (OCTET_STRING_t*)calloc(1, sizeof(OCTET_STRING_t)); 128 | report_style1->ric_ReportStyle_Name.buf = 129 | (uint8_t *) calloc (1, strlen ((char *) reportStyleNameBuffer)); 130 | memcpy (report_style1->ric_ReportStyle_Name.buf, reportStyleNameBuffer, 131 | strlen ((char *) reportStyleNameBuffer)); 132 | report_style1->ric_ReportStyle_Name.size = strlen ((char *) reportStyleNameBuffer); 133 | report_style1->ric_ReportIndicationHeaderFormat_Type = 1; 134 | report_style1->ric_ReportIndicationMessageFormat_Type = 1; 135 | ranfunc_desc->ric_ReportStyle_List = 136 | (E2SM_KPM_RANfunction_Description::E2SM_KPM_RANfunction_Description__ric_ReportStyle_List *) 137 | calloc (1, sizeof (E2SM_KPM_RANfunction_Description:: 138 | E2SM_KPM_RANfunction_Description__ric_ReportStyle_List)); 139 | 140 | ASN_SEQUENCE_ADD (&ranfunc_desc->ric_ReportStyle_List->list, report_style1); 141 | 142 | Encode (ranfunc_desc); 143 | 144 | NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_KPM_RANfunction_Description, ranfunc_desc)); 145 | } 146 | 147 | } // namespace ns3 148 | -------------------------------------------------------------------------------- /model/kpm-function-description.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef KPM_FUNCTION_DESCRIPTION_H 26 | #define KPM_FUNCTION_DESCRIPTION_H 27 | 28 | #include "ns3/object.h" 29 | #include 30 | 31 | extern "C" { 32 | #include "E2SM-KPM-RANfunction-Description.h" 33 | #include "E2SM-KPM-IndicationHeader.h" 34 | #include "E2SM-KPM-IndicationMessage.h" 35 | #include "RAN-Container.h" 36 | #include "PF-Container.h" 37 | #include "OCUUP-PF-Container.h" 38 | #include "PF-ContainerListItem.h" 39 | #include "asn1c-types.h" 40 | } 41 | 42 | namespace ns3 { 43 | 44 | class KpmFunctionDescription : public FunctionDescription 45 | { 46 | public: 47 | KpmFunctionDescription (); 48 | ~KpmFunctionDescription (); 49 | 50 | private: 51 | /** 52 | * Encodes the RAN Function Description item for the KPM Service Model. 53 | * 54 | * \param kpmFunctionDescription the RAN Function Description item 55 | */ 56 | void FillAndEncodeKpmFunctionDescription (E2SM_KPM_RANfunction_Description_t* descriptor); 57 | void Encode (E2SM_KPM_RANfunction_Description_t* descriptor); 58 | }; 59 | 60 | } 61 | 62 | #endif /* KPM_FUNCTION_DESCRIPTION_H */ 63 | -------------------------------------------------------------------------------- /model/kpm-indication.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | extern "C" { 30 | #include "E2SM-KPM-IndicationHeader-Format1.h" 31 | #include "E2SM-KPM-IndicationMessage-Format1.h" 32 | #include "GlobalE2node-ID.h" 33 | #include "GlobalE2node-gNB-ID.h" 34 | #include "GlobalE2node-eNB-ID.h" 35 | #include "GlobalE2node-ng-eNB-ID.h" 36 | #include "GlobalE2node-en-gNB-ID.h" 37 | #include "NRCGI.h" 38 | #include "PM-Containers-Item.h" 39 | #include "RIC-EventTriggerStyle-Item.h" 40 | #include "RIC-ReportStyle-Item.h" 41 | #include "TimeStamp.h" 42 | #include "CUUPMeasurement-Container.h" 43 | #include "PlmnID-Item.h" 44 | #include "EPC-CUUP-PM-Format.h" 45 | #include "PerQCIReportListItemFormat.h" 46 | #include "PerUE-PM-Item.h" 47 | #include "PM-Info-Item.h" 48 | #include "MeasurementInfoList.h" 49 | #include "CellObjectID.h" 50 | #include "CellResourceReportListItem.h" 51 | #include "ServedPlmnPerCellListItem.h" 52 | #include "EPC-DU-PM-Container.h" 53 | #include "PerQCIReportListItem.h" 54 | } 55 | 56 | namespace ns3 { 57 | 58 | NS_LOG_COMPONENT_DEFINE ("KpmIndication"); 59 | 60 | KpmIndicationHeader::KpmIndicationHeader (GlobalE2nodeType nodeType,KpmRicIndicationHeaderValues values) 61 | { 62 | m_nodeType = nodeType; 63 | E2SM_KPM_IndicationHeader_t *descriptor = new E2SM_KPM_IndicationHeader_t; 64 | FillAndEncodeKpmRicIndicationHeader (descriptor, values); 65 | delete descriptor; 66 | } 67 | 68 | KpmIndicationHeader::~KpmIndicationHeader () 69 | { 70 | NS_LOG_FUNCTION (this); 71 | free (m_buffer); 72 | m_size = 0; 73 | } 74 | 75 | void 76 | KpmIndicationHeader::Encode (E2SM_KPM_IndicationHeader_t *descriptor) 77 | { 78 | asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking 79 | asn_encode_to_new_buffer_result_s encodedHeader = asn_encode_to_new_buffer ( 80 | opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationHeader, descriptor); 81 | 82 | if (encodedHeader.result.encoded < 0) 83 | { 84 | NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Header, errno: " 85 | << strerror (errno) << ", failed_type " 86 | << encodedHeader.result.failed_type->name << ", structure_ptr " 87 | << encodedHeader.result.structure_ptr); 88 | } 89 | 90 | m_buffer = encodedHeader.buffer; 91 | m_size = encodedHeader.result.encoded; 92 | } 93 | 94 | void 95 | KpmIndicationHeader::FillAndEncodeKpmRicIndicationHeader (E2SM_KPM_IndicationHeader_t *descriptor, 96 | KpmRicIndicationHeaderValues values) 97 | { 98 | 99 | E2SM_KPM_IndicationHeader_Format1_t *ind_header = (E2SM_KPM_IndicationHeader_Format1_t *) calloc ( 100 | 1, sizeof (E2SM_KPM_IndicationHeader_Format1_t)); 101 | 102 | Ptr plmnid = Create (values.m_plmId, 3); 103 | Ptr cellId_bstring; 104 | 105 | GlobalE2node_ID *globalE2nodeIdBuf = (GlobalE2node_ID *) calloc (1, sizeof (GlobalE2node_ID)); 106 | ind_header->id_GlobalE2node_ID = *globalE2nodeIdBuf; 107 | 108 | switch (m_nodeType) 109 | { 110 | case gNB: { 111 | static int sizeGnb = 4; // 3GPP Specs 112 | 113 | cellId_bstring = Create (values.m_gnbId, sizeGnb); 114 | 115 | ind_header->id_GlobalE2node_ID.present = GlobalE2node_ID_PR_gNB; 116 | GlobalE2node_gNB_ID_t *globalE2node_gNB_ID = 117 | (GlobalE2node_gNB_ID_t *) calloc (1, sizeof (GlobalE2node_gNB_ID_t)); 118 | globalE2node_gNB_ID->global_gNB_ID.plmn_id = plmnid->GetValue (); 119 | globalE2node_gNB_ID->global_gNB_ID.gnb_id.present = GNB_ID_Choice_PR_gnb_ID; 120 | globalE2node_gNB_ID->global_gNB_ID.gnb_id.choice.gnb_ID = cellId_bstring->GetValue (); 121 | ind_header->id_GlobalE2node_ID.choice.gNB = globalE2node_gNB_ID; 122 | } 123 | break; 124 | 125 | case eNB: { 126 | static int sizeEnb = 127 | 3; // 3GPP TS 36.413 version 14.8.0 Release 14, Section 9.2.1.37 Global eNB ID 128 | static int unsedSizeEnb = 4; 129 | 130 | cellId_bstring = Create (values.m_gnbId, sizeEnb, unsedSizeEnb); 131 | 132 | ind_header->id_GlobalE2node_ID.present = GlobalE2node_ID_PR_eNB; 133 | GlobalE2node_eNB_ID_t *globalE2node_eNB_ID = 134 | (GlobalE2node_eNB_ID_t *) calloc (1, sizeof (GlobalE2node_eNB_ID_t)); 135 | globalE2node_eNB_ID->global_eNB_ID.pLMN_Identity = plmnid->GetValue (); 136 | globalE2node_eNB_ID->global_eNB_ID.eNB_ID.present = ENB_ID_PR_macro_eNB_ID; 137 | globalE2node_eNB_ID->global_eNB_ID.eNB_ID.choice.macro_eNB_ID = cellId_bstring->GetValue (); 138 | ind_header->id_GlobalE2node_ID.choice.eNB = globalE2node_eNB_ID; 139 | } 140 | break; 141 | 142 | case ng_eNB: { 143 | static int sizeEnb = 144 | 3; // 3GPP TS 36.413 version 14.8.0 Release 14, Section 9.2.1.37 Global eNB ID 145 | static int unsedSizeEnb = 4; 146 | 147 | cellId_bstring = Create (values.m_gnbId, sizeEnb, unsedSizeEnb); 148 | 149 | ind_header->id_GlobalE2node_ID.present = GlobalE2node_ID_PR_ng_eNB; 150 | GlobalE2node_ng_eNB_ID_t *globalE2node_ng_eNB_ID = 151 | (GlobalE2node_ng_eNB_ID_t *) calloc (1, sizeof (GlobalE2node_ng_eNB_ID_t)); 152 | 153 | globalE2node_ng_eNB_ID->global_ng_eNB_ID.plmn_id = plmnid->GetValue (); 154 | globalE2node_ng_eNB_ID->global_ng_eNB_ID.enb_id.present = ENB_ID_Choice_PR_enb_ID_macro; 155 | globalE2node_ng_eNB_ID->global_ng_eNB_ID.enb_id.choice.enb_ID_macro = 156 | cellId_bstring->GetValue (); 157 | ind_header->id_GlobalE2node_ID.choice.ng_eNB = globalE2node_ng_eNB_ID; 158 | } 159 | break; 160 | 161 | case en_gNB: { 162 | static int sizeGnb = 4; // 3GPP Specs 163 | cellId_bstring = Create (values.m_gnbId, sizeGnb); 164 | 165 | ind_header->id_GlobalE2node_ID.present = GlobalE2node_ID_PR_en_gNB; 166 | GlobalE2node_en_gNB_ID_t *globalE2node_en_gNB_ID = 167 | (GlobalE2node_en_gNB_ID_t *) calloc (1, sizeof (GlobalE2node_en_gNB_ID_t)); 168 | globalE2node_en_gNB_ID->global_gNB_ID.pLMN_Identity = plmnid->GetValue (); 169 | globalE2node_en_gNB_ID->global_gNB_ID.gNB_ID.present = ENGNB_ID_PR_gNB_ID; 170 | globalE2node_en_gNB_ID->global_gNB_ID.gNB_ID.choice.gNB_ID = cellId_bstring->GetValue (); 171 | ind_header->id_GlobalE2node_ID.choice.en_gNB = globalE2node_en_gNB_ID; 172 | } 173 | break; 174 | 175 | default: 176 | NS_FATAL_ERROR ( 177 | "Unrecognized node type for KpmRicIndicationHeader, value passed: " << m_nodeType); 178 | break; 179 | } 180 | 181 | NS_LOG_DEBUG ("Timestamp received: " << values.m_timestamp); 182 | long bigEndianTimestamp = htobe64 (values.m_timestamp); 183 | NS_LOG_DEBUG ("Timestamp inverted: " << bigEndianTimestamp); 184 | 185 | Ptr ts = Create ((void *) &bigEndianTimestamp, TIMESTAMP_LIMIT_SIZE); 186 | //NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_OCTET_STRING, ts->GetPointer() )); 187 | 188 | // Ptr ts2 = Create ((void *) &values.m_timestamp, TIMESTAMP_LIMIT_SIZE); 189 | // NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_OCTET_STRING, ts2->GetPointer())); 190 | 191 | ind_header->collectionStartTime = ts->GetValue (); 192 | 193 | 194 | NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_KPM_IndicationHeader_Format1, ind_header)); 195 | 196 | descriptor->present = E2SM_KPM_IndicationHeader_PR_indicationHeader_Format1; 197 | descriptor->choice.indicationHeader_Format1 = ind_header; 198 | 199 | Encode (descriptor); 200 | ASN_STRUCT_FREE (asn_DEF_E2SM_KPM_IndicationHeader_Format1, ind_header); 201 | free (globalE2nodeIdBuf); 202 | // TraceMessage (&asn_DEF_E2SM_KPM_IndicationHeader, header, "RIC Indication Header"); 203 | } 204 | 205 | KpmIndicationMessage::KpmIndicationMessage (KpmIndicationMessageValues values) 206 | { 207 | E2SM_KPM_IndicationMessage_t *descriptor = new E2SM_KPM_IndicationMessage_t (); 208 | CheckConstraints (values); 209 | FillAndEncodeKpmIndicationMessage (descriptor, values); 210 | delete descriptor; 211 | } 212 | 213 | KpmIndicationMessage::~KpmIndicationMessage () 214 | { 215 | free (m_buffer); 216 | m_size = 0; 217 | } 218 | 219 | void 220 | KpmIndicationMessage::CheckConstraints (KpmIndicationMessageValues values) 221 | { 222 | // TODO remove? 223 | // if (values.m_crnti.length () != 2) 224 | // { 225 | // NS_FATAL_ERROR ("C-RNTI should have length 2"); 226 | // } 227 | // if (values.m_plmId.length () != 3) 228 | // { 229 | // NS_FATAL_ERROR ("PLMID should have length 3"); 230 | // } 231 | // if (values.m_nrCellId.length () != 5) 232 | // { 233 | // NS_FATAL_ERROR ("NR Cell ID should have length 5"); 234 | // } 235 | // TODO add other constraints 236 | } 237 | 238 | void 239 | KpmIndicationMessage::Encode (E2SM_KPM_IndicationMessage_t *descriptor) 240 | { 241 | asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking 242 | asn_encode_to_new_buffer_result_s encodedMsg = asn_encode_to_new_buffer ( 243 | opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_KPM_IndicationMessage, descriptor); 244 | 245 | if (encodedMsg.result.encoded < 0) 246 | { 247 | NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Message, errno: " 248 | << strerror (errno) << ", failed_type " << encodedMsg.result.failed_type->name 249 | << ", structure_ptr " << encodedMsg.result.structure_ptr); 250 | } 251 | 252 | m_buffer = encodedMsg.buffer; 253 | m_size = encodedMsg.result.encoded; 254 | } 255 | 256 | void 257 | KpmIndicationMessage::FillPmContainer (PF_Container_t *ranContainer, Ptr values) 258 | { 259 | Ptr cuUpVal = DynamicCast (values); 260 | Ptr cuCpVal = DynamicCast (values); 261 | Ptr duVal = DynamicCast (values); 262 | 263 | if (cuUpVal) 264 | { 265 | FillOCuUpContainer (ranContainer, cuUpVal); 266 | } 267 | else if (cuCpVal) 268 | { 269 | FillOCuCpContainer (ranContainer, cuCpVal); 270 | } 271 | else if (duVal) 272 | { 273 | FillODuContainer (ranContainer, duVal); 274 | } 275 | else 276 | { 277 | NS_FATAL_ERROR ("Unknown PM Container type"); 278 | } 279 | } 280 | 281 | void 282 | KpmIndicationMessage::FillOCuUpContainer (PF_Container_t *ranContainer, 283 | Ptr values) 284 | { 285 | OCUUP_PF_Container_t* ocuup = (OCUUP_PF_Container_t*) calloc (1, sizeof (OCUUP_PF_Container_t)); 286 | PF_ContainerListItem_t* pcli = (PF_ContainerListItem_t*) calloc (1, sizeof (PF_ContainerListItem_t)); 287 | pcli->interface_type = NI_Type_x2_u; 288 | 289 | CUUPMeasurement_Container_t* cuuppmc = (CUUPMeasurement_Container_t*) calloc (1, sizeof (CUUPMeasurement_Container_t)); 290 | PlmnID_Item_t* plmnItem = (PlmnID_Item_t*) calloc (1, sizeof (PlmnID_Item_t)); 291 | Ptr plmnidstr = Create (values->m_plmId, 3); 292 | plmnItem->pLMN_Identity = plmnidstr->GetValue (); 293 | 294 | EPC_CUUP_PM_Format_t* cuuppmf = (EPC_CUUP_PM_Format_t*) calloc (1, sizeof (EPC_CUUP_PM_Format_t)); 295 | plmnItem->cu_UP_PM_EPC = cuuppmf; 296 | PerQCIReportListItemFormat_t* pqrli = (PerQCIReportListItemFormat_t*) calloc (1, sizeof (PerQCIReportListItemFormat_t)); 297 | pqrli->drbqci = 0; 298 | 299 | INTEGER_t *pDCPBytesDL = (INTEGER_t *) calloc (1, sizeof (INTEGER_t)); 300 | INTEGER_t *pDCPBytesUL = (INTEGER_t *) calloc (1, sizeof (INTEGER_t)); 301 | 302 | asn_long2INTEGER (pDCPBytesDL, values->m_pDCPBytesDL); 303 | asn_long2INTEGER (pDCPBytesUL, values->m_pDCPBytesUL); 304 | 305 | pqrli->pDCPBytesDL = pDCPBytesDL; 306 | pqrli->pDCPBytesUL = pDCPBytesUL; 307 | 308 | ASN_SEQUENCE_ADD (&cuuppmf->perQCIReportList_cuup.list, pqrli); 309 | 310 | ASN_SEQUENCE_ADD (&cuuppmc->plmnList.list, plmnItem); 311 | 312 | pcli->o_CU_UP_PM_Container = *cuuppmc; 313 | ASN_SEQUENCE_ADD (&ocuup->pf_ContainerList, pcli); 314 | ranContainer->choice.oCU_UP = ocuup; 315 | ranContainer->present = PF_Container_PR_oCU_UP; 316 | 317 | free (cuuppmc); 318 | } 319 | 320 | void 321 | KpmIndicationMessage::FillOCuCpContainer (PF_Container_t *ranContainer, 322 | Ptr values) 323 | { 324 | OCUCP_PF_Container_t *ocucp = (OCUCP_PF_Container_t *) calloc (1, sizeof(OCUCP_PF_Container_t)); 325 | long *numActiveUes = (long *) calloc (1, sizeof (long)); 326 | *numActiveUes = long(values->m_numActiveUes); 327 | ocucp->cu_CP_Resource_Status.numberOfActive_UEs = numActiveUes; 328 | ranContainer->choice.oCU_CP = ocucp; 329 | ranContainer->present = PF_Container_PR_oCU_CP; 330 | } 331 | 332 | void 333 | KpmIndicationMessage::FillODuContainer (PF_Container_t *ranContainer, 334 | Ptr values) 335 | { 336 | ODU_PF_Container_t *odu = (ODU_PF_Container_t *) calloc (1, sizeof (ODU_PF_Container_t)); 337 | 338 | for (auto cellReport : values->m_cellResourceReportItems) 339 | { 340 | NS_LOG_LOGIC ("O-DU: Add Cell Resource Report Item"); 341 | CellResourceReportListItem_t *crrli = 342 | (CellResourceReportListItem_t *) calloc (1, sizeof (CellResourceReportListItem_t)); 343 | 344 | Ptr plmnid = Create (cellReport->m_plmId, 3); 345 | Ptr nrcellid = Create (cellReport->m_nrCellId); 346 | crrli->nRCGI.pLMN_Identity = plmnid->GetValue (); 347 | crrli->nRCGI.nRCellIdentity = nrcellid->GetValue (); 348 | 349 | long *dlAvailablePrbs = (long *) calloc (1, sizeof (long)); 350 | *dlAvailablePrbs = cellReport->dlAvailablePrbs; 351 | crrli->dl_TotalofAvailablePRBs = dlAvailablePrbs; 352 | 353 | long *ulAvailablePrbs = (long *) calloc (1, sizeof (long)); 354 | *ulAvailablePrbs = cellReport->ulAvailablePrbs; 355 | crrli->ul_TotalofAvailablePRBs = ulAvailablePrbs; 356 | ASN_SEQUENCE_ADD (&odu->cellResourceReportList.list, crrli); 357 | 358 | for (auto servedPlmnCell : cellReport->m_servedPlmnPerCellItems) 359 | { 360 | NS_LOG_LOGIC ("O-DU: Add Served Plmn Per Cell Item"); 361 | ServedPlmnPerCellListItem_t *sppcl = 362 | (ServedPlmnPerCellListItem_t *) calloc (1, sizeof (ServedPlmnPerCellListItem_t)); 363 | Ptr servedPlmnId = Create (servedPlmnCell->m_plmId, 3); 364 | sppcl->pLMN_Identity = servedPlmnId->GetValue (); 365 | 366 | EPC_DU_PM_Container_t *edpc = 367 | (EPC_DU_PM_Container_t *) calloc (1, sizeof (EPC_DU_PM_Container_t)); 368 | 369 | for (auto perQciReportItem : servedPlmnCell->m_perQciReportItems) 370 | { 371 | NS_LOG_LOGIC ("O-DU: Add Per QCI Report Item"); 372 | PerQCIReportListItem_t *pqrl = 373 | (PerQCIReportListItem_t *) calloc (1, sizeof (PerQCIReportListItem_t)); 374 | pqrl->qci = perQciReportItem->m_qci; 375 | 376 | NS_ABORT_MSG_IF ((perQciReportItem->m_dlPrbUsage < 0) | (perQciReportItem->m_dlPrbUsage > 100), 377 | "As per ASN definition, dl_PRBUsage should be between 0 and 100"); 378 | long *dlUsedPrbs = (long *) calloc (1, sizeof (long)); 379 | *dlUsedPrbs = perQciReportItem->m_dlPrbUsage; 380 | pqrl->dl_PRBUsage = dlUsedPrbs; 381 | NS_LOG_LOGIC ("DL PRBs " << dlUsedPrbs); 382 | 383 | NS_ABORT_MSG_IF ((perQciReportItem->m_ulPrbUsage < 0) | (perQciReportItem->m_ulPrbUsage > 100), 384 | "As per ASN definition, ul_PRBUsage should be between 0 and 100"); 385 | long *ulUsedPrbs = (long *) calloc (1, sizeof (long)); 386 | *ulUsedPrbs = perQciReportItem->m_ulPrbUsage; 387 | pqrl->ul_PRBUsage = ulUsedPrbs; 388 | ASN_SEQUENCE_ADD (&edpc->perQCIReportList_du.list, pqrl); 389 | } 390 | 391 | sppcl->du_PM_EPC = edpc; 392 | ASN_SEQUENCE_ADD (&crrli->servedPlmnPerCellList.list, sppcl); 393 | } 394 | } 395 | ranContainer->choice.oDU = odu; 396 | ranContainer->present = PF_Container_PR_oDU; 397 | } 398 | 399 | void 400 | KpmIndicationMessage::FillAndEncodeKpmIndicationMessage (E2SM_KPM_IndicationMessage_t *descriptor, 401 | KpmIndicationMessageValues values) 402 | { 403 | // Create and fill the RAN Container 404 | PF_Container_t *ranContainer = (PF_Container_t *) calloc (1, sizeof (PF_Container_t)); 405 | FillPmContainer (ranContainer, values.m_pmContainerValues); 406 | 407 | //------- now fill the message 408 | PM_Containers_Item_t *containers_list = 409 | (PM_Containers_Item_t *) calloc (1, sizeof (PM_Containers_Item_t)); 410 | containers_list->performanceContainer = ranContainer; 411 | 412 | E2SM_KPM_IndicationMessage_Format1_t *format = (E2SM_KPM_IndicationMessage_Format1_t *) calloc ( 413 | 1, sizeof (E2SM_KPM_IndicationMessage_Format1_t)); 414 | 415 | ASN_SEQUENCE_ADD (&format->pm_Containers.list, containers_list); 416 | 417 | // Cell Object ID 418 | CellObjectID_t *cellObjectID = (CellObjectID_t *) calloc (1, sizeof (CellObjectID_t)); 419 | cellObjectID->size = values.m_cellObjectId.length (); 420 | cellObjectID->buf = (uint8_t *) calloc (1, cellObjectID->size); 421 | memcpy (cellObjectID->buf, values.m_cellObjectId.c_str (), values.m_cellObjectId.length ()); 422 | format->cellObjectID = *cellObjectID; 423 | 424 | // Measurement Information List 425 | if (values.m_cellMeasurementItems) 426 | { 427 | format->list_of_PM_Information = (E2SM_KPM_IndicationMessage_Format1:: 428 | E2SM_KPM_IndicationMessage_Format1__list_of_PM_Information *) 429 | calloc (1, sizeof (E2SM_KPM_IndicationMessage_Format1:: 430 | E2SM_KPM_IndicationMessage_Format1__list_of_PM_Information)); 431 | for (auto item : values.m_cellMeasurementItems->GetItems ()) 432 | { 433 | ASN_SEQUENCE_ADD (&format->list_of_PM_Information->list, item->GetPointer ()); 434 | } 435 | } 436 | 437 | // List of matched UEs 438 | if (values.m_ueIndications.size () > 0) 439 | { 440 | format->list_of_matched_UEs = (E2SM_KPM_IndicationMessage_Format1_t::E2SM_KPM_IndicationMessage_Format1__list_of_matched_UEs*) 441 | calloc (1, sizeof (E2SM_KPM_IndicationMessage_Format1_t::E2SM_KPM_IndicationMessage_Format1__list_of_matched_UEs)); 442 | 443 | 444 | for (auto ueIndication : values.m_ueIndications) 445 | { 446 | PerUE_PM_Item_t *perUEItem = (PerUE_PM_Item_t *) calloc (1, sizeof (PerUE_PM_Item_t)); 447 | 448 | // UE Identity 449 | perUEItem->ueId = ueIndication->GetId (); 450 | // xer_fprint (stderr, &asn_DEF_UE_Identity, &perUEItem->ueId); 451 | // NS_LOG_UNCOND ("Values " << ueIndication->m_drbIPLateDlUEID); 452 | 453 | // List of Measurements PM information 454 | perUEItem->list_of_PM_Information = 455 | (PerUE_PM_Item::PerUE_PM_Item__list_of_PM_Information *) calloc ( 456 | 1, sizeof (PerUE_PM_Item::PerUE_PM_Item__list_of_PM_Information)); 457 | 458 | for (auto measurementItem : ueIndication->GetItems ()) 459 | { 460 | ASN_SEQUENCE_ADD (&perUEItem->list_of_PM_Information->list, 461 | measurementItem->GetPointer ()); 462 | } 463 | ASN_SEQUENCE_ADD (&format->list_of_matched_UEs->list, perUEItem); 464 | } 465 | } 466 | 467 | descriptor->present = E2SM_KPM_IndicationMessage_PR_indicationMessage_Format1; 468 | descriptor->choice.indicationMessage_Format1 = format; 469 | 470 | 471 | NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_KPM_IndicationMessage_Format1, format)); 472 | 473 | // xer_fprint (stderr, &asn_DEF_PF_Container, ranContainer); 474 | Encode (descriptor); 475 | 476 | free (cellObjectID); 477 | // free (ranContainer); 478 | ASN_STRUCT_FREE (asn_DEF_E2SM_KPM_IndicationMessage_Format1, format); 479 | } 480 | 481 | MeasurementItemList::MeasurementItemList () 482 | { 483 | m_id = NULL; 484 | } 485 | 486 | MeasurementItemList::MeasurementItemList (std::string id) 487 | { 488 | m_id = Create (id, id.length ()); 489 | } 490 | 491 | MeasurementItemList::~MeasurementItemList (){}; 492 | 493 | std::vector> 494 | MeasurementItemList::GetItems () 495 | { 496 | return m_items; 497 | } 498 | 499 | OCTET_STRING_t 500 | MeasurementItemList::GetId () 501 | { 502 | NS_ABORT_IF (m_id == NULL); 503 | return m_id->GetValue (); 504 | } 505 | 506 | } // namespace ns3 507 | -------------------------------------------------------------------------------- /model/kpm-indication.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef KPM_INDICATION_H 26 | #define KPM_INDICATION_H 27 | 28 | #include "ns3/object.h" 29 | #include 30 | 31 | extern "C" { 32 | #include "E2SM-KPM-RANfunction-Description.h" 33 | #include "E2SM-KPM-IndicationHeader.h" 34 | #include "E2SM-KPM-IndicationMessage.h" 35 | #include "RAN-Container.h" 36 | #include "PF-Container.h" 37 | #include "OCUUP-PF-Container.h" 38 | #include "OCUCP-PF-Container.h" 39 | #include "ODU-PF-Container.h" 40 | #include "PF-ContainerListItem.h" 41 | #include "asn1c-types.h" 42 | } 43 | 44 | namespace ns3 { 45 | 46 | class KpmIndicationHeader : public SimpleRefCount 47 | { 48 | public: 49 | enum GlobalE2nodeType { gNB = 0, eNB = 1, ng_eNB = 2, en_gNB = 3 }; 50 | 51 | int TIMESTAMP_LIMIT_SIZE = 8; 52 | /** 53 | * Holds the values to be used to fill the RIC Indication header 54 | */ 55 | struct KpmRicIndicationHeaderValues 56 | { 57 | // E2SM-KPM Indication Header Format 1 58 | // KPM Node ID IE 59 | std::string m_gnbId; //!< gNB ID bit string 60 | // TODO not supported 61 | // uint64_t m_cuUpId; //!< gNB-CU-UP ID, integer [0, 2^36-1], optional 62 | 63 | // Cell Global ID (NR CGI) IE 64 | uint16_t m_nrCellId; //!< NR, bit string 65 | 66 | // PLMN ID IE 67 | std::string m_plmId; //!< PLMN identity, octet string, 3 bytes 68 | 69 | // Slice ID (S-NSSAI) IE // TODO not supported 70 | // std::string m_sst; //!< SNSSAI sST, 1 byte 71 | // std::string m_sd; //!< SNSSAI sD, 3 bytes, optional 72 | 73 | // FiveQI IE // TODO not supported 74 | // uint8_t m_fiveqi; //!< fiveQI, integer [0, 255], optional 75 | 76 | // QCI IE // TODO not supported 77 | // long m_qci; //!< QCI, integer [0, 255], optional 78 | 79 | // TODO this value is placed in a fiels which seems not to be defined 80 | // in the specs. See line 301 in encode_kpm.cpp 81 | // the field is called gNB_DU_ID 82 | // it should be part of KPM Node ID IE 83 | // m_duId 84 | 85 | // TODO this value is placed in a fiels which seems not to be defined 86 | // in the specs. See line 290 in encode_kpm.cpp, the field is called 87 | // gNB_Name 88 | // m_cuUpName 89 | 90 | // CollectionTimeStamp 91 | uint64_t m_timestamp; 92 | }; 93 | 94 | KpmIndicationHeader (GlobalE2nodeType nodeType,KpmRicIndicationHeaderValues values); 95 | ~KpmIndicationHeader (); 96 | void* m_buffer; 97 | size_t m_size; 98 | 99 | private: 100 | /** 101 | * Fills the KPM INDICATION Header descriptor 102 | * This function fills the RIC Indication Header with the provided 103 | * values 104 | * 105 | * \param descriptor object representing the KPM INDICATION Header 106 | * \param values struct holding the values to be used to fill the header 107 | */ 108 | void FillAndEncodeKpmRicIndicationHeader (E2SM_KPM_IndicationHeader_t* descriptor, 109 | KpmRicIndicationHeaderValues values); 110 | 111 | void Encode (E2SM_KPM_IndicationHeader_t* descriptor); 112 | 113 | GlobalE2nodeType m_nodeType; 114 | }; 115 | 116 | class MeasurementItemList : public SimpleRefCount 117 | { 118 | private: 119 | Ptr m_id; // ID, contains the UE IMSI if used to carry UE-specific measurement items 120 | std::vector> m_items; //!< list of Measurement Information Items 121 | public: 122 | MeasurementItemList (); 123 | MeasurementItemList (std::string ueId); 124 | ~MeasurementItemList (); 125 | 126 | // NOTE defined here to avoid undefined references 127 | template 128 | void AddItem (std::string name, T value) 129 | { 130 | Ptr item = Create (name, value); 131 | m_items.push_back (item); 132 | } 133 | 134 | std::vector> GetItems(); 135 | OCTET_STRING_t GetId (); 136 | }; 137 | 138 | /** 139 | * Base class to carry PM Container values 140 | */ 141 | class PmContainerValues : public SimpleRefCount 142 | { 143 | public: 144 | virtual ~PmContainerValues () = default; 145 | }; 146 | 147 | /** 148 | * Contains the values to be inserted in the O-CU-CP Measurement Container 149 | */ 150 | class OCuCpContainerValues : public PmContainerValues 151 | { 152 | public: 153 | uint16_t m_numActiveUes; //!< mean number of RRC connections 154 | }; 155 | 156 | /** 157 | * Contains the values to be inserted in the O-CU-UP Measurement Container 158 | */ 159 | class OCuUpContainerValues : public PmContainerValues 160 | { 161 | public: 162 | std::string m_plmId; //!< PLMN identity, octet string, 3 bytes 163 | long m_pDCPBytesUL; //!< total PDCP bytes transmitted UL 164 | long m_pDCPBytesDL; //!< total PDCP bytes transmitted DL 165 | }; 166 | 167 | /** 168 | * Contains the values to be inserted in the O-DU EPC Measurement Container 169 | */ 170 | class EpcDuPmContainer : public SimpleRefCount 171 | { 172 | public: 173 | long m_qci; //!< QCI value 174 | long m_dlPrbUsage; //!< Used number of PRBs in an average of DL for the monitored slice during E2 reporting period 175 | long m_ulPrbUsage; //!< Used number of PRBs in an average of UL for the monitored slice during E2 reporting period 176 | virtual ~EpcDuPmContainer () = default; 177 | }; 178 | 179 | /** 180 | * Contains the values to be inserted in the O-DU 5GC Measurement Container 181 | */ 182 | class FiveGcDuPmContainer : public SimpleRefCount 183 | { 184 | public: 185 | // Snssai m_sliceId; //!< S-NSSAI 186 | long m_fiveQi; //!< 5QI value 187 | long m_dlPrbUsage; //!< Used number of PRBs in an average of DL for the monitored slice during E2 reporting period 188 | long m_ulPrbUsage; //!< Used number of PRBs in an average of UL for the monitored slice during E2 reporting period 189 | virtual ~FiveGcDuPmContainer () = default; 190 | }; 191 | 192 | class ServedPlmnPerCell : public SimpleRefCount 193 | { 194 | public: 195 | std::string m_plmId; //!< PLMN identity, octet string, 3 bytes 196 | uint16_t m_nrCellId; 197 | std::set> m_perQciReportItems; 198 | }; 199 | 200 | class CellResourceReport : public SimpleRefCount 201 | { 202 | public: 203 | std::string m_plmId; //!< PLMN identity, octet string, 3 bytes 204 | uint16_t m_nrCellId; 205 | long dlAvailablePrbs; 206 | long ulAvailablePrbs; 207 | std::set> m_servedPlmnPerCellItems; 208 | }; 209 | 210 | /** 211 | * Contains the values to be inserted in the O-DU Measurement Container 212 | */ 213 | class ODuContainerValues : public PmContainerValues 214 | { 215 | public: 216 | std::set> m_cellResourceReportItems; 217 | }; 218 | 219 | class KpmIndicationMessage : public SimpleRefCount 220 | { 221 | public: 222 | 223 | /** 224 | * Holds the values to be used to fill the RIC Indication Message 225 | */ 226 | struct KpmIndicationMessageValues 227 | { 228 | std::string m_cellObjectId; //!< Cell Object ID 229 | Ptr m_pmContainerValues; //!< struct containing values to be inserted in the PM Container 230 | Ptr m_cellMeasurementItems; //!< list of cell-specific Measurement Information Items 231 | std::set> m_ueIndications; //!< list of Measurement Information Items 232 | }; 233 | 234 | KpmIndicationMessage (KpmIndicationMessageValues values); 235 | ~KpmIndicationMessage (); 236 | 237 | void* m_buffer; 238 | size_t m_size; 239 | 240 | private: 241 | static void CheckConstraints (KpmIndicationMessageValues values); 242 | void FillPmContainer (PF_Container_t *ranContainer, 243 | Ptr values); 244 | void FillOCuUpContainer (PF_Container_t *ranContainer, 245 | Ptr values); 246 | void FillOCuCpContainer (PF_Container_t *ranContainer, 247 | Ptr values); 248 | void FillODuContainer (PF_Container_t *ranContainer, 249 | Ptr values); 250 | void FillAndEncodeKpmIndicationMessage (E2SM_KPM_IndicationMessage_t *descriptor, 251 | KpmIndicationMessageValues values); 252 | void Encode (E2SM_KPM_IndicationMessage_t *descriptor); 253 | }; 254 | } 255 | 256 | #endif /* KPM_INDICATION_H */ 257 | -------------------------------------------------------------------------------- /model/oran-interface.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include "encode_e2apv1.hpp" 31 | 32 | extern "C" { 33 | #include "RICsubscriptionRequest.h" 34 | #include "RICactionType.h" 35 | #include "ProtocolIE-Field.h" 36 | #include "InitiatingMessage.h" 37 | } 38 | 39 | namespace ns3 { 40 | 41 | NS_LOG_COMPONENT_DEFINE ("E2Termination"); 42 | 43 | NS_OBJECT_ENSURE_REGISTERED (E2Termination); 44 | 45 | TypeId E2Termination::GetTypeId () 46 | { 47 | static TypeId tid = TypeId ("ns3::E2Termination") 48 | .SetParent() 49 | .AddConstructor(); 50 | return tid; 51 | } 52 | 53 | E2Termination::E2Termination () 54 | { 55 | NS_FATAL_ERROR("Do not use the default constructor"); 56 | } 57 | 58 | E2Termination::E2Termination(const std::string ricAddress, 59 | const uint16_t ricPort, 60 | const uint16_t clientPort, 61 | const std::string gnbId, 62 | const std::string plmnId) 63 | : m_ricAddress (ricAddress), 64 | m_ricPort (ricPort), 65 | m_clientPort (clientPort), 66 | m_gnbId (gnbId), 67 | m_plmnId(plmnId) 68 | { 69 | NS_LOG_FUNCTION (this); 70 | m_e2sim = new E2Sim; 71 | 72 | // create a new file which will be used to trace the encoded messages 73 | // TODO create an appropriate log class to handle these messages 74 | // FILE* f = fopen ("messages.txt", "w"); 75 | // fclose (f); 76 | } 77 | 78 | void 79 | E2Termination::RegisterFunctionDescToE2Sm (long ranFunctionId, Ptr ranFunctionDescription) 80 | { 81 | // create an octet string and copy the e2smbuffer 82 | OCTET_STRING_t *rfdBuf = (OCTET_STRING_t *) calloc (1, sizeof (OCTET_STRING_t)); 83 | rfdBuf->buf = (uint8_t *) calloc (1, ranFunctionDescription->m_size); 84 | rfdBuf->size = ranFunctionDescription->m_size; 85 | memcpy (rfdBuf->buf, ranFunctionDescription->m_buffer, ranFunctionDescription->m_size); 86 | 87 | m_e2sim->register_e2sm (ranFunctionId, rfdBuf); 88 | } 89 | 90 | void 91 | E2Termination::RegisterKpmCallbackToE2Sm (long ranFunctionId, Ptr ranFunctionDescription, 92 | SubscriptionCallback sbCb) 93 | { 94 | RegisterFunctionDescToE2Sm (ranFunctionId,ranFunctionDescription); 95 | m_e2sim->register_subscription_callback (ranFunctionId, sbCb); 96 | } 97 | 98 | void 99 | E2Termination::RegisterSmCallbackToE2Sm (long ranFunctionId, Ptr ranFunctionDescription, SmCallback smCb) 100 | { 101 | RegisterFunctionDescToE2Sm (ranFunctionId,ranFunctionDescription); 102 | m_e2sim->register_sm_callback (ranFunctionId, smCb); 103 | } 104 | 105 | void E2Termination::Start () 106 | { 107 | NS_LOG_FUNCTION (this); 108 | 109 | NS_ABORT_MSG_IF(m_ricAddress.empty(), "Set the RIC information first"); 110 | 111 | // create a thread to host e2sim execution 112 | std::thread e2simThread (&E2Termination::DoStart, this); 113 | e2simThread.detach (); 114 | } 115 | 116 | void E2Termination::DoStart () 117 | { 118 | NS_LOG_FUNCTION (this); 119 | 120 | // start e2sim main loop 121 | // char second[14]; // RIC ADDRESS 122 | // std::strcpy (second, m_ricAddress.c_str ()); 123 | // char third[6]; // RIC PORT 124 | // std::strcpy (third, std::to_string (m_ricPort).c_str ()); 125 | // char fourth[5]; // GNB ID value 126 | // std::strncpy (fourth, m_gnbId.c_str (), 4); 127 | // char fifth[6]; // CLIENT PORT 128 | // std::strcpy (fifth, std::to_string (m_clientPort).c_str ()); 129 | // char sixth[4]; //PLMN ID 130 | // std::strcpy (sixth, m_plmnId.c_str ()); 131 | 132 | NS_LOG_INFO ("In ns3::E2Term: GNB" << m_gnbId << ", clientPort " << m_clientPort << ", ricPort " 133 | << m_ricPort << ", PlmnID " 134 | << m_plmnId); 135 | 136 | // char* argv [] = {nullptr, &second [0], &third [0], &fourth[0], &fifth[0],&sixth[0]}; 137 | m_e2sim->run_loop (m_ricAddress, m_ricPort, m_clientPort, m_gnbId, m_plmnId); 138 | } 139 | 140 | E2Termination::~E2Termination () 141 | { 142 | NS_LOG_FUNCTION (this); 143 | delete m_e2sim; 144 | } 145 | 146 | E2Termination::RicSubscriptionRequest_rval_s 147 | E2Termination::ProcessRicSubscriptionRequest (E2AP_PDU_t* sub_req_pdu) 148 | { 149 | //Record RIC Request ID 150 | //Go through RIC action to be Setup List 151 | //Find first entry with REPORT action Type 152 | //Record ricActionID 153 | //Encode subscription response 154 | 155 | RICsubscriptionRequest_t orig_req = sub_req_pdu->choice.initiatingMessage->value.choice.RICsubscriptionRequest; 156 | 157 | // RICsubscriptionResponse_IEs_t *ricreqid = (RICsubscriptionResponse_IEs_t*)calloc(1, sizeof(RICsubscriptionResponse_IEs_t)); 158 | 159 | int count = orig_req.protocolIEs.list.count; 160 | int size = orig_req.protocolIEs.list.size; 161 | 162 | RICsubscriptionRequest_IEs_t **ies = (RICsubscriptionRequest_IEs_t**)orig_req.protocolIEs.list.array; 163 | 164 | NS_LOG_DEBUG ("Number of IEs " << count); 165 | NS_LOG_DEBUG ("Size of IEs " << size); 166 | 167 | RICsubscriptionRequest_IEs__value_PR pres; 168 | 169 | uint16_t reqRequestorId {}; 170 | uint16_t reqInstanceId {}; 171 | uint16_t ranFuncionId {}; 172 | uint8_t reqActionId {}; 173 | 174 | std::vector actionIdsAccept; 175 | std::vector actionIdsReject; 176 | 177 | // iterate over the IEs 178 | for (int i = 0; i < count; i++) 179 | { 180 | RICsubscriptionRequest_IEs_t *next_ie = ies[i]; 181 | pres = next_ie->value.present; // value of the current IE 182 | 183 | switch(pres) 184 | { 185 | // IE containing the RIC Request ID 186 | case RICsubscriptionRequest_IEs__value_PR_RICrequestID: 187 | { 188 | NS_LOG_DEBUG ("Processing RIC Request ID field"); 189 | RICrequestID_t reqId = next_ie->value.choice.RICrequestID; 190 | reqRequestorId = reqId.ricRequestorID; 191 | reqInstanceId = reqId.ricInstanceID; 192 | NS_LOG_DEBUG ( "RIC Requestor ID " << reqRequestorId); 193 | NS_LOG_DEBUG ( "RIC Instance ID " << reqInstanceId); 194 | break; 195 | } 196 | // IE containing the RAN Function ID 197 | case RICsubscriptionRequest_IEs__value_PR_RANfunctionID: 198 | { 199 | NS_LOG_DEBUG ("Processing RAN Function ID field"); 200 | ranFuncionId = next_ie->value.choice.RANfunctionID; 201 | NS_LOG_DEBUG ("RAN Function ID " << ranFuncionId); 202 | break; 203 | } 204 | case RICsubscriptionRequest_IEs__value_PR_RICsubscriptionDetails: 205 | { 206 | NS_LOG_DEBUG ("Processing RIC Subscription Details field"); 207 | RICsubscriptionDetails_t subDetails = next_ie->value.choice.RICsubscriptionDetails; 208 | 209 | // RIC Event Trigger Definition 210 | RICeventTriggerDefinition_t triggerDef = subDetails.ricEventTriggerDefinition; 211 | 212 | // TODO How to decode this field? 213 | uint8_t size = 20; 214 | uint8_t *buf = (uint8_t *)calloc(1,size); 215 | memcpy(buf, &triggerDef, size); 216 | NS_LOG_DEBUG ("RIC Event Trigger Definition " << std::to_string (*buf)); 217 | 218 | // Sequence of actions 219 | RICactions_ToBeSetup_List_t actionList = subDetails.ricAction_ToBeSetup_List; 220 | // TODO We are ignoring the trigger definition 221 | 222 | int actionCount = actionList.list.count; 223 | NS_LOG_DEBUG ("Number of actions " << actionCount); 224 | 225 | auto **item_array = actionList.list.array; 226 | bool foundAction = false; 227 | 228 | for (int i = 0; i < actionCount; i++) 229 | { 230 | auto *next_item = item_array[i]; 231 | RICactionID_t actionId = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionID; 232 | RICactionType_t actionType = ((RICaction_ToBeSetup_ItemIEs*)next_item)->value.choice.RICaction_ToBeSetup_Item.ricActionType; 233 | 234 | //We identify the first action whose type is REPORT 235 | //That is the only one accepted; all others are rejected 236 | if (!foundAction && (actionType == RICactionType_report || actionType == RICactionType_insert)) 237 | { 238 | reqActionId = actionId; 239 | actionIdsAccept.push_back(reqActionId); 240 | NS_LOG_DEBUG ("Action ID " << actionId << " accepted"); 241 | foundAction = true; 242 | } 243 | else 244 | { 245 | reqActionId = actionId; 246 | NS_LOG_DEBUG ("Action ID " << actionId << " rejected"); 247 | // actionIdsReject.push_back(reqActionId); 248 | } 249 | } 250 | break; 251 | } 252 | default: 253 | { 254 | NS_LOG_DEBUG ("in case default"); 255 | break; 256 | } 257 | } 258 | } 259 | 260 | NS_LOG_DEBUG ("Create RIC Subscription Response"); 261 | 262 | E2AP_PDU *e2ap_pdu = (E2AP_PDU*)calloc(1,sizeof(E2AP_PDU)); 263 | 264 | long *accept_array = &actionIdsAccept[0]; 265 | long *reject_array = &actionIdsReject[0]; 266 | int accept_size = actionIdsAccept.size(); 267 | int reject_size = actionIdsReject.size(); 268 | 269 | encoding::generate_e2apv1_subscription_response_success(e2ap_pdu, accept_array, reject_array, accept_size, reject_size, reqRequestorId, reqInstanceId); 270 | 271 | NS_LOG_DEBUG ("Send RIC Subscription Response"); 272 | m_e2sim->encode_and_send_sctp_data(e2ap_pdu); 273 | 274 | RicSubscriptionRequest_rval_s reqParams; 275 | reqParams.requestorId = reqRequestorId; 276 | reqParams.instanceId = reqInstanceId; 277 | reqParams.ranFuncionId = ranFuncionId; 278 | reqParams.actionId = reqActionId; 279 | return reqParams; 280 | } 281 | 282 | void 283 | E2Termination::SendE2Message (E2AP_PDU* pdu) 284 | { 285 | m_e2sim->encode_and_send_sctp_data (pdu); 286 | } 287 | 288 | } 289 | -------------------------------------------------------------------------------- /model/oran-interface.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef ORAN_INTERFACE_H 26 | #define ORAN_INTERFACE_H 27 | 28 | #include "ns3/object.h" 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include "e2sim.hpp" 34 | 35 | namespace ns3 { 36 | 37 | class E2Termination : public Object 38 | { 39 | public: 40 | 41 | E2Termination(); 42 | 43 | /** 44 | * 45 | * \param ricAddress RIC IP address 46 | * \param ricPort RIC port 47 | * \param clientPort the local port to which the client will bind 48 | * \param gnbId the GNB ID 49 | * \param plmnId the PLMN ID 50 | */ 51 | E2Termination(const std::string ricAddress, 52 | const uint16_t ricPort, 53 | const uint16_t clientPort, 54 | const std::string gnbId, 55 | const std::string plmnId); 56 | 57 | virtual ~E2Termination (); 58 | 59 | /** 60 | * inherited from Object 61 | * @return 62 | */ 63 | static TypeId GetTypeId(); 64 | 65 | /** 66 | * Start the E2 termination. 67 | * Create a separate thread to host the execution of e2sim. The thread will 68 | * execute the method DoStart. 69 | */ 70 | void Start (); 71 | 72 | /** 73 | * Register an E2 Service Model. 74 | * Create a RAN Function Description item containing the configurations 75 | * for the SM, add it to the list of supported RAN functions, and 76 | * register a callback. 77 | * Whenever a RIC Subscription Request to this RAN Function is received, 78 | * the callback is triggered. 79 | * 80 | * \param ranFunctionId ID used to identify the KPM RAN Function 81 | * \param ranFunctionDescription 82 | * \param cb callback that will be triggered if the RIC subscribes to 83 | * this function 84 | */ 85 | void RegisterKpmCallbackToE2Sm (long ranFunctionId, 86 | Ptr ranFunctionDescription, 87 | SubscriptionCallback sbCb); 88 | 89 | /** 90 | * Register an E2 Service Model. 91 | * Create a RAN Function Description item containing the configurations 92 | * for the SM, add it to the list of supported RAN functions, and 93 | * register a callback. 94 | * Whenever a Sm message to this RAN Function is received, 95 | * the callback is triggered. 96 | * 97 | * \param ranFunctionId ID used to identify the KPM RAN Function 98 | * \param ranFunctionDescription 99 | * \param cb callback that will be triggered if the RIC subscribes to 100 | * this function 101 | */ 102 | void RegisterSmCallbackToE2Sm (long ranFunctionId, 103 | Ptr ranFunctionDescription, 104 | SmCallback smCb); 105 | 106 | /** 107 | * Struct holding the values returned by ProcessRicSubscriptionRequest 108 | */ 109 | struct RicSubscriptionRequest_rval_s 110 | { 111 | uint16_t requestorId; //!< RIC Requestor ID 112 | uint16_t instanceId; //!< RIC Instance ID 113 | uint16_t ranFuncionId; //!< RAN Function ID 114 | uint8_t actionId; //!< RIC Action ID 115 | }; 116 | 117 | /** 118 | * Process RIC Subscription Request. 119 | * This function processes the RIC Subscription Request and sends the 120 | * RIC Subscription Response. 121 | * 122 | * \param sub_req_pdu request message 123 | * \return RIC subscription request parameters 124 | */ 125 | RicSubscriptionRequest_rval_s ProcessRicSubscriptionRequest (E2AP_PDU_t* sub_req_pdu); 126 | 127 | /** 128 | * Sends an E2 message to the RIC 129 | * This function encodes and sends an E2 message to the RIC 130 | * 131 | * \param pdu the PDU of the message 132 | */ 133 | void SendE2Message (E2AP_PDU* pdu); 134 | 135 | private: 136 | /** 137 | * Run the e2sim main loop. 138 | * Starts the e2sim main loop, it will open a socket towards the RIC and 139 | * start the reception routine. 140 | */ 141 | void DoStart (); 142 | 143 | /** 144 | * \brief Accessory function to populate to the registration of the ran function description to e2sim 145 | * 146 | * \param ranFunctionId 147 | * \param ranFunctionDescription 148 | */ 149 | void RegisterFunctionDescToE2Sm (long ranFunctionId, 150 | Ptr ranFunctionDescription); 151 | 152 | E2Sim* m_e2sim; //!< pointer to an instance of the O-RAN E2 simulator 153 | std::string m_ricAddress; //!< IP address of the RIC 154 | uint16_t m_ricPort; //!< port of the RIC 155 | uint16_t m_clientPort; //!< local bind port 156 | std::string m_gnbId; //!< GNB id 157 | std::string m_plmnId; //!< PLMN Id 158 | }; 159 | } 160 | 161 | #endif /* ORAN_INTERFACE_H */ 162 | -------------------------------------------------------------------------------- /model/ric-control-function-description.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | extern "C" { 30 | #include "RIC-ControlStyle-Item.h" 31 | #include "RIC-ControlAction-Item.h" 32 | #include "RAN-ControlParameter-Item.h" 33 | } 34 | 35 | namespace ns3 { 36 | 37 | NS_LOG_COMPONENT_DEFINE ("RicControlFunctionDescription"); 38 | 39 | RicControlFunctionDescription::RicControlFunctionDescription () 40 | { 41 | E2SM_RC_RANFunctionDefinition_t *descriptor = new E2SM_RC_RANFunctionDefinition_t (); 42 | FillAndEncodeRCFunctionDescription (descriptor); 43 | ASN_STRUCT_FREE_CONTENTS_ONLY (asn_DEF_E2SM_RC_RANFunctionDefinition, descriptor); 44 | delete descriptor; 45 | } 46 | 47 | RicControlFunctionDescription::~RicControlFunctionDescription () 48 | { 49 | 50 | } 51 | 52 | void 53 | RicControlFunctionDescription::Encode (E2SM_RC_RANFunctionDefinition_t *descriptor) 54 | { 55 | asn_codec_ctx_t *opt_cod = 0; // disable stack bounds checking 56 | // encode the structure into the e2smbuffer 57 | asn_encode_to_new_buffer_result_s encodedMsg = asn_encode_to_new_buffer ( 58 | opt_cod, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_RC_RANFunctionDefinition, descriptor); 59 | 60 | if (encodedMsg.result.encoded < 0) 61 | { 62 | NS_FATAL_ERROR ("Error during the encoding of the RIC Indication Header, errno: " 63 | << strerror (errno) << ", failed_type " << encodedMsg.result.failed_type->name 64 | << ", structure_ptr " << encodedMsg.result.structure_ptr); 65 | } 66 | 67 | m_buffer = encodedMsg.buffer; 68 | m_size = encodedMsg.result.encoded; 69 | } 70 | 71 | void 72 | RicControlFunctionDescription::FillAndEncodeRCFunctionDescription ( 73 | E2SM_RC_RANFunctionDefinition_t *ranfunc_desc) 74 | { 75 | 76 | std::string shortNameBuffer = "ORAN-WG3-RC"; 77 | 78 | Ptr shortName = Create (shortNameBuffer, shortNameBuffer.size ()); 79 | 80 | ranfunc_desc->ranFunction_Name.ranFunction_ShortName = shortName->GetValue (); 81 | 82 | // This part is not in the specs, maybe it can be removed? 83 | 84 | uint8_t *descriptionBuffer = (uint8_t *) "RIC Control Definitions"; 85 | uint8_t *oidBuffer = (uint8_t *) "OID123"; // this is optional, dummy value 86 | 87 | long *inst = (long *) calloc (1, sizeof (long)); 88 | 89 | ranfunc_desc->ranFunction_Name.ranFunction_Description.buf = 90 | (uint8_t *) calloc (1, strlen ((char *) descriptionBuffer)); 91 | memcpy (ranfunc_desc->ranFunction_Name.ranFunction_Description.buf, descriptionBuffer, 92 | strlen ((char *) descriptionBuffer)); 93 | ranfunc_desc->ranFunction_Name.ranFunction_Description.size = strlen ((char *) descriptionBuffer); 94 | ranfunc_desc->ranFunction_Name.ranFunction_Instance = inst; 95 | ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf = 96 | (uint8_t *) calloc (1, strlen ((char *) oidBuffer)); 97 | memcpy (ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.buf, oidBuffer, 98 | strlen ((char *) oidBuffer)); 99 | ranfunc_desc->ranFunction_Name.ranFunction_E2SM_OID.size = strlen ((char *) oidBuffer); 100 | 101 | // End part of of specs 102 | 103 | RIC_ControlStyle_Item_t *control_style0 = 104 | (RIC_ControlStyle_Item_t *) calloc (1, sizeof (RIC_ControlStyle_Item_t)); 105 | control_style0->ric_ControlStyle_Type = 1; 106 | 107 | uint8_t *controlStyleName0Buffer = (uint8_t *) "Radio Bearer Control"; 108 | size_t controlStyleName0BufferSize = strlen ((char *) controlStyleName0Buffer); 109 | control_style0->ric_ControlStyle_Name.buf = (uint8_t *) calloc (1, controlStyleName0BufferSize); 110 | memcpy (control_style0->ric_ControlStyle_Name.buf, controlStyleName0Buffer, 111 | controlStyleName0BufferSize); 112 | control_style0->ric_ControlStyle_Name.size = controlStyleName0BufferSize; 113 | 114 | // these two were not present in the spec in this control style but just in the second, remove if they lead to crash 115 | control_style0->ric_ControlMessageFormat_Type = 1; 116 | control_style0->ric_ControlHeaderFormat_Type = 1; 117 | 118 | control_style0->ric_ControlAction_List = 119 | (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List *) calloc ( 120 | 1, sizeof (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List)); 121 | 122 | RIC_ControlAction_Item_t *control_action0 = 123 | (RIC_ControlAction_Item_t *) calloc (1, sizeof (RIC_ControlAction_Item_t)); 124 | 125 | control_action0->ric_ControlAction_ID = 6; 126 | uint8_t *controlActionName0Buffer = (uint8_t *) "DRB split ratio control"; 127 | size_t controlActionName0BufferSize = strlen ((char *) controlActionName0Buffer); 128 | control_action0->ric_ControlAction_Name.buf = 129 | (uint8_t *) calloc (1, controlActionName0BufferSize); 130 | memcpy (control_action0->ric_ControlAction_Name.buf, controlActionName0Buffer, 131 | controlActionName0BufferSize); 132 | control_action0->ric_ControlAction_Name.size = controlActionName0BufferSize; 133 | control_action0->ran_ControlParameters_List = 134 | (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List *) calloc ( 135 | 1, sizeof (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List)); 136 | 137 | RAN_ControlParameter_Item_t *ranParameter0 = 138 | (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t)); 139 | uint8_t *ranParameter0NameBuffer = (uint8_t *) "Downlink PDCP Data Split"; 140 | size_t ranParameter0NameBufferSize = strlen ((char *) ranParameter0NameBuffer); 141 | ranParameter0->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter0NameBufferSize); 142 | memcpy (ranParameter0->ranParameter_Name.buf, ranParameter0NameBuffer, 143 | ranParameter0NameBufferSize); 144 | ranParameter0->ranParameter_Name.size = ranParameter0NameBufferSize; 145 | ranParameter0->ranParameter_ID = 3; 146 | 147 | RAN_ControlParameter_Item_t *ranParameter1 = 148 | (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t)); 149 | uint8_t *ranParameter1NameBuffer = (uint8_t *) "Uplink PDCP Data Split Threshold"; 150 | size_t ranParameter1NameBufferSize = strlen ((char *) ranParameter1NameBuffer); 151 | ranParameter1->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter1NameBufferSize); 152 | memcpy (ranParameter1->ranParameter_Name.buf, ranParameter1NameBuffer, 153 | ranParameter1NameBufferSize); 154 | ranParameter1->ranParameter_ID = 2; 155 | 156 | ASN_SEQUENCE_ADD (&control_action0->ran_ControlParameters_List->list, ranParameter0); 157 | ASN_SEQUENCE_ADD (&control_action0->ran_ControlParameters_List->list, ranParameter1); 158 | 159 | ASN_SEQUENCE_ADD (&control_style0->ric_ControlAction_List->list, control_action0); 160 | 161 | RIC_ControlStyle_Item_t *control_style1 = 162 | (RIC_ControlStyle_Item_t *) calloc (1, sizeof (RIC_ControlStyle_Item_t)); 163 | control_style1->ric_ControlStyle_Type = 3; 164 | 165 | uint8_t *controlStyleName1Buffer = (uint8_t *) "Radio Bearer Control"; 166 | size_t controlStyleName1BufferSize = strlen ((char *) controlStyleName1Buffer); 167 | control_style1->ric_ControlStyle_Name.buf = (uint8_t *) calloc (1, controlStyleName1BufferSize); 168 | memcpy (control_style1->ric_ControlStyle_Name.buf, controlStyleName1Buffer, 169 | controlStyleName1BufferSize); 170 | control_style1->ric_ControlStyle_Name.size = controlStyleName1BufferSize; 171 | 172 | control_style1->ric_ControlMessageFormat_Type = 1; 173 | control_style1->ric_ControlHeaderFormat_Type = 1; 174 | 175 | control_style1->ric_ControlAction_List = 176 | (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List *) calloc ( 177 | 1, sizeof (RIC_ControlStyle_Item::RIC_ControlStyle_Item__ric_ControlAction_List)); 178 | 179 | RIC_ControlAction_Item_t *control_action1 = 180 | (RIC_ControlAction_Item_t *) calloc (1, sizeof (RIC_ControlAction_Item_t)); 181 | 182 | control_action1->ric_ControlAction_ID = 1; 183 | uint8_t *controlActionName1Buffer = (uint8_t *) "Handover control"; 184 | size_t controlActionName1BufferSize = strlen ((char *) controlActionName1Buffer); 185 | control_action1->ric_ControlAction_Name.buf = 186 | (uint8_t *) calloc (1, controlActionName1BufferSize); 187 | memcpy (control_action1->ric_ControlAction_Name.buf, controlActionName1Buffer, 188 | controlActionName1BufferSize); 189 | control_action1->ric_ControlAction_Name.size = controlActionName1BufferSize; 190 | control_action1->ran_ControlParameters_List = 191 | (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List *) calloc ( 192 | 1, sizeof (RIC_ControlAction_Item::RIC_ControlAction_Item__ran_ControlParameters_List)); 193 | 194 | RAN_ControlParameter_Item_t *ranParameter2 = 195 | (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t)); 196 | uint8_t *ranParameter2NameBuffer = (uint8_t *) "NR CGI"; 197 | size_t ranParameter2NameBufferSize = strlen ((char *) ranParameter2NameBuffer); 198 | ranParameter2->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter2NameBufferSize); 199 | memcpy (ranParameter2->ranParameter_Name.buf, ranParameter2NameBuffer, 200 | ranParameter2NameBufferSize); 201 | ranParameter2->ranParameter_Name.size = ranParameter2NameBufferSize; 202 | ranParameter2->ranParameter_ID = 4; 203 | 204 | RAN_ControlParameter_Item_t *ranParameter3 = 205 | (RAN_ControlParameter_Item_t *) calloc (1, sizeof (RAN_ControlParameter_Item_t)); 206 | uint8_t *ranParameter3NameBuffer = (uint8_t *) "E-UTRA CGI"; 207 | size_t ranParameter3NameBufferSize = strlen ((char *) ranParameter3NameBuffer); 208 | ranParameter3->ranParameter_Name.buf = (uint8_t *) calloc (1, ranParameter3NameBufferSize); 209 | memcpy (ranParameter3->ranParameter_Name.buf, ranParameter3NameBuffer, 210 | ranParameter3NameBufferSize); 211 | ranParameter3->ranParameter_Name.size = ranParameter3NameBufferSize; 212 | ranParameter3->ranParameter_ID = 6; 213 | 214 | ASN_SEQUENCE_ADD (&control_action1->ran_ControlParameters_List->list, ranParameter2); 215 | ASN_SEQUENCE_ADD (&control_action1->ran_ControlParameters_List->list, ranParameter3); 216 | 217 | ASN_SEQUENCE_ADD (&control_style1->ric_ControlAction_List->list, control_action1); 218 | 219 | ranfunc_desc->ric_ControlStyle_List = 220 | (E2SM_RC_RANFunctionDefinition::E2SM_RC_RANFunctionDefinition__ric_ControlStyle_List *) 221 | calloc (1, sizeof (E2SM_RC_RANFunctionDefinition:: 222 | E2SM_RC_RANFunctionDefinition__ric_ControlStyle_List)); 223 | 224 | ASN_SEQUENCE_ADD (&ranfunc_desc->ric_ControlStyle_List->list, control_style0); 225 | ASN_SEQUENCE_ADD (&ranfunc_desc->ric_ControlStyle_List->list, control_style1); 226 | 227 | Encode (ranfunc_desc); 228 | 229 | NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_RC_RANFunctionDefinition, ranfunc_desc)); 230 | } 231 | 232 | } // namespace ns3 233 | -------------------------------------------------------------------------------- /model/ric-control-function-description.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef RIC_CONTROL_FUNCTION_DESCRIPTION_H 26 | #define RIC_CONTROL_FUNCTION_DESCRIPTION_H 27 | 28 | #include 29 | #include "ns3/object.h" 30 | 31 | extern "C" { 32 | #include "E2SM-RC-RANFunctionDefinition.h" 33 | } 34 | 35 | namespace ns3 { 36 | 37 | class RicControlFunctionDescription : public FunctionDescription 38 | { 39 | public: 40 | RicControlFunctionDescription (); 41 | ~RicControlFunctionDescription (); 42 | 43 | 44 | private: 45 | 46 | void FillAndEncodeRCFunctionDescription (E2SM_RC_RANFunctionDefinition_t* descriptor); 47 | void Encode (E2SM_RC_RANFunctionDefinition_t* descriptor); 48 | }; 49 | } 50 | 51 | #endif /* RIC_CONTROL_FUNCTION_DESCRIPTION_H */ 52 | -------------------------------------------------------------------------------- /model/ric-control-message.cc: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | namespace ns3 { 30 | 31 | NS_LOG_COMPONENT_DEFINE ("RicControlMessage"); 32 | 33 | 34 | RicControlMessage::RicControlMessage (E2AP_PDU_t* pdu) 35 | { 36 | DecodeRicControlMessage (pdu); 37 | NS_LOG_INFO ("End of RicControlMessage::RicControlMessage()"); 38 | } 39 | 40 | RicControlMessage::~RicControlMessage () 41 | { 42 | 43 | } 44 | 45 | void 46 | RicControlMessage::DecodeRicControlMessage(E2AP_PDU_t* pdu) 47 | { 48 | InitiatingMessage_t* mess = pdu->choice.initiatingMessage; 49 | auto *request = (RICcontrolRequest_t *) &mess->value.choice.RICcontrolRequest; 50 | NS_LOG_INFO (xer_fprint(stderr, &asn_DEF_RICcontrolRequest, request)); 51 | 52 | size_t count = request->protocolIEs.list.count; 53 | if (count <= 0) { 54 | NS_LOG_ERROR("[E2SM] received empty list"); 55 | return; 56 | } 57 | 58 | for (size_t i = 0; i < count; i++) 59 | { 60 | RICcontrolRequest_IEs_t *ie = request->protocolIEs.list.array [i]; 61 | switch (ie->value.present) { 62 | case RICcontrolRequest_IEs__value_PR_RICrequestID: { 63 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RICrequestID"); 64 | m_ricRequestId = ie->value.choice.RICrequestID; 65 | switch (m_ricRequestId.ricRequestorID) { 66 | case 1001: { 67 | NS_LOG_DEBUG("TS xApp message"); 68 | m_requestType = ControlMessageRequestIdType::TS; 69 | break; 70 | } 71 | case 1002: { 72 | NS_LOG_DEBUG("QoS xApp message"); 73 | m_requestType = ControlMessageRequestIdType::QoS; 74 | break; 75 | } 76 | } 77 | break; 78 | } 79 | case RICcontrolRequest_IEs__value_PR_RANfunctionID: { 80 | m_ranFunctionId = ie->value.choice.RANfunctionID; 81 | 82 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RANfunctionID"); 83 | break; 84 | } 85 | case RICcontrolRequest_IEs__value_PR_RICcallProcessID: { 86 | m_ricCallProcessId = ie->value.choice.RICcallProcessID; 87 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RICcallProcessID"); 88 | break; 89 | } 90 | case RICcontrolRequest_IEs__value_PR_RICcontrolHeader: { 91 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RICcontrolHeader"); 92 | // xer_fprint(stderr, &asn_DEF_RICcontrolHeader, &ie->value.choice.RICcontrolHeader); 93 | 94 | auto *e2smControlHeader = (E2SM_RC_ControlHeader_t *) calloc(1, 95 | sizeof(E2SM_RC_ControlHeader_t)); 96 | ASN_STRUCT_RESET(asn_DEF_E2SM_RC_ControlHeader, e2smControlHeader); 97 | asn_decode (nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_RC_ControlHeader, 98 | (void **) &e2smControlHeader, ie->value.choice.RICcontrolHeader.buf, 99 | ie->value.choice.RICcontrolHeader.size); 100 | 101 | NS_LOG_INFO (xer_fprint (stderr, &asn_DEF_E2SM_RC_ControlHeader, e2smControlHeader)); 102 | if (e2smControlHeader->present == E2SM_RC_ControlHeader_PR_controlHeader_Format1) { 103 | m_e2SmRcControlHeaderFormat1 = e2smControlHeader->choice.controlHeader_Format1; 104 | //m_e2SmRcControlHeaderFormat1->ric_ControlAction_ID; 105 | //m_e2SmRcControlHeaderFormat1->ric_ControlStyle_Type; 106 | //m_e2SmRcControlHeaderFormat1->ueId; 107 | } else { 108 | NS_LOG_DEBUG("[E2SM] Error in checking format of E2SM Control Header"); 109 | } 110 | break; 111 | } 112 | case RICcontrolRequest_IEs__value_PR_RICcontrolMessage: { 113 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RICcontrolMessage"); 114 | // xer_fprint(stderr, &asn_DEF_RICcontrolMessage, &ie->value.choice.RICcontrolMessage); 115 | 116 | auto *e2SmControlMessage = (E2SM_RC_ControlMessage_t *) calloc(1, 117 | sizeof(E2SM_RC_ControlMessage_t)); 118 | ASN_STRUCT_RESET(asn_DEF_E2SM_RC_ControlMessage, e2SmControlMessage); 119 | 120 | asn_decode (nullptr, ATS_ALIGNED_BASIC_PER, &asn_DEF_E2SM_RC_ControlMessage, 121 | (void **) &e2SmControlMessage, ie->value.choice.RICcontrolMessage.buf, 122 | ie->value.choice.RICcontrolMessage.size); 123 | 124 | NS_LOG_INFO (xer_fprint(stderr, &asn_DEF_E2SM_RC_ControlMessage, e2SmControlMessage)); 125 | 126 | if (e2SmControlMessage->present == E2SM_RC_ControlMessage_PR_controlMessage_Format1) 127 | { 128 | NS_LOG_DEBUG ("[E2SM] E2SM_RC_ControlMessage_PR_controlMessage_Format1"); 129 | E2SM_RC_ControlMessage_Format1_t *e2SmRcControlMessageFormat1 = 130 | e2SmControlMessage->choice.controlMessage_Format1; 131 | m_valuesExtracted = 132 | ExtractRANParametersFromControlMessage (e2SmRcControlMessageFormat1); 133 | if (m_requestType == ControlMessageRequestIdType::TS) 134 | { 135 | // Get and parse the secondaty cell id according to 3GPP TS 38.473, Section 9.2.2.1 136 | for (RANParameterItem item : m_valuesExtracted) 137 | { 138 | if (item.m_valueType == RANParameterItem::ValueType::OctectString) 139 | { 140 | // First 3 digits are the PLMNID (always 111), last digit is CellId 141 | std::string cgi = item.m_valueStr->DecodeContent (); 142 | NS_LOG_INFO ("Decoded CGI value is: " << cgi); 143 | m_secondaryCellId = cgi.back(); 144 | } 145 | } 146 | } 147 | } 148 | else 149 | { 150 | NS_LOG_DEBUG("[E2SM] Error in checking format of E2SM Control Message"); 151 | } 152 | break; 153 | } 154 | case RICcontrolRequest_IEs__value_PR_RICcontrolAckRequest: { 155 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_RICcontrolAckRequest"); 156 | 157 | switch (ie->value.choice.RICcontrolAckRequest) { 158 | case RICcontrolAckRequest_noAck: { 159 | NS_LOG_DEBUG("[E2SM] RIC Control ack value: NO ACK"); 160 | break; 161 | } 162 | case RICcontrolAckRequest_ack: { 163 | NS_LOG_DEBUG("[E2SM] RIC Control ack value: ACK"); 164 | break; 165 | } 166 | case RICcontrolAckRequest_nAck: { 167 | NS_LOG_DEBUG("[E2SM] RIC Control ack value: NACK"); 168 | break; 169 | } 170 | default: { 171 | NS_LOG_DEBUG("[E2SM] RIC Control ack value unknown"); 172 | break; 173 | } 174 | } 175 | break; 176 | } 177 | case RICcontrolRequest_IEs__value_PR_NOTHING: { 178 | NS_LOG_DEBUG("[E2SM] RICcontrolRequest_IEs__value_PR_NOTHING"); 179 | NS_LOG_DEBUG("[E2SM] Nothing"); 180 | break; 181 | } 182 | default: { 183 | NS_LOG_DEBUG("[E2SM] RIC Control value unknown"); 184 | break; 185 | } 186 | } 187 | } 188 | 189 | NS_LOG_INFO ("End of DecodeRicControlMessage"); 190 | } 191 | 192 | std::string 193 | RicControlMessage::GetSecondaryCellIdHO () 194 | { 195 | return m_secondaryCellId; 196 | } 197 | 198 | std::vector 199 | RicControlMessage::ExtractRANParametersFromControlMessage ( 200 | E2SM_RC_ControlMessage_Format1_t *e2SmRcControlMessageFormat1) 201 | { 202 | std::vector ranParameterList; 203 | int count = e2SmRcControlMessageFormat1->ranParameters_List->list.count; 204 | for (int i = 0; i < count; i++) 205 | { 206 | RANParameter_Item_t *ranParameterItem = 207 | e2SmRcControlMessageFormat1->ranParameters_List->list.array[i]; 208 | for (RANParameterItem extractedParameter : 209 | RANParameterItem::ExtractRANParametersFromRANParameter (ranParameterItem)) 210 | { 211 | ranParameterList.push_back (extractedParameter); 212 | } 213 | } 214 | 215 | return ranParameterList; 216 | } 217 | 218 | } // namespace ns3 219 | -------------------------------------------------------------------------------- /model/ric-control-message.h: -------------------------------------------------------------------------------- 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 2 | /* 3 | * Copyright (c) 2022 Northeastern University 4 | * Copyright (c) 2022 Sapienza, University of Rome 5 | * Copyright (c) 2022 University of Padova 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License version 2 as 9 | * published by the Free Software Foundation; 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this program; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author: Andrea Lacava 21 | * Tommaso Zugno 22 | * Michele Polese 23 | */ 24 | 25 | #ifndef RIC_CONTROL_MESSAGE_H 26 | #define RIC_CONTROL_MESSAGE_H 27 | 28 | #include "ns3/object.h" 29 | #include 30 | 31 | extern "C" { 32 | #include "E2AP-PDU.h" 33 | #include "E2SM-RC-ControlHeader.h" 34 | #include "E2SM-RC-ControlMessage.h" 35 | #include "E2SM-RC-ControlHeader-Format1.h" 36 | #include "E2SM-RC-ControlMessage-Format1.h" 37 | #include "RICcontrolRequest.h" 38 | #include "ProtocolIE-Field.h" 39 | #include "InitiatingMessage.h" 40 | #include "CellGlobalID.h" 41 | #include "NRCGI.h" 42 | } 43 | 44 | namespace ns3 { 45 | 46 | class RicControlMessage : public SimpleRefCount 47 | { 48 | public: 49 | enum ControlMessageRequestIdType { TS = 1001, QoS = 1002 }; 50 | RicControlMessage (E2AP_PDU_t *pdu); 51 | ~RicControlMessage (); 52 | 53 | ControlMessageRequestIdType m_requestType; 54 | 55 | static std::vector ExtractRANParametersFromControlMessage ( 56 | E2SM_RC_ControlMessage_Format1_t *e2SmRcControlMessageFormat1); 57 | 58 | std::vector m_valuesExtracted; 59 | RANfunctionID_t m_ranFunctionId; 60 | RICrequestID_t m_ricRequestId; 61 | RICcallProcessID_t m_ricCallProcessId; 62 | E2SM_RC_ControlHeader_Format1_t *m_e2SmRcControlHeaderFormat1; 63 | std::string GetSecondaryCellIdHO (); 64 | 65 | private: 66 | /** 67 | * Decodes the RIC Control message . 68 | * 69 | * \param pdu PDU passed by the RIC 70 | */ 71 | void DecodeRicControlMessage (E2AP_PDU_t *pdu); 72 | std::string m_secondaryCellId; 73 | }; 74 | } 75 | 76 | #endif /* RIC_CONTROL_MESSAGE_H */ 77 | --------------------------------------------------------------------------------