You are on page 1of 36

370

1503

Debugging Simulation Models — Advanced

CONFIDENTIAL — RESTRICTED ACCESS:
This information may not be disclosed, copied, or transmitted in any format without the prior written consent of OPNET Technologies, Inc.
© 2010 OPNET Technologies, Inc.

1503 Debugging Simulation Models — Advanced

Debugging Simulation Models (Advanced) Lab
Overview
Welcome to the Debugging Simulation Models — Advanced lab. The purpose of this lab is to show
you how to use the C/C++ source code debugger to debug OPNET simulations. A source code
debugger can be helpful in diagnosing problems with OPNET simulations. After following these
exercises, you should be able to use a C/C++ source code debugger in debugging any OPNET
simulation.

Labs

Using a C/C++ debugger to catch a simulation abort

Using a C/C++ debugger and ODB – Advanced

Using execution trace to validate changes

Using advanced memory tracking features

Note

To run the labs involving the C/C++ debugger, you must install the Debugging Tools for
Windows suite found on Microsoft’s web site:
http://www.microsoft.com/whdc/devtools/debugging/installx86.mspx. The version used for
these labs is 6.12.2.633.

To run Lab 2 you need to install the Windiff utility on the machine where OPNET Modeler
is installed.

To successfully run these Labs, you need to update your preference file by adding the full
path to the cdb.exe file and to the windiff.exe file. For example, on a 32-bit machine you
could add the following entries:

des.windows_32bit_debugger_executable_path: "C:\\Program Files\\Debugging Tools for
Windows\\cdb.exe"
mdiff_diff_prog

: "C:\\Program Files\\Microsoft Platform SDK\\Bin\\WinDiff.Exe"

CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed, copied, or transmitted in any format without the prior written consent of OPNET Technologies, Inc.
© 2010 OPNET Technologies, Inc.

1

Choose Help > Error Log > Open. Switch to scenario lab1 (choose Scenarios > Switch To Scenario > lab1). Inc. Run the simulation (Ctrl+Shift+R or choose DES > Run Discrete Event Simulation). CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies.prj. Select 1503. 2. Run OPNET Modeler® and choose File > Open. or transmitted in any format without the prior written consent of OPNET Technologies. Observe program abort. b. 2.1503 Debugging Simulation Models — Advanced Lab 1: Using a C/C++ Debugger to Catch a Simulation Abort Overview This lab will show you how to use a C/C++ debugger to diagnose a simulation abort. Scroll up to the function call stack for the program abort. 4. 3. copied. Inc. Note the process model name and state. 2 . Run Simulation up to the Abort 1. View Call Stack and Code 1. 5. Also note the block line number. a.

CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Go to process model gna_clsvr_mgr_1503_lab1. It is likely that sess_ptr pointer is not valid. Inc. Examine the program block for possible causes of the problem. c. 5. Open process model gna_clsvr_mgr_1503_lab1. 7. 6. Inc.1503 Debugging Simulation Models — Advanced 3. Invalid memory access often means an invalid pointer. 8. Return to the OPNET Modeler window. © 2010 OPNET Technologies. Preparing a Simulation for Debugging 1. Open the function block and find line 3707. Close the function block by clicking on the X in the upper-right corner of the window. a. d. Choose Compile > Compile Code (Advanced). 4. 3 . Set the compilation flags to include debugging information. or transmitted in any format without the prior written consent of OPNET Technologies. copied. b. Click Cancel. Note that correct debug compilation flags are set for the development kernel.

Inc. click on the Detailed… button. Re-Run Simulation with Debugger 1. copied. Open the Configure/Run DES dialog box. 4 . © 2010 OPNET Technologies. If you see the following dialog. to bring up the advanced version of the Configure/Run DES dialog CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. 2. or transmitted in any format without the prior written consent of OPNET Technologies.1503 Debugging Simulation Models — Advanced 2. Recompile the process model. Inc.

5 . or transmitted in any format without the prior written consent of OPNET Technologies. copied. and make sure the Simulation Kernel menu is set to development or Based on ‘kernel_type’ preference if the preference is set to development. Inc. Or CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. Inc.1503 Debugging Simulation Models — Advanced 3. Select the Common tree view item.

select Simulation > Attach Windows Debugger (CDB). 6 . 5. Inc. Click on the Run button in the lower-right. Inc. copied. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. When the Simulation Execution dialog comes up.1503 Debugging Simulation Models — Advanced 4. or transmitted in any format without the prior written consent of OPNET Technologies.

7 . Inc. Observe the following: • Source code of the current function is loaded. © 2010 OPNET Technologies. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. • An arrow points to the source code at the line of the abort • You can see the value of sess_ptr in the Local and State Variables tab at the bottom of the window (you may need to scroll down to see the variable). or transmitted in any format without the prior written consent of OPNET Technologies. copied.1503 Debugging Simulation Models — Advanced 6. Inc. Find and Fix the Problem 1. the debugger will automatically bring you to the error. When the abort occurs. 7. Click Continue.

i--) 7. Thus correct backward list iteration should start from session_list_size-1 and continue until i is non-negative. Select Simulation > Detach Windows Debugger (CDB). Recompile the process model. Indeed. so further investigation will focus on how the variable got the bad value. or transmitted in any format without the prior written consent of OPNET Technologies. which has an invalid value (NIL). starting at the sess_list_size position. Close Simulation Execution dialog. 5. 2. but list position indexes start at 0.1503 Debugging Simulation Models — Advanced We conclude that the cause of the abort is the use of the variable sess_ptr. The value is taken from the state variable sess_list. Hit Continue if you’re at the ODB> prompt. 3. A recoverable error about invalid list index. Inc. Open the function block. copied. 8. 10. the for loop where crash occurred traverses the list backwards. 11. 8 . Correct the for loop bounds at the line 3706: for (i = sess_list_size-1. which was issued immediately before the crash. hints that there may be something wrong with the list iteration logic. Inc. 6. End of Lab 1 CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. 4. i >= 0. 9. Return to the Project Editor (the 1503-lab1 window). © 2010 OPNET Technologies. Return to the process model: select the gna_clsvr_mgr_1503_lab1 window. Observe that the simulation runs to completion. Close and save your changes. Run the simulation.

copied. • Also note the block line number. In this lab. 3. Run the simulation. © 2010 OPNET Technologies. Using the information gained from the error message. Run Simulation and Examine Problem 1. we will observe a number of recoverable errors involving the use of an invalid statistic handle. 9 . • Note that the error occurred at event 4995. or transmitted in any format without the prior written consent of OPNET Technologies. 6.Campus. Observe a number of recoverable errors. we will see (by stepping through the CDB debugger) where the bug occurs.1503 Debugging Simulation Models — Advanced Lab 2: Using a C/C++ Debugger and ODB — Advanced Overview This lab shows you how to use a C/C++ debugger in concert with the OPNET debugger (ODB). 5. Return to the 1503 window in the Project Editor. we will run the OPNET debugger and attach the CDB debugger to the simulation process. Select scenario lab2. We will start by analyzing the first error message and extracting some useful information from the error message.mac". Open the error log (choose Help > Error Log > Open). Observation: All errors are reported by one particular module "top. 2. we will then run the simulation up to the event of the error. Inc. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. 4. Scroll up and view the function call stack for the first error encountered: • Note the process model name and state. Inc. Next.This Workstation Does Some Web Browsing And Maybe Something Else Too. The techniques demonstrated in this lab are useful for debugging most simulation model problems.

7. Open process model ethernet_mac_v2_1503_lab2. one of questionable statistic handles in the same function block. Observe 4 op_stat_write () calls in that block: Conclusion: At least one of statistic handle does not seem to be initialized correctly for a given process instance. Let's find a piece of code where those statistic handles are initialized. © 2010 OPNET Technologies. Inc. which is the block line number reported in the error log. Inc. 8. Open the function block and scroll to line 592. Search reveals that all relevant statistic handles seem to be properly initialized in function ethernet_mac_stat_init2 (). 12. 10 . Search for global_ete_handle. or transmitted in any format without the prior written consent of OPNET Technologies. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. copied. 9. 10. Return to the OPNET Modeler window.1503 Debugging Simulation Models — Advanced At this point. we will take a look at the code where the error message occurred: the call to op_stat_write() in the ethernet_mac_phys_pk_accept function called from ethernet_mac_v2_1503_lab2 process model. 11.

11 . copied. or transmitted in any format without the prior written consent of OPNET Technologies. 19. An ODB Console will appear. Run the simulation (click on the Run button). Type "bp ethernet_mac_stat_init2" in the CDB: prompt area. Return to 1503 project window. 15. To configure the simulation to run ODB. 16. open the Configure/Run DES dialog box. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Inc. Check the Use OPNET Simulation Debugger (ODB)… checkbox. 18. 17. Select Execution > OPNET Debugger in the tree view. To set a source breakpoint in function ethernet_mac_stat_init2at CDB: a. To check this hypothesis lets use the source level debugger to see if that function is actually called. 13. Select Simulation > Attach Windows Debugger (CDB) 20.1503 Debugging Simulation Models — Advanced Hypothesis 1: ethernet_mac_stat_init2 () is not called. 14. © 2010 OPNET Technologies. Inc.

copied. © 2010 OPNET Technologies.This Workstation Does Some Web Browsing And Maybe Something Else Too. or transmitted in any format without the prior written consent of OPNET Technologies. First let’s deactivate the breakpoint that was set in ethernet_mac_stat_init2 (). 25. From the object tree observe that the object id of the module in question is 14481. 12 . Inc. Note that your new breakpoint has been recorded. Right-click on the breakpoint's diamond in the source view and choose "Delete Breakpoint". Switch to the Source Breakpoints tab at the bottom of the debugger window.mac" module. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Click the Continue button. Conclusion: Hypothesis 1 failed. Hypothesis 2: ethernet_mac_stat_init2 () is not called for a specific instance of the process model that is running inside of "top.1503 Debugging Simulation Models — Advanced b. 21. 24. 22. Simulation stops when it hits the breakpoint set in ethernet_mac_stat_init2. 23. Inc.Campus. To verify this hypothesis lets set a Conditional breakpoint that is trapped in the specific instance of the module. Observe that one of mac process state variables contains the parent module object id.

Inc. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed.pr. Inc.1503 Debugging Simulation Models — Advanced 26.c source file that is triggered when my_objid state variable value is 14481. CDB syntax for that is: WARNING: Be very careful when choosing the correct quote marks for the above command. 13 . Let’s set a breakpoint at line 770 of the ethernet_mac_v2_1503_lab2. © 2010 OPNET Technologies. copied. or transmitted in any format without the prior written consent of OPNET Technologies.

14 . • The ‘ quote around the gc and before the .pr. Inc. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. copied.1503 Debugging Simulation Models — Advanced • The ` quote before the ethernet_ and after the :770 is a back quote (or grave accent) (found in the upper-left part of your keyboard).txt. • The entire command spelled out character-by-character: o bp<space> o <backquote> o ethernet_mac_v2. You can verify that my_objid state variable value in the Local and State Variables panel is indeed 14481. • The “ quote before the j @@c++ and after the ‘gc’ is a double-quote (found near the enter key). © 2010 OPNET Technologies. Click the Continue button and observe that execution stopped at the breakpoint that we just set. Inc. 27. or transmitted in any format without the prior written consent of OPNET Technologies.c:770 o <backquote> o <space><double-quote> o j @@c++(op_sv_ptr->my_objid == 14481) o <single-quote><single-quote><semi-colon> o <single-quote> o gc o <single-quote> o <double-quote> • The command itself is also in the file c:\op_models\lab2_conditional_breakpoint_command. are single-quotes (same key as the doublequote). You can copy and paste the command from the file into the debugger.

CDB's "dt -b op_sv_ptr" will print the value of the op_sv_ptr pointer and offsets from that address to all structure members.validation value changes. or transmitted in any format without the prior written consent of OPNET Technologies. but something later incorrectly modifies the memory that contains the statistic references. Inc. Hypothesis 3. 28. 29. Inc. © 2010 OPNET Technologies. Statistic handles are initialized correctly. Let’s set a watch point that is triggered when global_ete_handle.1503 Debugging Simulation Models — Advanced Conclusion: Hypothesis 2 failed too. 15 . First we need to determine the address of that field in memory. Remember that global_ete_handle was one of statistic handles suspected to become corrupted. Expand global_ete_handle state variable line in the Local and State Variables panel and observe that all fields are set to zero. copied. a. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. To verify this hypothesis we will use a Watchpoint: a type of breakpoint that is triggered when the value stored at particular address in memory changes.

32. Click on Continue button. . b.. This tells us that the address of global_ete_handle. copied. Observe that the watch point is trapped in seemingly unrelated code in the INIT stat enter executives CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Execution will stop at the point where the statistic is registered in the current function.1503 Debugging Simulation Models — Advanced The numbers circled in red in the image below may be different from what you see when running your simulation. 31. or transmitted in any format without the prior written consent of OPNET Technologies.. With this knowledge we can set a watchpoint for the 4 bytes of the validation field with this CDB command: ba w4 0x0284b658 +0x80+0x0c NOTE: Remember to use your numbers! 30. c. Inc.validation field in memory is op_sv_ptr value (0x0284b658 in the example above) plus global_ete_handle field offset (which is +0x080) plus the validation field offset (which is +0x0c). Inc. 16 . Click Continue button again.. © 2010 OPNET Technologies.

34. Inc.1503 Debugging Simulation Models — Advanced 33. Open the state variables block It appears that state variable my_node_name is big enough to carry up to 25 characters. or transmitted in any format without the prior written consent of OPNET Technologies. Open the ethernet_mac_v2_1503_lab2 process model. Inc. The length of node name in question (This Workstation Does Some Web Browsing And Maybe CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. 17 . copied.

Postscript Note the use of conditional breakpoints and watchpoints. Let’s fix the problem. Conditional breakpoints were used to stop at a very convenient point in the source code. This wasn’t the only way to get to that point (you could use the ODB command prostop). Open 1503 project and if simulation debugging session is still running. Much debugging time is often spent trying to find corruption that is far removed from a reported error state. Watchpoints are an excellent way to test a common hypothesis: a value becomes invalid or corrupted between a known valid state and a known invalid state. Re-run the simulation (may use Ctrl-Shift-R shortcut) and observe that no errors are reported. but it is by far the most straightforward and direct way. copied. or transmitted in any format without the prior written consent of OPNET Technologies. © 2010 OPNET Technologies. 36.1503 Debugging Simulation Models — Advanced Something Else Too) exceeds this limitation and thus name copy in the INIT state corrupts the memory of global_ete_handle field. 35. Hint: APIs that check array bounds such as strncpy () or op_ima_obj_attr_get_str () combined with dynamically allocated string may be more appropriate. compile ethernet_mac_v2_1503_lab2. 37. 18 . Inc. detach ODB and quit the simulation. Hypothesis 3 turned out to be true. Implement your change. End of Lab 2 CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Solution 2: Use your implementation. Inc. Using watchpoints saves much of this time. Solution 1: Modify the "my_node_name" to carry up to 255 characters.

Compare Simulation Results 1. Repeat the procedure for lab3_2 scenario and click OK. Choose "Scenarios->Manage Scenarios". b. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. "New and improved" model is implemented in the scenario lab3_2.1503 Debugging Simulation Models — Advanced Lab 3: Using Execution Trace to Validate Changes Overview This lab introduces the "execution trace": An OPNET simulation kernel feature that allows us to efficiently find the point where two simulations diverge. copied. Left-click in the Results column for the lab3_1 scenario row and choose the <collect> option (or the <recollect> option if results for the scenario already exist). 19 . c. Run simulations for both scenarios a. We found this functionality to be particularly useful for validation of model changes and optimizations. Here is the setup: A creative model developer implemented certain model improvements before leaving for a long vacation on a remote island. © 2010 OPNET Technologies. 2. This scenario contains the original (reference) model. Your job is to see if the changes affect the model correctness and to resolve any issues if found. Project's scenario management dialog appears. Inc. Open 1503 project and switch to lab3_1 scenario. or transmitted in any format without the prior written consent of OPNET Technologies. Inc.

or transmitted in any format without the prior written consent of OPNET Technologies. "DES Execution Manager" window will appear.1503 Debugging Simulation Models — Advanced d. Compare simulation results: a. Select results for both lab3_1 and lab3_2. Click on the View Results button in the project toolbar. 20 . CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. b. c. © 2010 OPNET Technologies. Inc. Choose to view results for the Current Project. You can check the progress of simulations by clicking on the "View Details" button for a particular run. Inc. copied. 3.

Collect the execution trace of the reference scenario: a. c. copied. Pick Global Statistics->Ftp->Download Response Time (sec) statistic and set Presentation style to Overlaid Statistics. Find the Cause of a Difference 4.1503 Debugging Simulation Models — Advanced d. © 2010 OPNET Technologies. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Conclusion: Results from the simulation of the modified model do not match the reference. b. Inc. Open Configure/Run DES dialog and navigate to Execution->Advanced>Application panel. Type -etrace_dump c:\ref_etrace in the Additional command line arguments field. Inc. 21 . or transmitted in any format without the prior written consent of OPNET Technologies. Switch to lab3_1 scenario.

Switch to lab3_2 scenario. 6. NOTE: This time the option is "-etrace_diff". Run simulation to capture the reference execution trace in c:\ref_trace file. Type -etrace_diff c:\ref_etrace in the Additional command line arguments field. Inc. Open Configure/Run DES dialog and navigate to Execution->Advanced>Application panel. c. Run simulation and once it quickly completes click Simulation Console button. © 2010 OPNET Technologies. e. Compare execution trace of the modified scenario: a. Scroll down to the bottom and observe report of detected simulation execution discrepancy: Observation: Simulation execution pattern was identical until event #12399. Next step is to capture the detailed trace of activity during this event to see where execution diverges. Capture full trace of event #12399 execution: CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. or transmitted in any format without the prior written consent of OPNET Technologies. not collecting it. Inc. d. not "-etrace_dump" as we are now comparing execution pattern against the original. 5.1503 Debugging Simulation Models — Advanced d. copied. 22 . b.

copied. This will set the breakpoint at the event of interest • "c" and hit Enter. At ODB prompt type: • "evst #12399" and hit Enter. c. Hit Ctrl-R to open simulation configuration dialog and turn on ODB in Execution>OPNET Debugger panel. Choose Simulation->Save Console.1503 Debugging Simulation Models — Advanced a. Switch to lab3_1 scenario. 23 .. Inc.. b. d. Inc. menu command and save the console content in C:\trace1 file. Click Run. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. This will turn on the full trace • "n" and hit Enter. or transmitted in any format without the prior written consent of OPNET Technologies. This will run the simulation until the above set breakpoint • "f" and hit Enter. This will stop at the next simulation event after producing the full trace of execution of the event # 12399 e.

copied. c. Scroll through the differences ignoring differences in used model names and pointers until you see a difference in computed service time. Inc. Select C:\trace2 and click Open. Choose File->Compare Files. Select C:\trace1 and click Open. © 2010 OPNET Technologies. 24 . g.1503 Debugging Simulation Models — Advanced f.. f.. Switch to scenario lab3_2 and repeat steps b through e this time saving the console trace into C:\trace2. Click on Expand button... Inc. 7. e. d. Type windiff at the prompt and click OK. Compare captured traces: a. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Another file chooser will reappear. Choose Run. or transmitted in any format without the prior written consent of OPNET Technologies. b. from the Windows Start menu.

or transmitted in any format without the prior written consent of OPNET Technologies. © 2010 OPNET Technologies. 8. Observe odd-looking asymmetry in service_time computations between lines 2147 and 2155. This is the process model used by scenario lab3_2. Open gna_clsvr_mgr_1503_lab3 process model. 10. Open Function Block and search for gna_clsvr_mgr_service_time_compute function definition. 25 . Inc.1503 Debugging Simulation Models — Advanced Observation: Function gna_clsvr_mgr_service_time_compute() produced different result. Inc. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. 9. copied.

Inc. you can confirm by looking at the gna_clsvr_mgr_1503_orig process model. To fix the discrepancy.1503 Debugging Simulation Models — Advanced 11. or transmitted in any format without the prior written consent of OPNET Technologies. 12. Indeed. Save and Compile fixed gna_clsvr_mgr_1503_lab3 process model. Postscript Using Execution Trace coupled with ODB tracing we were able to easily track down a problem in the modified model code without much knowledge about the nature of the model code modification or much knowledge about the model code in general. Inc. End of Lab 3 CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. copied. where response_size is specified in bits. 26 . 13. 14. modify line 2147 to divide the response_size by the processing_speed multiplied by 8. Rerun lab3_1 and lab3_2 scenarios without ODB and observe that simulation now produce identical results and execution trace reports no differences. processing_speed is specified in bytes per second.

2. Notice the rapidly increasing memory usage. Click the Memory Usage tab in the Simulation Sequence dialog box. 5. Open the Configure/Run DES dialog box. if currently checked. Go back to project 1503 and switch to scenario lab4. Inc. 4. © 2010 OPNET Technologies. Pause the simulation after the Elapsed time shows 15s.1503 Debugging Simulation Models — Advanced Lab 4: Using Advanced Memory Tracking Features Overview This lab introduces advanced memory tracking features that can be used to track down memory leaks. copied. 27 . Run Simulation and Observe Memory Usage 1. Inc. 6. Select Execution > OPNET Debugger in the tree view and uncheck the Use OPNET Simulation Debugger (ODB) checkbox. or transmitted in any format without the prior written consent of OPNET Technologies. 3. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Run the simulation.

8. copied. or transmitted in any format without the prior written consent of OPNET Technologies. 28 . Inc. Click on the Get Latest Data button. 9. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. Click on the Use (KB) column header. 11. Click the Memory Stats tab. © 2010 OPNET Technologies. De-select the OPNET Kernel checkbox in the lower-right corner. Note that packet-related items are at the top of the list. 10. Inc.1503 Debugging Simulation Models — Advanced 7.

Resume the simulation. 29 . Inc. Open the Configure/Run DES dialog box. or transmitted in any format without the prior written consent of OPNET Technologies. Click Close to close the dialog. can we discover which module—even which function—is responsible for the packet build-up? Collect More Information about Packet Allocation 1. Stop the simulation by clicking the Stop button. copied. Check the Show differences checkbox. Inc. Conclusion: The system generates packets. The table should now look something like this: 13. but they are not being destroyed when they should be. then click on the Pause and Get Latest Data button again. Note that the Memory Stats table helpfully shows you that ams_atm_cell packet related memory use is on the rise.1503 Debugging Simulation Models — Advanced 12. Question: Although it seems obvious that ATM cells are the packets that are building up. wait a few more seconds. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. © 2010 OPNET Technologies. 2. This creates a packet build-up.

1503 Debugging Simulation Models — Advanced 3. 4. Inc. © 2010 OPNET Technologies. Select the Generate memory source tracing information (Only available with the sequential development kernel) checkbox. 5. Click in the top row of the text entry field and type the word Packet (then hit Enter). 7. and then hit Pause. or transmitted in any format without the prior written consent of OPNET Technologies. 2. Select the Only for specific memory categories radio button. Inc. Select Runtime Displays > Memory Usage in the tree view. Click Run. View Source of Leaked Packets 1. Let the simulation run for about 20-30 seconds. 6. Click on the Update button. Click on the Memory Sources tab in the Simulation Sequence dialog box. 30 . 3. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. copied.

or transmitted in any format without the prior written consent of OPNET Technologies. but perhaps they are not being destroyed when receiving packets that are to be passed to the AAL layer. Inc. Notice that one function—ams_aal_disp_v3()—seems responsible for most of the packet build-up. Inc. 31 . © 2010 OPNET Technologies. and finding out if packets are being destroyed before being sent to the AAL layer. In other words. Let’s check our hypothesis by looking at the FTP server. Note that most of the packets outstanding were allocated in the enter execs of the conn irpt state. copied. Conclusion: Packets are being leaked at the ATM layer.1503 Debugging Simulation Models — Advanced 4. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. it appears that ATM cells are being created.

we expect ATM cells to be destroyed after AAL packets are decapsulated. That process is likely responsible for the leak. Capture full trace of the event and gather IDs of created packets. This information is sufficient to trace any one of the leaked packet using ODB event and packet tracing. Double-click on the enter execs of the to AAL state. Investigation revealed that bulk of packets seemed to be last processed by the "to AAL" state's enter executives of the ams_atam_layer_v3_1503_lab4 process model. In a little while a table showing all memory blocks that were allocated from the specified function will appear. b. Trace created packets (pktrace ODB command) to see which module / process accessed packets last. 5. Inc. Double-click on one of Voice Stn nodes in the project editor. but here is the brief outline of the procedure: a. Inc. 32 . c. 4. Find (Ctrl+F) instances of op_pk_send(). or transmitted in any format without the prior written consent of OPNET Technologies. Double-click on the ATM_layer module. In this state. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed. We will leave this as an optional exercise. 6. copied. 8. 2. 7. 3.1503 Debugging Simulation Models — Advanced Find and Fix the Problem 1. The most likely place we can expect a call to op_pk_destroy() is right before or after an op_pk_send_…() call. Set the breakpoint at leaked packet creation event. Right click on the top ams_aal_disp_v3 entry and select Show Details. © 2010 OPNET Technologies.

Re-compile the process model.. 33 .. Inc. or transmitted in any format without the prior written consent of OPNET Technologies. copied. Inc. 11. © 2010 OPNET Technologies. Remove #if DEBUGGING_SOMETHING and #endif statements. Note the problem (failure to destroy the ATM cell). Somebody forgot to remove debugging statements. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed.1503 Debugging Simulation Models — Advanced 9. 10.

The techniques shown in these labs are sufficient for the vast majority of debugging problems and will serve you well for any process modeling project you will see in the future. In the end. For anyone who develops process models. It will enable you to save time debugging any type of problem that comes your way. the better chance you have in fixing it. Inc. Postscript Using the new simulation memory tracking features can be very useful in tracking down memory leaks. © 2010 OPNET Technologies. Note the decrease in memory usage. CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed.1503 Debugging Simulation Models — Advanced 12. copied. keep in mind that the more knowledge you have about an OPNET model. End of Lab 4 Summary Congratulations! You now should be comfortable debugging simulation models in OPNET using a C/C++ source code debugger. or transmitted in any format without the prior written consent of OPNET Technologies. this is a valuable skill to have. 34 . Inc. Go to the Project Editor and re-run simulation (Ctrl+Shift+R). However. techniques take a back seat to model knowledge.