debugging
Post on 02-Dec-2014
458 Views
Preview:
TRANSCRIPT
Presentation Title Subtitle
Author
OPNET Technologies, Inc.
Copyright © 2000 OPNET Technologies, Inc.
Title – 1
TM OPNET UNIVERSITY
2000
Debugging Simulation Models --Introduction
Copyright © 2000 OPNET Technologies, Inc.
Title – 2
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 2
Goals
•Develop a sensible approach to debugging
•Teach use of OPNET Debugger (ODB)
• How to debug models
• Review features and commands
•Discuss the debugging process
• Step-by step methods for debugging models
Copyright © 2000 OPNET Technologies, Inc.
Title – 3
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 3
Items Not Covered
•Will not cover…
• C programming
• Segmentation violation
• Bus error
• These topics are covered in the session Debugging Simulation Models – Advanced.
Copyright © 2000 OPNET Technologies, Inc.
Title – 4
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 4
Prerequisites
• Familiarity with
• OPNET Modeler model hierarchy
• Creating process models
• Running simulations
Copyright © 2000 OPNET Technologies, Inc.
Title – 5
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 5
Agenda
• Interpreting error messages
• Identifying the problem
•Using the OPNET Debugger (ODB)
•Viewing animation for debugging
Copyright © 2000 OPNET Technologies, Inc.
Title – 6
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 6
The Challenge
• Debugging is like finding a needle in a haystack
• Narrow down the problem
• Time (event number)
• Space (code segment)
• Different types of problems
Structural Simulation fails to execute successfully.
Illustrated in Lab 1
Behavioral Simulation completes successfully, but does not accurately represent the modeler‟s intent.
Illustrated in Lab 2
Copyright © 2000 OPNET Technologies, Inc.
Title – 7
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 7
Object Reference
• Objects can be identified in two ways
• Object ID: Unique integer identifying object
• Object Name: Hierarchical name of object:
Format: <subnet name(s)>.<node name>.<module name>
top.e_campus.bldg_10.router.in_queue
<subnet name(s)> top.e_campus.bldg_10
<node name> router
<module name> in_queue
Copyright © 2000 OPNET Technologies, Inc.
Title – 8
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 8
Simulation Log
• Records notable events for every scenario
• Recreated every time a scenario‟s simulation is run
• Describes problems
• Suggests solutions
• Gives informational messages
Copyright © 2000 OPNET Technologies, Inc.
Title – 9
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 9
Simulation Error Classifications
Program Abort
Problem that prohibits the simulation from proceeding.
Recoverable Error
Problem that does not prohibit the simulation from proceeding, but may result in cancellation of the current operation.
Diagnostic Error
Problem that is recoverable, but minor.
Only reported if the diag_enable preference is TRUE. Default value is FALSE.
Warning Message typically generated by model to identify problems within the model itself, written by model developer using op_sim_message() Kernel Procedure (KP).
Copyright © 2000 OPNET Technologies, Inc.
Title – 10
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 10
Error Message Fields
|----------------------------------------------------------------------------|
| <<< Recoverable Error >>> |
| Output stream index (1) is out-of-range. |
| T (21.4), EV (254), MOD (top.sample_net.stn_5.mac), KP (op_pk_send) |
|----------------------------------------------------------------------------|
Type Type of error
T Simulation time of error
EV Event ID of simulation event
MOD Name of module where error occurred
KP Name of Kernel Procedure that reported the problem
Messages Match in Kernel Procedure docs
Copyright © 2000 OPNET Technologies, Inc.
Title – 11
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 11
Obtaining a Function Call Stack (FCS)
• Function call stack provides the user with
• More details
• Locates error in space
• Contains function listings
•err_log file in <home>/op_admin records all FCSs
• This file will grow over time and may be periodically removed
•op_vuerr utility extracts last FCS from err_log
•-num_err attribute can be used to extract the last N errors in case the error of interest is not the most recent
• Example: op_vuerr -num_err 5
Copyright © 2000 OPNET Technologies, Inc.
Title – 12
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 12
Example Function Call Stack
<<< Program Abort >>>
. . .
* Function call stack: (builds down)
------------------------------------------------------------
Call Block
Count Line# Function
------------------------------------------------------------
0) 1 125 m3_main (argc, argv)
1) 1 519 sim_main (prog_name, argc, argv, dynamic, ...)
2) 1 935 sim_ev_loop ()
3) 1 79 sim_strm_insert ()
4) 6 477 sim_obj_qps_intrpt (simev_ptr)
5) 5 0 pksw_nd_proc () [xmt enter execs]
6) 1 60 op_pk_nfd_set (pkptr, fd_name, value, <...>)
............................................................
7) 1 1481 *sim_err_pk_access (pkptr, error_code)
8) 1 88 *sim_err_issue (pkg_id, msg_id, <subst_values>)
9) 1 339 sim_err_print (severity_level, str0, str1)
------------------------------------------------------------
Sim.
Kernel
Error
Message
Printing
Process model
and state
KP reporting
problem
Copyright © 2000 OPNET Technologies, Inc.
Title – 13
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 13
Block Line Numbers in FCS
• Block Line Numbers refer to last curly brace passed 1 int function(void)
2 {
3 int x, z;
4
5 FIN (function (void))
6 z = 0; A
7 for (x = 0; x < 10; x++)
8 {
9 printf (“z = %d\n”,z);
10 z += x; B
11 }
12 FRET (z) C
13 }
• Location A Reported block line number: 5
• Location B Reported block line number: 8
• Location C Reported block line number: 11
Copyright © 2000 OPNET Technologies, Inc.
Title – 14
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 14
Development and Optimized Kernels
• OPNET includes two different Simulation Kernels:
• Optimized Kernel
Run simulations, collect statistics
Faster
• Development Kernel
Same features as Optimized Kernel…
Plus diagnostic information automatically collected
Slower
• Development Kernel must be used for most debugging activities
• In order to see complete FCS, the process models and external files must be compiled with comp_trace_info
Copyright © 2000 OPNET Technologies, Inc.
Title – 15
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 15
Using the Development Kernel
•The kernel_type preference
• Controls which Simulation Kernel is used during a simulation
•To set kernel_type to development: • Don‟t use optimize_simulation environment file
• Command line: op_runsim -kernel_type development
• Preferences: set kernel_type to development
• Set comp_trace_info environment attribute to TRUE
• This inserts additional trace information into compiled code
• Use FIN/FOUT/FRET macros in custom functions
Copyright © 2000 OPNET Technologies, Inc.
Title – 16
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 16
OPNET Debugger (ODB)
• ODB capabilities
• Allows you to gain interactive control of the simulation
• You can issue commands to obtain detailed information about events or objects of interest
• The same events are executed in debug and non-debug sims
Copyright © 2000 OPNET Technologies, Inc.
Title – 17
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 17
ODB Features
• ODB provides commands that allow user to:
• Execute single and multiple events
• Set breakpoints for specific events, times, modules, and processes
• Trace Kernel Procedures as they are being executed
• Print out information about the current status of simulation entities
• Print out statistics of memory usage
• Affect the course of the simulation by modifying object attributes
Copyright © 2000 OPNET Technologies, Inc.
Title – 18
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 18
How to Activate / Invoke ODB
• Use the debug environment attribute to activate ODB
• To set the value of debug :
• From the Simulation Tool:
Include debug environment file
• From the command line:
Example use:
op_runsim -net_name project1-scenario1 -debug
Copyright © 2000 OPNET Technologies, Inc.
Title – 19
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 19
Invoking and Exiting ODB
• Commands can be issued at odb> prompt
• To end the simulation:
•quit - terminates the simulation normally (creates output files)
•exit - immediately exits ODB, no output file created
% op_runsim -net_name example -debug
<...simulation banner...>
______________ OPNET Simulation Debugger ____________
Type „help‟ for Command Summary
odb> Time 0, before begsim interrupts are delivered
Copyright © 2000 OPNET Technologies, Inc.
Title – 20
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 20
Getting Help in ODB
•help command is available at odb> prompt
•help: displays summary of help categories
•help <category>: displays help on specified category
•help <command>: displays help on specified command
odb> help
________________ OPNET Debugger Help ________________
There are three levels of help:
help -- displays summary of help categories.
help <category> -- display help on specified category.
help <command> -- display help on specified command.
____ Command Categories [builtin] ____
all
basic
action
...
Copyright © 2000 OPNET Technologies, Inc.
Title – 21
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 21
ODB: Lesson Plan • Breakpoints
• Traces
• Labels
• Lab 1
• Break
• Maps
• Entity Information
• Lab 2
• Diagnostic Block
• Memory Allocation
Copyright © 2000 OPNET Technologies, Inc.
Title – 22
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 22
Breakpoints • Interrupt simulation execution
• Allow the user to issue commands at the odb> prompt
• Two methods of advancing simulation execution within ODB:
• Single event execution
• Continuation of event
execution until
a breakpoint occurs
00:21
00:05
00:31
00:45
00:51
Single Event Execution
00:21
00:05
00:31
00:45
00:51
Multiple Event Execution
cont
pending
breakpoint
next
set breakpoint
00:59
next
next
next
next
set breakpoint
set breakpoint
set breakpoint
set breakpoint
Copyright © 2000 OPNET Technologies, Inc.
Title – 23
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 23
Breakpoints: cont and next
•next - executes one event and stops before the next event
•cont - continues simulation execution until a pending breakpoint
• May be equivalent to several „next‟ commands
00:21
00:05
00:31
00:45
00:51
Single Event Execution
00:21
00:05
00:31
00:45
00:51
Multiple Event Execution
cont
pending
breakpoint
next
set breakpoint
00:59
next
next
next
next
set breakpoint
set breakpoint
set breakpoint
set breakpoint
Copyright © 2000 OPNET Technologies, Inc.
Title – 24
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 24
Breakpoints: Interpreting the Event Banner
• At each breakpoint, event banner for next pending event is displayed
____________________________ (ODB 7.0.B: Event) ____________________________
* Time : 9.08349170694 sec, [00d 00h 00m 09s . 083ms 491us 706ns 942ps]
* Event : execution ID (10), schedule ID (#20), type (stream intrpt)
* Source : execution ID (9), top.pksw1.node_0.src (ideal generator)
* Data : instrm (1), packet ID (1)
> Module : top.pksw1.node_0.proc (processor)
•Time Simulation time associated with the event
•Event Event ID associated with the event
•Type Type of interrupt that will be delivered
•Source Module generating the interrupt
•Data Other information associated with the event
•Module Simulation object where the event will occur
Copyright © 2000 OPNET Technologies, Inc.
Title – 25
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 25
Breakpoints: Basic Commands
next
Execute the next pending event and set a breakpoint after its completion
evstop For specified pending event
tstop For specified time
mstop For all interrupts delivered to a specific module
prostop When a specified process is about to be invoked
intstop For a specified module and type of interrupt
Copyright © 2000 OPNET Technologies, Inc.
Title – 26
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 26
Breakpoints: Reviewing
•status command displays all pending breakpoints
odb> evstop 34
odb> tstop 40
odb> status
Breakpoints :
1) stop at event (34)
2) stop at time = (40) sec.
Traces :
None
Copyright © 2000 OPNET Technologies, Inc.
Title – 27
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 27
Breakpoints: Deleting and Suspending
• Breakpoints may be deleted while still pending
• Command: delstop
• Breakpoints may be suspended, then re-activated so that complete recreation is not necessary
• Command: suspstop
• Command: actstop
Copyright © 2000 OPNET Technologies, Inc.
Title – 28
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 28
Traces
• A list of KPs called by a process
• Used to print detailed information about event execution
• Typical traces display details of Kernel Procedures
• KP name
• Argument names
• Argument values
• Return value
• Contain information about the process being executed
• Once activated, a trace remains active until deactivated
Copyright © 2000 OPNET Technologies, Inc.
Title – 29
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 29
Traces: Interpretation
* invoking process (“pk_sink”)
__________state (st_0): exit executives__________
* op_intrpt_strm ()
active strm (0)
* op_pk_get (instrm_index)
strm. index (0)
packet ID (1)
* op_pk_destroy (pkptr)
packet ID (1)
__________state (st_1): enter executives_________
*returning from process (“pk_sink”)
Process invocation
Process return
State banner
KP invocations
State banner
Copyright © 2000 OPNET Technologies, Inc.
Title – 30
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 30
Traces: Interpreting KP Trace Format
• Kernel Procedure invocation argument values
• Kernel Procedure return values
Copyright © 2000 OPNET Technologies, Inc.
Title – 31
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 31
Traces: Basic Commands
fulltrace Global tracing of all KP invocations. Toggles between enabled or disabled
mtrace KPs invoked within a specified module
protrace KPs invoked within a specified module process
pktrace KPs which affect a certain packet
pttrace KPs which affect a certain packet tree
Copyright © 2000 OPNET Technologies, Inc.
Title – 32
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 32
odb> pktrace 5
odb> mtrace 11
odb> protrace 0
odb> status
Breakpoints :
None
Traces :
0) trace on packet with ID (5) (packet not in system)
1) trace on module (top.pksw1.node_0.proc)
2) trace on process (0)
Traces: Reviewing
•status command displays all pending traces
Copyright © 2000 OPNET Technologies, Inc.
Title – 33
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 33
Traces: Suspending and Deleting
• Traces may be deleted
• Command: deltrace
• Trace may be suspended, then re-activated so that complete recreation is not necessary
• Command: susptrace
• Command: acttrace
• If fulltrace is active, fulltrace again toggles to inactive
Copyright © 2000 OPNET Technologies, Inc.
Title – 34
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 34
Labels
• Established by process model code
• Allow traces restricted to classes of activity
• Print values of state, temporary variables
• Print results of statements
• User-defined trace statements may be added to a process model
• Many OPNET standard models use labels
• e.g. TCP, ATM
Copyright © 2000 OPNET Technologies, Inc.
Title – 35
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 35
Labels: Basic Commands
•ltrace
• Sets a trace for a specified label
• Example: ltrace atm
•mltrace
• Sets a trace for a specified module and label
•proltrace
• Sets a trace for a specified process model and label
Copyright © 2000 OPNET Technologies, Inc.
Title – 36
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 36
____________________________ (ODB 7.0.B: Event) ____________________________
* Time : 972.409334997 sec, [00d 00h 16m 12s . 409ms 334us 997ns 496ps]
* Event : execution ID (15204), schedule ID (#15605), type (remote intrpt)
* Source : execution ID (15203), top.Office network.DEVELOPMENT.tcp (processor)
* Data : code (10)
> Module : top.Office network.DEVELOPMENT.tcp (processor)
| Removing connection (14) from TCB list.
/* Print trace information if enabled */
if (op_prg_odb_ltrace_active (“tcp”))
{
sprintf (msg0, “Removing connection (%d) from TCB list.”, conn_id);
op_prg_odb_print_minor (msg0, OPC_NIL);
}
Labels: Example of a Labeled Trace
• User-defined code that checks for a label and prints the relevant information:
• Output when running a simulation with the TCP trace turned on (ltrace tcp):
Copyright © 2000 OPNET Technologies, Inc.
Title – 37
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 37
A Basic Debugging Paradigm
1. Locate the error
• From error message, identify event number of an error
2. Stop the simulation at the last event before the error
• In ODB, evstop with that event number
•cont to “skip ahead” to that event of interest
3. Turn on traces
•fulltrace to turn on detailed trace
•next to view execution details of the event of interest
4. Inspect the traces
5. Fix the problem
Copyright © 2000 OPNET Technologies, Inc.
Title – 38
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 38
Lab 1: Using evstop and fulltrace
• Context: Packet Switching Tutorial model
Packets are evenly routed between 4 nodes via a hub
• Open Project Editor and load pksw_net
• Open lab1 scenario
Scenario node_0 model hub model
Copyright © 2000 OPNET Technologies, Inc.
Title – 39
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 39
<<< Program Abort >>>
* Time: 20:28:15 Sun Aug 06 2000
* Program: op_runsim (Version 7.0.B PL6 Build 1086)
* Function: sim_err_print (severity_level, str0, str1)
* Error: Packet pointer is NIL
T (8.93569), EV (6), MOD (top.pksw1.node_1.proc),
KP (op_pk_nfd_set)
Lab 1: Error Message from pksw_net
1. Execute simulation from command line
op_runsim -net_name pksw_net-lab1
2. Inspect error message
3. Note: Event ID 6
Copyright © 2000 OPNET Technologies, Inc.
Title – 40
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 40
Lab 1: Obtain fulltrace Information
1. Execute simulation in debug mode op_runsim -net_name pksw_net-lab1 -debug
2. Set evstop for event 6 (evstop 6)
3. cont to continue until event 6
4. fulltrace to toggle global tracing
5. next to execute pending event
____________________________ (ODB 7.0.B: Event) ____________________________
* Time : 8.9356938109 sec, [00d 00h 00m 08s . 935ms 693us 810ns 900ps]
* Event : execution ID (6), schedule ID (#14), type (stream intrpt)
* Source : execution ID (5), top.pksw1.node_1.src (ideal generator)
* Data : instrm (1), packet ID (0)
> Module : top.pksw1.node_1.proc (processor)
breakpoint trapped : "stop at event (6)"
Copyright © 2000 OPNET Technologies, Inc.
Title – 41
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 41
Lab 1: Inspect fulltrace Information _________THREAD 236: state (xmt): enter executives_________
* THREAD 236: op_pk_get (instrm_index)
THREAD 236: strm. index (0)
THREAD 236: strm. is empty.
* THREAD 236: op_dist_outcome (dist_ptr)
THREAD 236: dist. ptr. (0x00901EA8)
THREAD 236: distribution (uniform_int (0.000000000e+000, 3.0000000000e+000))
THREAD 236: outcome (1.0)
<<< Program Abort >>>
* Time: 20:44:52 Sun Aug 06 2000
* Program: op_runsim (Version 7.0.B PL6 Build 1086)
* Function: sim_err_print (severity_level, str0, str1)
* Error: Packet pointer is NIL
T (8.93569), EV (6), MOD (top.pksw1.node_1.proc), KP (op_pk_nfd_set)
6. Observe: packet arrived on stream 1, but op_pk_get() attempts to access stream 0
7. quit to quit ODB
Copyright © 2000 OPNET Technologies, Inc.
Title – 42
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 42
Lab 1: Correct the Error
1.In the Project Editor double click on
• Double-click on node_1 to edit module proc
• Double-click on module proc to edit process model pksw_nd_proc
2. Edit enter executive of xmt state
Change
pkptr = op_pk_get (RCV_IN_STRM)
to
pkptr = op_pk_get (SRC_IN_STRM)
3. Compile process model
Copyright © 2000 OPNET Technologies, Inc.
Title – 43
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 43
Lab 1: Confirm the Error is Corrected
prompt% op_runsim -net_name pksw_net-lab1
|-----------------------------------------------------------------------------|
| Module (11), (top.pksw1.node_0.proc) |
| From procedure: pksw_nd_proc1 () [end enter execs] |
| Node node_0: received 89 packets. |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Module (22), (top.pksw1.node_1.proc) |
| From procedure: pksw_nd_proc1 () [end enter execs] |
| Node node_1: received 0 packets. |
|-----------------------------------------------------------------------------|
< . . . >
|-----------------------------------------------------------------------------|
| Simulation Completed - Collating Results. |
| Events: Total (1077), Average Speed (2761 events/sec.) |
| Time: Elapsed (1 sec.), Simulated (16 min. 40 sec.) |
|-----------------------------------------------------------------------------|
Copyright © 2000 OPNET Technologies, Inc.
Title – 44
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 44
Break
Copyright © 2000 OPNET Technologies, Inc.
Title – 45
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 45
Maps
• A list of simulation objects corresponding to some criteria
• Provides object IDs and corresponding topological “location”
• Objects are identified by name or object ID
• Inspect state of simulation objects and packets
• Typically:
• Selection of a specific object (RIP process at Router_4)
• Selection of all objects of a specific type (map of all queue objects in the simulation, packets from the same packet tree)
Copyright © 2000 OPNET Technologies, Inc.
Title – 46
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 46
odb> objmap proc hub
Obj ID Obj Name Obj Type Parent ID
-----------------------------------------------------------------------------------------
55 top.pksw1.hub.hub processor 6
Maps: Interpreting Command Output
Packet switching tutorial network:
•Obj ID: Unique integer identifying object
•Obj Name: Hierarchical name of object
•Obj Type: Description of class of object
•Parent ID: Object ID of parent object
Copyright © 2000 OPNET Technologies, Inc.
Title – 47
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 47
Maps: Basic Commands
objmap
List of objects matching specified criteria
promap List of processes associated with a specified processor or queue
objid Object id of a specified object
objassoc List of objects of the specified type that are associated with the specified object
pkmap List of packets matching specified criteria
ptmap List of packets belonging to a specified tree
Copyright © 2000 OPNET Technologies, Inc.
Title – 48
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 48
Entity Information
• Commands can be applied to objects to display verbose information about the state of the object
• Examples:
• Current state of a subqueue, including list of packets it contains
• Contents of packet fields
Copyright © 2000 OPNET Technologies, Inc.
Title – 49
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 49
Entity Information: Basic Commands
objprint Display information about an object -- attribute values, queue sizes and contents, process information.
pkprint Display information about a packet -- ID, field values, current location, size
attrget Display the current value of an attribute of an object
attrset Assign a new value to an attribute of an object
attrprint Display information about the internal state of a specified attribute
Copyright © 2000 OPNET Technologies, Inc.
Title – 50
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 50
Entity Information: Example
odb> pkprint 6937
* packet contents:
ID : 6937
format : ethernet
creation module : top.ethcoax_net.stn_8.mac
creation time : 5.32919
total size : 12208
owner : top.ethcoax_net.stn_8.mac
Index Name Type Value Size
0 preamble info unspecified 64
1 dst_addr integer 2 48
2 src_addr integer 6 48
3 type integer 0 16
4 data packet pk id (6936) 12000
5 last_sent_MAC_ID integer 148 0
Copyright © 2000 OPNET Technologies, Inc.
Title – 51
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 51
Entity Information: Obtaining
• Determine Object ID of object of interest
•objmap <type> to obtain a list of selected objects
or
• Visually identify object of interest from hierarchical names in map and find its object ID
• Print information about the object
• Use objprint <Obj ID>
Copyright © 2000 OPNET Technologies, Inc.
Title – 52
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 52
Lab 2: Using Entity Information
Problem: Unexpected simulation results: all packets are received by node_0
• The error may indicate a problem with setting destination address field in packets
• Use pkprint to investigate contents of packet fields
Copyright © 2000 OPNET Technologies, Inc.
Title – 53
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 53
Lab 2: Unexpected Results
prompt% op_runsim -net_name pksw_net-lab1
|-----------------------------------------------------------------------------|
| Module (11), (top.pksw1.node_0.proc) |
| From procedure: pksw_nd_proc1 () [end enter execs] |
| Node node_0: received 89 packets. |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Module (22), (top.pksw1.node_1.proc) |
| From procedure: pksw_nd_proc1 () [end enter execs] |
| Node node_1: received 0 packets. |
|-----------------------------------------------------------------------------|
< Other nodes also receive 0 packets>
|-----------------------------------------------------------------------------|
| Simulation Completed - Collating Results. |
| Events: Total (1077), Average Speed (2761 events/sec.) |
| Time: Elapsed (1 sec.), Simulated (16 min. 40 sec.) |
|-----------------------------------------------------------------------------|
Copyright © 2000 OPNET Technologies, Inc.
Title – 54
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 54
Lab 2: Approach -- Tracing One Packet
1. Execute simulation in debug mode
op_runsim -net_name pksw_net-lab1 -debug
2. Set pktrace for packet 0 (pktrace 0)
3. next until event involving packet 0 is encountered
* Time : 8.9356938109 sec, [00d 00h 00m 08s . 935ms 693us 810ns 900ps]
* Event : execution ID (5), schedule ID (#10), type (self intrpt)
* Source : execution ID (-1), top.pksw1.node_1.src (ideal generator)
* Data : code (0)
> Module : top.pksw1.node_1.src (ideal generator)
odb> next
* THREAD 305: generating packet
THREAD 305: packet ID (0)
THREAD 305: bulk size (9600)
THREAD 305: total size (9600)
Copyright © 2000 OPNET Technologies, Inc.
Title – 55
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 55
odb> next
* THREAD 305: op_pk_get (instrm_index)
THREAD 305: strm. index (1)
THREAD 305: packet ID (0)
* THREAD 305: op_pk_nfd_set (pkptr, fd_name, value, <...>)
THREAD 305: packet ID (0)
THREAD 305: field name (dest_address)
THREAD 305: field type (integer)
THREAD 305: field value (1)
THREAD 305: field size (0)
* THREAD 305: op_pk_send (pkptr, outstrm_index)
THREAD 305: packet ID (0)
THREAD 305: stream index (0)
Lab 2: Tracing One Packet (continued)
4. next to observe a packet field being set
Copyright © 2000 OPNET Technologies, Inc.
Title – 56
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 56
odb> pkprint 0
* THREAD 305: packet contents:
THREAD 305: ID : 0
THREAD 305: tree ID : 0
THREAD 305: address : 0x8AAB90
THREAD 305: format : pksw_format
THREAD 305: creation module : top.pksw1.node_1.src
THREAD 305: creation time : 8.93569
THREAD 305: stamp module : top.pksw1.node_1.src
THREAD 305: stamp time : 8.93569
THREAD 305: bulk size : 9600
THREAD 305: total size : 9600
THREAD 305: owner : top.pksw1.node_1.strm_2
THREAD 305: ICI ID : NONE
THREAD 305: ID trace : on
THREAD 305: tree ID trace : off
THREAD 305: encap flags : NONE
Index Name Type Value Size
0 dest_address integer 1 0
Lab 2: Tracing One Packet (continued)
5. pkprint to observe contents of packet fields
Copyright © 2000 OPNET Technologies, Inc.
Title – 57
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 57
Lab 2: Tracing One Packet (continued)
6. next to continue tracing
7. Hub receives packet at event 15, stop the simulation at event 15
odb> evstop 15
odb> cont
. . .
____________________________ (ODB 7.0.B: Event) ____________________________
* Time : 9.9356938109 sec, [00d 00h 00m 09s . 935ms 693us 810ns 900ps]
* Event : execution ID (15), schedule ID (#25), type (stream intrpt)
* Source : execution ID (14), top.pksw1.hub.rcv3 (pt-pt receiver)
* Data : instrm (3), packet ID (0)
> Module : top.pksw1.hub.hub (processor)
breakpoint trapped : "stop at event (15)"
Copyright © 2000 OPNET Technologies, Inc.
Title – 58
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 58
Lab 2: Tracing One Packet (continued)
8. next to continue tracing
9. Observe further manipulation of packet
odb> next
* THREAD 305: op_pk_get (instrm_index)
THREAD 305: strm. index (3)
THREAD 305: packet ID (0)
* THREAD 305: op_pk_nfd_set (pkptr, fd_name, value, <...>)
THREAD 305: packet ID (0)
THREAD 305: field name (dest_address)
THREAD 305: field type (integer)
THREAD 305: field value (0)
THREAD 305: field size (0)
* THREAD 305: op_pk_send (pkptr, outstrm_index)
THREAD 305: packet ID (0)
THREAD 305: stream index (0)
Copyright © 2000 OPNET Technologies, Inc.
Title – 59
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 59
odb> pkprint
* THREAD 305: packet contents:
THREAD 305: ID : 0
THREAD 305: tree ID : 0
THREAD 305: address : 0x8AAB90
THREAD 305: format : pksw_format
THREAD 305: creation module : top.pksw1.node_1.src
THREAD 305: creation time : 8.93569
THREAD 305: stamp module : top.pksw1.node_1.src
THREAD 305: stamp time : 8.93569
THREAD 305: bulk size : 9600
THREAD 305: total size : 9600
THREAD 305: owner : top.pksw1.hub.strm_8
THREAD 305: ICI ID : NONE
THREAD 305: ID trace : on
THREAD 305: tree ID trace : off
THREAD 305: encap flags : NONE
THREAD 305: Index Name Type Value Size
THREAD 305: 0 dest_address integer 0 0
Lab 2: Tracing One Packet (continued)
10. pkprint to observe contents of packet fields
Copyright © 2000 OPNET Technologies, Inc.
Title – 60
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 60
Lab 2: Localization of Error
• Observe: Value of packet field 0 has been changed to 0 from its originally set value of 1
• Packet is therefore sent on stream 0, not on stream 1 as expected
11. Exit debugger
Copyright © 2000 OPNET Technologies, Inc.
Title – 61
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 61
Lab 2: Correct the Error
1. In the project editor double click on
• node hub to see module hub
• module hub to edit process model pksw_hub_proc
2. Edit enter executive state route_pk
• Note that the destination address was never initialized
3. Change op_pk_nfd_set (pkptr, “dest_address”, dest_address);
to op_pk_nfd_get (pkptr, “dest_address”, &dest_address);
4. Compile process model
Copyright © 2000 OPNET Technologies, Inc.
Title – 62
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 62
Lab 2: Confirm the Error is Corrected
prompt% op_runsim -net_name pksw_net-lab1
|-----------------------------------------------------------------------------|
| Module (11), (top.pksw1.node_0.proc) |
| From procedure: pksw_nd_proc2 () [end enter execs] |
| Node node_0: received 22 packets. |
|-----------------------------------------------------------------------------|
|-----------------------------------------------------------------------------|
| Module (22), (top.pksw1.node_1.proc) |
| From procedure: pksw_nd_proc2 () [end enter execs] |
| Node node_1: received 23 packets. |
|-----------------------------------------------------------------------------|
<Other nodes receive similar numbers of packets> |-----------------------------------------------------------------------------|
| Simulation Completed - Collating Results. |
| Events: Total (1077), Average Speed (3846 events/sec.) |
| Time: Elapsed (1 sec.), Simulated (16 min. 40 sec.) |
|-----------------------------------------------------------------------------|
Copyright © 2000 OPNET Technologies, Inc.
Title – 63
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 63
Diagnostic Block
• Process model code that may be invoked via an ODB command
• Statements that display state information of interest
• values of state variables
• Contents of key data structures (example TCP Transmission Control Block, routing tables)
• Diagnostic block may be invoked from any breakpoint
• Created in Process Editor
• Diagnostic block button
Copyright © 2000 OPNET Technologies, Inc.
Title – 64
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 64
Diagnostic Block: Example
• Code in Diagnostic block:
• Text in ODB:
op_prg_odb_print_major ("TCB list:", OPC_NIL);
list_size = op_prg_list_size (tcb_list);
for (i = 0; i < list_size; i++)
{
tcb_ptr = (TcpT_Tcb *) op_prg_list_access (tcb_list, i);
/* Print socket information. */
sprintf (msg0, "Connection (%d) information: state (%s)",
tcb_ptr->conn_id, tcb_ptr->state_name);
....
....
}
| TCB list:
| Connection (1) information: state (LISTEN)
| Application objid (26034), Type of Service: As Requested by Client,
| traffic through stream (1)
Copyright © 2000 OPNET Technologies, Inc.
Title – 65
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 65
Diagnostic Block: Basic Commands
•prodiag: invokes the diagnostic block of a specified process
•proldiag: executes the diagnostic block of the specified process and sets a trace for a specified label restricted to the execution of the block
• Example: (Diagnostic block of ip_rte_v4.pr.m)
if (op_prg_odb_ltrace_active ("ip_frag"))
{
ip_frag_sup_print (dgram_list_ptr);
}
Copyright © 2000 OPNET Technologies, Inc.
Title – 66
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 66
Diagnostic Block : How to Use
1. Find object ID of module containing the process of interest • Use objmap type to obtain a list of selected objects
Example: objmap proc rip gives the list of all rip modules
• Locate desired node and note module ID of interest
2. Find object ID of the process of interest • Use promap objid where objid is the module of interest
Example: promap 104
3. Run the simulation in debug mode; stop it at some time
4. Print the information from the diagnostic block Example: proldiag 0 rip_route_table
Copyright © 2000 OPNET Technologies, Inc.
Title – 67
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 67
Memory
• Simulation Kernel tracks memory allocation
• organized by source categories
• Display of memory categories
• Identify areas of memory buildup
• Example: Packets received but never destroyed
• Memory Usage Monitor object
• Located in utilities object palette
Copyright © 2000 OPNET Technologies, Inc.
Title – 68
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 68
Memory: Commands
•memstats
• Displays a list of statistics for memory categories
• High-level
• Can be limited to categories accounting for more than a specified amount of memory
• Advanced:
•memsrc: Displays list of allocation sources for a memory category
•memsnk: Displays list of deallocation sinks for a memory category
Copyright © 2000 OPNET Technologies, Inc.
Title – 69
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 69
odb> memstats 10
--------------------------------------------------------------------------------
Object Allocation Statistics
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Memory Category Bytes #Use #Free #Total Total(KB)
--------------------------------------------------------------------------------
general - - - - 308
linked list cell 12 43405 4 44000 516
linked list cell [long] 12 249 0 1000 12
linked list cell [short] 12 0 143 1000 12
linked list desc. 24 70 436 550 13
--------------------------------------------------------------------------------
obj attribute props 176 67 - 67 13
other - - - - 72
packet 136 36153 0 37001 4915
packet field block (pksw_format) 24 36154 0 36201 849
process descriptor 152 5 0 1001 149
--------------------------------------------------------------------------------
……………..
--------------------------------------------------------------------------------
Total (KB) 15299
Memory: memstats Output
Model: Packet switching tutorial run for 100 hours without destroying packets
Copyright © 2000 OPNET Technologies, Inc.
Title – 70
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 70
Memory: Identifying Memory Buildup
• Use memstats at some time T
• Use tstop T + T for some future time
• Use memstats
• Compare
• Repeat to identify areas of buildup
Copyright © 2000 OPNET Technologies, Inc.
Title – 71
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 71
Animation as a Debugging Technique
• Animation can be used to visualize the behavior of a simulation
• Can help identify location on which to focus in ODB
• Demo: Visualizing a failure in packet routing
Copyright © 2000 OPNET Technologies, Inc.
Title – 72
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 72
Summary
• Determine the nature of the problem first
• Simulation Log
• err_log, op_vuerr
• ODB allows interactive control over a simulation to investigate its behavior
• Set breakpoints, traces, query object information, print information from diagnostic blocks
• Key commands:
•help
•evstop, tstop, mstop
•next, cont
•fulltrace, mtrace, pktrace
•pkmap, objmap
•pkprint, objprint
Copyright © 2000 OPNET Technologies, Inc.
Title – 73
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 73
Reference
• All ODB documentation • Simx chapter of External Interfaces Manual • OPNET Simulation Debugger section
• General ODB Concepts
• ODB Concepts
• ODB Command Reference • ODB Command Reference
• ODB Tutorial
• ODB Usage Scenarios
Copyright © 2000 OPNET Technologies, Inc.
Title – 74
Copyright © 2000 OPNET Technologies, Inc.
OPNET Technologies, Inc.
OPNET UNIVERSITY
2000
Debugging Simulation Models Intro 74
Question & Answer
top related