OLD | NEW |
1 .. include:: replace.txt | 1 .. include:: replace.txt |
2 .. highlight:: cpp | 2 .. highlight:: cpp |
3 | 3 |
4 Conceptual Overview | 4 Conceptual Overview |
5 ------------------- | 5 ------------------- |
6 | 6 |
7 The first thing we need to do before actually starting to look at or write | 7 The first thing we need to do before actually starting to look at or write |
8 |ns3| code is to explain a few core concepts and abstractions in the | 8 |ns3| code is to explain a few core concepts and abstractions in the |
9 system. Much of this may appear transparently obvious to some, but we | 9 system. Much of this may appear transparently obvious to some, but we |
10 recommend taking the time to read through this section just to ensure you | 10 recommend taking the time to read through this section just to ensure you |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 | 333 |
334 int | 334 int |
335 main (int argc, char *argv[]) | 335 main (int argc, char *argv[]) |
336 { | 336 { |
337 | 337 |
338 This is just the declaration of the main function of your program (script). | 338 This is just the declaration of the main function of your program (script). |
339 Just as in any C++ program, you need to define a main function that will be· | 339 Just as in any C++ program, you need to define a main function that will be· |
340 the first function run. There is nothing at all special here. Your· | 340 the first function run. There is nothing at all special here. Your· |
341 |ns3| script is just a C++ program. | 341 |ns3| script is just a C++ program. |
342 | 342 |
| 343 The next line sets the time resolution to one nanosecond, which happens |
| 344 to be the default value: |
| 345 |
| 346 :: |
| 347 |
| 348 Time::SetResolution (Time::NS); |
| 349 |
| 350 The resolution is the smallest time value that can be represented (as well as |
| 351 the smallest representable difference between two time values). |
| 352 You can change the resolution exactly once. The mechanism enabling this |
| 353 flexibility is somewhat memory hungry, so once the resolution has been |
| 354 set explicitly we release the memory, preventing further updates. (If |
| 355 you don't set the resolution explicitly, it will default to one nanosecond, |
| 356 and the memory will be released when the simulation starts.) |
| 357 |
343 The next two lines of the script are used to enable two logging components that | 358 The next two lines of the script are used to enable two logging components that |
344 are built into the Echo Client and Echo Server applications: | 359 are built into the Echo Client and Echo Server applications: |
345 | 360 |
346 :: | 361 :: |
347 | 362 |
348 LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); | 363 LogComponentEnable("UdpEchoClientApplication", LOG_LEVEL_INFO); |
349 LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); | 364 LogComponentEnable("UdpEchoServerApplication", LOG_LEVEL_INFO); |
350 | 365 |
351 If you have read over the Logging component documentation you will have seen | 366 If you have read over the Logging component documentation you will have seen |
352 that there are a number of levels of logging verbosity/detail that you can· | 367 that there are a number of levels of logging verbosity/detail that you can· |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 link to the right of the directory name. If you click on the ``src`` | 848 link to the right of the directory name. If you click on the ``src`` |
834 directory, you will be taken to the listing of the ``src`` subdirectories. If y
ou· | 849 directory, you will be taken to the listing of the ``src`` subdirectories. If y
ou· |
835 then click on ``core`` subdirectory, you will find a list of files. The first f
ile | 850 then click on ``core`` subdirectory, you will find a list of files. The first f
ile |
836 you will find (as of this writing) is ``abort.h``. If you click on the· | 851 you will find (as of this writing) is ``abort.h``. If you click on the· |
837 ``abort.h`` link, you will be sent to the source file for ``abort.h`` which· | 852 ``abort.h`` link, you will be sent to the source file for ``abort.h`` which· |
838 contains useful macros for exiting scripts if abnormal conditions are detected. | 853 contains useful macros for exiting scripts if abnormal conditions are detected. |
839 | 854 |
840 The source code for the helpers we have used in this chapter can be found in the······· | 855 The source code for the helpers we have used in this chapter can be found in the······· |
841 ``src/applications/helper`` directory. Feel free to poke around in the director
y tree to | 856 ``src/applications/helper`` directory. Feel free to poke around in the director
y tree to |
842 get a feel for what is there and the style of |ns3| programs. | 857 get a feel for what is there and the style of |ns3| programs. |
OLD | NEW |