opnet Debugging Intro

74
Presentatio n Title Subtitle Author OPNET Technologies, Inc. Copyright © 2000 OPNET Technologies, Inc Title – 1 TM OPNET UNIVERSITY 2000 Debugging Simulation Models -- Introduction

description

opnet simulation debugger

Transcript of opnet Debugging Intro

Page 1: opnet Debugging Intro

Presentation TitleSubtitle

Author

OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, Inc.

Title – 1

TMOPNET UNIVERSITY

2000

Debugging Simulation Models --Introduction

Page 2: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 2 Debugging Simulation Models Intro 2Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Goals•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

Page 3: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 3 Debugging Simulation Models Intro 3Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Items Not Covered•Will not cover…

• C programming• Segmentation violation• Bus error

• These topics are covered in the session Debugging Simulation Models – Advanced.

Page 4: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 4 Debugging Simulation Models Intro 4Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Prerequisites• Familiarity with

• OPNET Modeler model hierarchy• Creating process models• Running simulations

Page 5: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 5 Debugging Simulation Models Intro 5Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

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

Page 6: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 6 Debugging Simulation Models Intro 6Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000The Challenge• Debugging is like finding a needle in a haystack• Narrow down the problem

• Time (event number)• Space (code segment)

• Different types of problemsStructural 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

Page 7: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 7 Debugging Simulation Models Intro 7Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Object 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

Page 8: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 8 Debugging Simulation Models Intro 8Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

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

Page 9: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 9 Debugging Simulation Models Intro 9Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Simulation Error ClassificationsProgram 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).

Page 10: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

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

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Error 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 errorT Simulation time of errorEV Event ID of simulation eventMOD Name of module where error occurredKP Name of Kernel Procedure that reported the

problemMessages Match in Kernel Procedure docs

Page 11: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 11 Debugging Simulation Models Intro 11Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Obtaining 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

Page 12: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 12 Debugging Simulation Models Intro 12Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Example 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

ErrorMessagePrinting

Process modeland state

KP reportingproblem

Page 13: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 13 Debugging Simulation Models Intro 13Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Block Line Numbers in FCS• Block Line Numbers refer to last curly brace passed 1 int function(void)2 {3 int x, z;45 FIN (function (void))6 z = 0; A7 for (x = 0; x < 10; x++)8 {9 printf (“z = %d\n”,z);10 z += x; B11 }12 FRET (z) C13 }

• Location A Reported block line number: 5• Location B Reported block line number: 8• Location C Reported block line number: 11

Page 14: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 14 Debugging Simulation Models Intro 14Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Development 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

Page 15: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 15 Debugging Simulation Models Intro 15Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Using 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

Page 16: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 16 Debugging Simulation Models Intro 16Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000OPNET 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

Page 17: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 17 Debugging Simulation Models Intro 17Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000ODB 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

Page 18: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 18 Debugging Simulation Models Intro 18Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000How 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

Page 19: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 19 Debugging Simulation Models Intro 19Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Invoking 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

Page 20: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 20 Debugging Simulation Models Intro 20Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Getting 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 ...

Page 21: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 21 Debugging Simulation Models Intro 21Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000ODB: Lesson Plan• Breakpoints• Traces• Labels• Lab 1• Break• Maps• Entity Information• Lab 2• Diagnostic Block• Memory Allocation

Page 22: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 22 Debugging Simulation Models Intro 22Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints• 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

S ingle Event Execution

00 :21

00 :05

00 :31

00 :45

00 :51

M ultip le E ven t Execution

con t

pend ingbreakpo in t

next

set b reakpoint

00 :59

next

next

next

next

se t b reakpo in t

set b reakpoint

se t b reakpo in t

se t b reakpo in t

Page 23: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 23 Debugging Simulation Models Intro 23Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints: 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

S ingle E vent E xecution

00 :21

00 :05

00 :31

00 :45

00 :51

M ultip le E vent Execution

cont

pend ingbreakpo in t

next

set b reakpo in t

00 :59

next

next

next

next

se t b reakpo in t

set b reakpo in t

se t b reakpo in t

se t b reakpo in t

Page 24: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 24 Debugging Simulation Models Intro 24Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints: 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

Page 25: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 25 Debugging Simulation Models Intro 25Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints: Basic Commandsnext 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

Page 26: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 26 Debugging Simulation Models Intro 26Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints: 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

Page 27: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 27 Debugging Simulation Models Intro 27Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Breakpoints: 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

Page 28: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 28 Debugging Simulation Models Intro 28Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Traces• 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

Page 29: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 29 Debugging Simulation Models Intro 29Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Traces: 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

Page 30: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 30 Debugging Simulation Models Intro 30Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Traces: Interpreting KP Trace Format

• Kernel Procedure invocation argument values• Kernel Procedure return values

Page 31: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 31 Debugging Simulation Models Intro 31Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Traces: Basic Commandsfulltrace 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

Page 32: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 32 Debugging Simulation Models Intro 32Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

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

Page 33: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 33 Debugging Simulation Models Intro 33Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Traces: 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

Page 34: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 34 Debugging Simulation Models Intro 34Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Labels• 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

Page 35: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 35 Debugging Simulation Models Intro 35Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Labels: 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

Page 36: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 36 Debugging Simulation Models Intro 36Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

____________________________ (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):

Page 37: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 37 Debugging Simulation Models Intro 37Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000A Basic Debugging Paradigm1. 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 traces5. Fix the problem

Page 38: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

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

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 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

Page 39: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 39 Debugging Simulation Models Intro 39Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

<<< 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_net1. Execute simulation from command line

op_runsim -net_name pksw_net-lab12. Inspect error message

3. Note: Event ID 6

Page 40: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

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

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 1: Obtain fulltrace Information1. Execute simulation in debug mode

op_runsim -net_name pksw_net-lab1 -debug2. Set evstop for event 6 (evstop 6)3. cont to continue until event 6

4. fulltrace to toggle global tracing5. 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)"

Page 41: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 41 Debugging Simulation Models Intro 41Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 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

Page 42: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

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

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 1: Correct the Error1.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 stateChangepkptr = op_pk_get (RCV_IN_STRM)

to

pkptr = op_pk_get (SRC_IN_STRM)

3. Compile process model

Page 43: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 43 Debugging Simulation Models Intro 43Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 1: Confirm the Error is Correctedprompt% 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.) ||-----------------------------------------------------------------------------|

Page 44: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 44 Debugging Simulation Models Intro 44Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

Break

Page 45: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 45 Debugging Simulation Models Intro 45Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Maps • 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)

Page 46: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 46 Debugging Simulation Models Intro 46Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

odb> objmap proc hub

Obj ID Obj Name Obj Type Parent ID----------------------------------------------------------------------------------------- 55 top.pksw1.hub.hub processor 6

Maps: Interpreting Command OutputPacket 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

Page 47: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 47 Debugging Simulation Models Intro 47Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Maps: Basic Commandsobjmap 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

Page 48: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 48 Debugging Simulation Models Intro 48Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Entity 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

Page 49: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 49 Debugging Simulation Models Intro 49Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Entity Information: Basic Commandsobjprint 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

Page 50: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 50 Debugging Simulation Models Intro 50Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Entity Information: Exampleodb> pkprint 6937

* packet contents:ID : 6937format : ethernetcreation module : top.ethcoax_net.stn_8.maccreation time : 5.32919total size : 12208owner : 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

Page 51: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 51 Debugging Simulation Models Intro 51Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Entity 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>

Page 52: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 52 Debugging Simulation Models Intro 52Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Using Entity InformationProblem: 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

Page 53: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 53 Debugging Simulation Models Intro 53Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Unexpected Resultsprompt% 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.) ||-----------------------------------------------------------------------------|

Page 54: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 54 Debugging Simulation Models Intro 54Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Approach -- Tracing One Packet1. 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)

Page 55: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 55 Debugging Simulation Models Intro 55Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

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

Page 56: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 56 Debugging Simulation Models Intro 56Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

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

Page 57: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 57 Debugging Simulation Models Intro 57Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Tracing One Packet (continued)6. next to continue tracing7. Hub receives packet at event 15, stop the simulation at event 15

odb> evstop 15odb> 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)"

Page 58: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 58 Debugging Simulation Models Intro 58Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Tracing One Packet (continued)8. next to continue tracing9. 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)

Page 59: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 59 Debugging Simulation Models Intro 59Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

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

Page 60: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 60 Debugging Simulation Models Intro 60Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 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

Page 61: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

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

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Correct the Error1. 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. Changeop_pk_nfd_set (pkptr, “dest_address”, dest_address);

toop_pk_nfd_get (pkptr, “dest_address”, &dest_address);

4. Compile process model

Page 62: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 62 Debugging Simulation Models Intro 62Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Lab 2: Confirm the Error is Correctedprompt% 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.) ||-----------------------------------------------------------------------------|

Page 63: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 63 Debugging Simulation Models Intro 63Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Diagnostic 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

Page 64: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 64 Debugging Simulation Models Intro 64Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Diagnostic 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)

Page 65: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 65 Debugging Simulation Models Intro 65Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

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

Page 66: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 66 Debugging Simulation Models Intro 66Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Diagnostic Block : How to Use1. 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 time4. Print the information from the diagnostic block

Example: proldiag 0 rip_route_table

Page 67: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 67 Debugging Simulation Models Intro 67Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Memory• 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

Page 68: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 68 Debugging Simulation Models Intro 68Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Memory: 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

Page 69: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 69 Debugging Simulation Models Intro 69Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

odb> memstats 10 -------------------------------------------------------------------------------- Object Allocation Statistics----------------------------------------------------------------------------------------------------------------------------------------------------------------Memory Category Bytes #Use #Free #Total Total(KB)--------------------------------------------------------------------------------general - - - - 308linked list cell 12 43405 4 44000 516linked list cell [long] 12 249 0 1000 12linked list cell [short] 12 0 143 1000 12linked list desc. 24 70 436 550 13--------------------------------------------------------------------------------obj attribute props 176 67 - 67 13other - - - - 72packet 136 36153 0 37001 4915packet field block (pksw_format) 24 36154 0 36201 849process descriptor 152 5 0 1001 149--------------------------------------------------------------------------------……………..--------------------------------------------------------------------------------Total (KB) 15299

Memory: memstats OutputModel: Packet switching tutorial run for 100 hours without destroying packets

Page 70: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 70 Debugging Simulation Models Intro 70Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Memory: 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

Page 71: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 71 Debugging Simulation Models Intro 71Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Animation 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

Page 72: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 72 Debugging Simulation Models Intro 72Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Summary • 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

Page 73: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 73 Debugging Simulation Models Intro 73Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000Reference • 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

Page 74: opnet Debugging Intro

Copyright © 2000 OPNET Technologies, Inc.

Title – 74 Debugging Simulation Models Intro 74Copyright © 2000 OPNET Technologies, Inc.

OPNET Technologies, Inc.

OPNET UNIVERSITY

2000

Question & Answer