Vous êtes sur la page 1sur 74

OPNET Technologies, Inc.

Presentation Title Debugging


Simulation Models -Introduction Author
OPNET UNIVERSITY 2000
TM

Subtitle

Title 1
Copyright 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 2

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Items Not Covered Will not cover C programming Segmentation violation Bus error
These topics are covered in the session Debugging Simulation Models Advanced.

Debugging Simulation Models Intro

Title 3

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Prerequisites
Familiarity with OPNET Modeler model hierarchy Creating process models Running simulations

Debugging Simulation Models Intro

Title 4

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Agenda

Interpreting error messages Identifying the problem Using the OPNET Debugger (ODB) Viewing animation for debugging

Debugging Simulation Models Intro

Title 5

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 Simulation completes successfully, but does not accurately represent the modelers intent. Illustrated in Lab 2
Title 6
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

Behavioral

Debugging Simulation Models Intro

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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)> <node name> <module name> top.e_campus.bldg_10 router in_queue

Debugging Simulation Models Intro

Title 7

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Simulation Log
Records notable events for every scenario Recreated every time a scenarios simulation is run Describes problems Suggests solutions Gives informational messages

Debugging Simulation Models Intro

Title 8

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Simulation Error Classifications


Program Abort Recoverable Error Problem that prohibits the simulation from proceeding. Problem that does not prohibit the simulation from proceeding, but may result in cancellation of the current operation. Problem that is recoverable, but minor. Only reported if the diag_enable preference is TRUE. Default value is FALSE. Message typically generated by model to identify problems within the model itself, written by model developer using op_sim_message() Kernel Procedure (KP).
Title 9
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

Diagnostic Error

Warning

Debugging Simulation Models Intro

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 EV
MOD KP

Simulation time of error Event ID of simulation event


Name of module where error occurred Name of Kernel Procedure that reported the problem

Messages Match in Kernel Procedure docs


Debugging Simulation Models Intro
Title 10
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

10

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 11

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

11

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 () Process model KP reporting Sim. 3) 1 79 sim_strm_insert () and state problem Kernel 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, <...>) ............................................................ Error 7) 1 1481 *sim_err_pk_access (pkptr, error_code) Message 8) 1 88 *sim_err_issue (pkg_id, msg_id, <subst_values>) Printing 9) 1 339 sim_err_print (severity_level, str0, str1) -----------------------------------------------------------Debugging Simulation Models Intro
Title 12
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

12

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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; 7 for (x = 0; x < 10; x++) 8 { 9 printf (z = %d\n,z); 10 z += x; 11 } 12 FRET (z) 13 }

B C

Location A Reported block line number: 5 Location B Reported block line number: 8 Location C Reported block line number: 11
Debugging Simulation Models Intro
Title 13
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

13

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
Title 14

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

14

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Using the Development Kernel

The kernel_type preference Controls which Simulation Kernel is used during a simulation To set kernel_type to development:
Dont 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

Debugging Simulation Models Intro

Title 15

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

15

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 16

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

16

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 17

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

17

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 18

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

18

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Invoking and Exiting ODB


% op_runsim -net_name example -debug <...simulation banner...> ______________ OPNET Simulation Debugger ____________ Type help for Command Summary odb> Time 0, before begsim interrupts are delivered

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
Debugging Simulation Models Intro
Title 19
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

19

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 ... Debugging Simulation Models Intro
Title 20
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

20

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

ODB: Lesson Plan


Breakpoints Traces Labels Lab 1 Break Maps Entity Information Lab 2 Diagnostic Block Memory Allocation

Debugging Simulation Models Intro

Title 21

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

21

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
noitucexE tnevE elpitluM
5 0: 0 0 1 2: 0 0 1 3: 0 0 5 4: 0 0

noitucexE tnevE elgniS


5 0: 0 0

execution until a breakpoint occurs


gnidnep tniopkaerb

tnoc tniopkaerb tes

txen txen
1 2: 0 0

tniopkaerb tes
1 3: 0 0

txen

1 5: 0 0

tniopkaerb tes
9 5: 0 0 5 4: 0 0

txen txen
1 5: 0 0

tniopkaerb tes tniopkaerb tes

Debugging Simulation Models Intro

Title 22

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

22

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
noitucexE tnevE elpitluM
5 0: 0 0 1 2: 0 0 1 3: 0 0 5 4: 0 0

noitucexE tnevE elgniS txen


5 0: 0 0

tnoc tniopkaerb tes

txen
1 2: 0 0

tniopkaerb tes
1 3: 0 0

txen

gnidnep tniopkaerb

1 5: 0 0

tniopkaerb tes
9 5: 0 0 5 4: 0 0

txen txen
1 5: 0 0

tniopkaerb tes tniopkaerb tes

Debugging Simulation Models Intro

Title 23

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

23

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Breakpoints: Interpreting the Event Banner


At each breakpoint, event banner for next pending event is displayed
____________________________ (ODB 7.0.B: Event) ____________________________ * * * * > Time Event Source Data Module : : : : : 9.08349170694 sec, [00d 00h 00m 09s . 083ms 491us 706ns 942ps] execution ID (10), schedule ID (#20), type (stream intrpt) execution ID (9), top.pksw1.node_0.src (ideal generator) instrm (1), packet ID (1) top.pksw1.node_0.proc (processor)

Time Event Type Source Data Module

Simulation time associated with the event Event ID associated with the event Type of interrupt that will be delivered Module generating the interrupt Other information associated with the event Simulation object where the event will occur
Title 24

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

24

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Breakpoints: Basic Commands


next evstop Execute the next pending event and set a breakpoint after its completion For specified pending event

tstop
mstop prostop intstop

For specified time


For all interrupts delivered to a specific module When a specified process is about to be invoked For a specified module and type of interrupt
Title 25

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

25

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Breakpoints: Reviewing
status command displays all pending breakpoints
odb> evstop 34 odb> tstop 40 odb> status Breakpoints : 1) 2)

stop at event (34) stop at time = (40) sec.

Traces :

None

Debugging Simulation Models Intro

Title 26

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

26

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 27

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

27

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 28

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

28

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Traces: Interpretation
Process invocation State banner
* invoking process (pk_sink) __________state (st_0): exit executives__________

* op_intrpt_strm () active strm

(0)

KP invocations

* op_pk_get (instrm_index) strm. index (0) packet ID (1) * op_pk_destroy (pkptr) packet ID

(1)

State banner Process return


Debugging Simulation Models Intro

__________state (st_1): enter executives_________

*returning from process (pk_sink)

Title 29

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

29

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Traces: Interpreting KP Trace Format

Kernel Procedure invocation argument values Kernel Procedure return values

Debugging Simulation Models Intro

Title 30

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

30

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Traces: Basic Commands


fulltrace mtrace protrace pktrace pttrace Global tracing of all KP invocations. Toggles between enabled or disabled KPs invoked within a specified module

KPs invoked within a specified module process

KPs which affect a certain packet

KPs which affect a certain packet tree

Debugging Simulation Models Intro

Title 31

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

31

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Traces: Reviewing
status command displays all pending traces
odb> pktrace 5 odb> mtrace 11 odb> protrace 0 odb> status Breakpoints : None

Traces : 0) 1) 2) trace on packet with ID (5) (packet not in system) trace on module (top.pksw1.node_0.proc) trace on process (0)

Debugging Simulation Models Intro

Title 32

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

32

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 33

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

33

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 34

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

34

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 35

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

35

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Labels: Example of a Labeled Trace


User-defined code that checks for a label and prints the relevant information:
/* 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); }

Output when running a simulation with the TCP trace turned on (ltrace tcp):
____________________________ (ODB 7.0.B: Event) ____________________________ * * * * > Time Event Source Data Module : : : : : 972.409334997 sec, [00d 00h 16m 12s . 409ms 334us 997ns 496ps] execution ID (15204), schedule ID (#15605), type (remote intrpt) execution ID (15203), top.Office network.DEVELOPMENT.tcp (processor) code (10) top.Office network.DEVELOPMENT.tcp (processor) | Removing connection (14) from TCB list.

Debugging Simulation Models Intro

Title 36

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

36

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
Debugging Simulation Models Intro
Title 37

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

37

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Lab 1: Using evstop and fulltrace


Context: Packet Switching Tutorial model Packets are evenly routed between 4 nodes via a hub
Scenario

node_0 model

hub model

Open Project Editor and load pksw_net Open lab1 scenario


Debugging Simulation Models Intro
Title 38
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

38

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Lab 1: Error Message from pksw_net


1. Execute simulation from command line op_runsim -net_name pksw_net-lab1 2. Inspect error message
<<< * * * * 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)

3. Note: Event ID 6
Debugging Simulation Models Intro
Title 39
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

39

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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


____________________________ (ODB 7.0.B: Event) ____________________________ * * * * > Time Event Source Data Module : : : : : 8.9356938109 sec, [00d 00h 00m 08s . 935ms 693us 810ns 900ps] execution ID (6), schedule ID (#14), type (stream intrpt) execution ID (5), top.pksw1.node_1.src (ideal generator) instrm (1), packet ID (0) top.pksw1.node_1.proc (processor)

breakpoint trapped : "stop at event (6)"

4. fulltrace to toggle global tracing 5. next to execute pending event


Debugging Simulation Models Intro
Title 40
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

40

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
Debugging Simulation Models Intro
Title 41
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

41

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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


Debugging Simulation Models Intro
Title 42
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

42

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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.) | |-----------------------------------------------------------------------------|
Title 43

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

43

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Break

Debugging Simulation Models Intro

Title 44

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

44

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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)

Debugging Simulation Models Intro

Title 45

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

45

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Maps: Interpreting Command Output


Packet switching tutorial network:
odb> objmap proc hub Obj ID Obj Name Obj Type Parent ID ----------------------------------------------------------------------------------------55 top.pksw1.hub.hub processor 6

Obj ID: Obj Name: Obj Type: Parent ID:

Unique integer identifying object Hierarchical name of object Description of class of object Object ID of parent object
Title 46

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

46

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Maps: Basic Commands


objmap List of objects matching specified criteria List of processes associated with a specified processor or queue

promap
objid
objassoc pkmap ptmap

Object id of a specified object


List of objects of the specified type that are associated with the specified object List of packets matching specified criteria List of packets belonging to a specified tree
Title 47

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

47

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 48

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

48

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Entity Information: Basic Commands


objprint pkprint attrget attrset attrprint Display information about an object -- attribute values, queue sizes and contents, process information. Display information about a packet -- ID, field values, current location, size Display the current value of an attribute of an object

Assign a new value to an attribute of an object

Display information about the internal state of a specified attribute


Title 49

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

49

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Entity Information: Example


odb> pkprint 6937 * packet contents: ID format creation module creation time total size owner Index Name

: : : : : :

6937 ethernet top.ethcoax_net.stn_8.mac 5.32919 12208 top.ethcoax_net.stn_8.mac Type Value Size

0 1 2 3 4 5

preamble dst_addr src_addr type data last_sent_MAC_ID

info integer integer integer packet integer

unspecified 2 6 0 pk id (6936) 148

64 48 48 16 12000 0

Debugging Simulation Models Intro

Title 50

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

50

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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>

Debugging Simulation Models Intro

Title 51

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

51

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
Debugging Simulation Models Intro
Title 52
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

52

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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.) | |-----------------------------------------------------------------------------|
Title 53

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

53

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 Event Source Data Module : : : : : 8.9356938109 sec, [00d 00h 00m 08s . 935ms 693us 810ns 900ps] execution ID (5), schedule ID (#10), type (self intrpt) execution ID (-1), top.pksw1.node_1.src (ideal generator) code (0) top.pksw1.node_1.src (ideal generator)

odb> next * THREAD 305: generating packet THREAD 305: packet ID THREAD 305: bulk size THREAD 305: total size

(0) (9600) (9600)


Title 54

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

54

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Lab 2: Tracing One Packet (continued)


4. next to observe a packet field being set
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)

Debugging Simulation Models Intro

Title 55

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

55

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Lab 2: Tracing One Packet (continued)


5. pkprint to observe contents of packet fields
odb> pkprint 0 * THREAD 305: packet contents: THREAD 305: ID THREAD 305: tree ID THREAD 305: address THREAD 305: format THREAD 305: creation module THREAD 305: creation time THREAD 305: stamp module THREAD 305: stamp time THREAD 305: bulk size THREAD 305: total size THREAD 305: owner THREAD 305: ICI ID THREAD 305: ID trace THREAD 305: tree ID trace THREAD 305: encap flags Index Name 0 dest_address Debugging Simulation Models Intro

: 0 : 0 : 0x8AAB90 : pksw_format : top.pksw1.node_1.src : 8.93569 : top.pksw1.node_1.src : 8.93569 : 9600 : 9600 : top.pksw1.node_1.strm_2 : NONE : on : off : NONE Type Value integer 1

Size 0
Title 56
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

56

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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 Event Source Data Module : : : : : 9.9356938109 sec, [00d 00h 00m 09s . 935ms 693us 810ns 900ps] execution ID (15), schedule ID (#25), type (stream intrpt) execution ID (14), top.pksw1.hub.rcv3 (pt-pt receiver) instrm (3), packet ID (0) top.pksw1.hub.hub (processor)

breakpoint trapped : "stop at event (15)"

Debugging Simulation Models Intro

Title 57

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

57

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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)
Title 58

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

58

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Lab 2: Tracing One Packet (continued)


10. pkprint to observe contents of packet fields
odb> pkprint * THREAD 305: packet contents: THREAD 305: ID THREAD 305: tree ID THREAD 305: address THREAD 305: format THREAD 305: creation module THREAD 305: creation time THREAD 305: stamp module THREAD 305: stamp time THREAD 305: bulk size THREAD 305: total size THREAD 305: owner THREAD 305: ICI ID THREAD 305: ID trace THREAD 305: tree ID trace THREAD 305: encap flags THREAD 305: Index THREAD 305: 0

: : : : : : : : : : : : : : :

0 0 0x8AAB90 pksw_format top.pksw1.node_1.src 8.93569 top.pksw1.node_1.src 8.93569 9600 9600 top.pksw1.hub.strm_8 NONE on off NONE
Type integer Value 0 Size 0

Name dest_address

Debugging Simulation Models Intro

Title 59

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

59

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 60

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

60

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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


Debugging Simulation Models Intro
Title 61
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

61

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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.) | |-----------------------------------------------------------------------------|

Debugging Simulation Models Intro

Title 62

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

62

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 63

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

63

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Diagnostic Block: Example


Code in Diagnostic block:
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); .... .... }

Text in ODB:
| | | | TCB list: Connection (1) information: state (LISTEN) Application objid (26034), Type of Service: As Requested by Client, traffic through stream (1)
Title 64

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

64

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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); }

Debugging Simulation Models Intro

Title 65

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

65

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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


Title 66

Debugging Simulation Models Intro

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

66

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 67

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

67

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 68

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

68

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Memory: memstats Output


Model: Packet switching tutorial run for 100 hours without destroying packets
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

Debugging Simulation Models Intro

Title 69

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

69

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 70

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

70

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 71

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

71

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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
Debugging Simulation Models Intro
Title 72
Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

72

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 73

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

73

OPNET UNIVERSITY 2000

OPNET Technologies, Inc.

Question & Answer

Debugging Simulation Models Intro

Title 74

Copyright Copyright 2000 OPNET Technologies, Inc. 2000 OPNET Technologies, Inc.

74

Vous aimerez peut-être aussi