Vous êtes sur la page 1sur 74

OPNET Technologies, Inc.

Presentation

Title

Subtitle

Debugging Simulation Models --

Introduction

Author

2000
2000

OPNET UNIVERSITY

TM

Title 1

Copyright © 2000 OPNET Technologies, Inc.

2000
2000

OPNET UNIVERSITY

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

Title 2

2000
2000

OPNET UNIVERSITY

Items Not Covered • Will not cover…

C programming

Segmentation violation Bus error

OPNET Technologies, Inc.

These topics are covered in the session Debugging Simulation

Models Advanced.

Title 3

2000
2000

OPNET UNIVERSITY

Prerequisites

Familiarity with

OPNET Modeler model hierarchy

Creating process models Running simulations

OPNET Technologies, Inc.

Title 4

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Agenda

Interpreting error messages

Identifying the problem Using the OPNET Debugger (ODB)

Viewing animation for debugging

Title 5

2000
2000

OPNET UNIVERSITY

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

Behavioral

Simulation completes successfully, but does not accurately represent the modeler‟s intent.

Illustrated in Lab 2

Title 6

2000
2000

OPNET UNIVERSITY

Object Reference

Objects can be identified in two ways

Object ID: Unique integer identifying object

Object Name: Hierarchical name of object:

OPNET Technologies, Inc.

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

Title 7

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Simulation Log

Records notable events for every scenario

• Recreated every time a scenario‟s simulation is run

Describes problems

Suggests solutions

Gives informational messages

• Suggests solutions • Gives informational messages Title – 8 Debugging Simulation Models Intro Copyright

Title 8

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

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

 

Title 9

2000
2000

OPNET UNIVERSITY

Error Message Fields

OPNET Technologies, Inc.

|----------------------------------------------------------------------------|

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

Debugging Simulation Models Intro

Title 10

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 10 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 11 Inc.

2000
2000

OPNET UNIVERSITY

Example Function Call Stack

<<< Program Abort >>>

.

.

.

* Function call stack: (builds down)

OPNET Technologies, Inc.

------------------------------------------------------------

Call

Count Line# Function

Block

------------------------------------------------------------

Sim.

Kernel

Error

Message

Printing

Sim. Kernel Error Message Printing 0) 1) 2) 3) 4) 5) 6) 7) 8) 9) 1

0)

1)

2)

3)

4)

5)

6)

7)

8)

9)

1

1

1

1

6

5

1

1

1

1

125 m3_main (argc, argv)

519 sim_main (prog_name, argc, argv, dynamic, 935 sim_ev_loop ()

Process model

and state

79

sim_strm_insert ()

)

KP reporting

problem

477 sim_obj_qps_intrpt (simev_ptr)

477 sim_obj_qps_intrpt (simev_ptr)

0

60

pksw_nd_proc () [xmt enter execs]

op_pk_nfd_set (pkptr, fd_name, value, <

sim_obj_qps_intrpt (simev_ptr) 0 60 pksw_nd_proc () [xmt enter execs] op_pk_nfd_set (pkptr, fd_name, value, < >)

>)

1481 *sim_err_pk_access (pkptr, error_code) 88 *sim_err_issue (pkg_id, msg_id, <subst_values>)

339 sim_err_print (severity_level, str0, str1)

------------------------------------------------------------

Debugging Simulation Models Intro

Title 12

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 12 Inc.

2000
2000

OPNET UNIVERSITY

Block Line Numbers in FCS

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 13

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 13 Inc.

2000
2000

OPNET UNIVERSITY

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

Debugging Simulation Models Intro

Title 14

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 14 Inc.

2000
2000

OPNET UNIVERSITY

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:

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

Debugging Simulation Models Intro

Title 15

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 15 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Debugger (ODB)

ODB capabilities

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 16 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 17 Inc.

2000
2000

OPNET UNIVERSITY

How to Activate / Invoke ODB

OPNET Technologies, Inc.

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:

file • From the command line:  Example use: op_runsim -net_name project1-scenario1 -debug Debugging

op_runsim -net_name project1-scenario1 -debug

Debugging Simulation Models Intro

Title 18

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 18 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Invoking and Exiting ODB % op_runsim -net_name example -debug < simulation banner > OPNET Simulation
Invoking and Exiting ODB
% op_runsim -net_name example -debug
<
simulation
banner
>
OPNET Simulation Debugger
Type „help‟ for Command Summary
Time 0, before begsim interrupts are delivered
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

Debugging Simulation Models Intro

Title 19

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 19 Inc.

2000
2000

OPNET UNIVERSITY

Getting Help in ODB

OPNET Technologies, Inc.

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 help <category> help <command>

-- displays summary of help categories. -- display help on specified category. -- display help on specified command.

Command Categories [builtin]

all

basic

action

Debugging Simulation Models Intro

Title 20

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 20 Inc.

2000
2000

OPNET UNIVERSITY

ODB: Lesson Plan

Breakpoints

Traces

Labels

Lab 1

Break

Maps

Entity Information

Lab 2

Diagnostic Block

Memory Allocation

Debugging Simulation Models Intro

OPNET Technologies, Inc.

Title 21

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 21 Inc.

2000
2000

OPNET UNIVERSITY

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 execution until a breakpoint occurs

Debugging Simulation Models Intro

breakpoint pending 00:51 00:45 00:31 00:21 00:05 ExecutionEventMultiple
breakpoint
pending
00:51
00:45
00:31
00:21
00:05
ExecutionEventMultiple

00:59

cont

Title – 22 breakpointset 00:51 next breakpointset 00:45 next breakpointset 00:31 next breakpointset 00:21
Title – 22
breakpointset
00:51
next
breakpointset
00:45
next
breakpointset
00:31
next
breakpointset
00:21
next
breakpointset
00:05
next
ExecutionEventSingle

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 22 Inc.

2000
2000

OPNET UNIVERSITY

Breakpoints: cont and next

OPNET Technologies, Inc.

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

breakpoint pending 00:51 00:45 00:31 00:21 00:05 ExecutionEventMultiple
breakpoint
pending
00:51
00:45
00:31
00:21
00:05
ExecutionEventMultiple

00:59

cont

Debugging Simulation Models Intro

breakpointset 00:51 breakpointset 00:45 breakpointset 00:31 breakpointset 00:21 breakpointset 00:05
breakpointset
00:51
breakpointset
00:45
breakpointset
00:31
breakpointset
00:21
breakpointset
00:05
ExecutionEventSingle

next

next

next

next

next

Title 23

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 23 Inc.

2000
2000

OPNET UNIVERSITY

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 : execution ID (10), schedule ID (#20), type (stream intrpt)

* Source : execution ID (9), top.pksw1.node_0.src (ideal generator)

* Data

> Module : top.pksw1.node_0.proc (processor)

: 9.08349170694 sec, [00d 00h 00m 09s . 083ms 491us 706ns 942ps]

:

instrm (1), packet ID (1)

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

Debugging Simulation Models Intro

Title 24

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 24 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 25

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 25 Inc.

2000
2000

OPNET UNIVERSITY

Breakpoints: Reviewing

OPNET Technologies, Inc.

status command displays all pending breakpoints

odb> evstop 34

odb> tstop 40

odb> status

Breakpoints :

1)

2)

Traces :

None

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

Debugging Simulation Models Intro

Title 26

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 26 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 27 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 28 Inc.

2000
2000

OPNET UNIVERSITY

Traces: Interpretation

OPNET Technologies, Inc.

* 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 State banner

from process (“pk_sink”) Process invocation State banner KP invocations State banner Process return Debugging
from process (“pk_sink”) Process invocation State banner KP invocations State banner Process return Debugging
from process (“pk_sink”) Process invocation State banner KP invocations State banner Process return Debugging

KP invocations

State banner Process return

State banner KP invocations State banner Process return Debugging Simulation Models Intro Title – 29 Copyright
State banner KP invocations State banner Process return Debugging Simulation Models Intro Title – 29 Copyright

Debugging Simulation Models Intro

Title 29

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 29 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Traces: Interpreting KP Trace Format

Technologies, Inc. Traces: Interpreting KP Trace Format • Kernel Procedure invocation argument values • Kernel

Kernel Procedure invocation argument values

Kernel Procedure return values

Debugging Simulation Models Intro

Title 30

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 30 Inc.

2000
2000

OPNET UNIVERSITY

Traces: Basic Commands

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 31

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 31 Inc.

2000
2000

OPNET UNIVERSITY

Traces: Reviewing

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 32 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 33 Inc.

2000
2000

OPNET UNIVERSITY

Labels

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 34 Inc.

2000
2000

OPNET UNIVERSITY

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

OPNET Technologies, Inc.

Sets a trace for a specified process model and label

Debugging Simulation Models Intro

Title 35

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 35 Inc.

2000
2000

OPNET UNIVERSITY

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 : execution ID (15204), schedule ID (#15605), type (remote intrpt)

* Source : execution ID (15203), top.Office network.DEVELOPMENT.tcp (processor)

* Data

> Module : top.Office network.DEVELOPMENT.tcp (processor)

: 972.409334997 sec, [00d 00h 16m 12s . 409ms 334us 997ns 496ps]

:

code (10)

|

Removing connection (14) from TCB list.

Debugging Simulation Models Intro

Title 36

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 36 Inc.

2000
2000

OPNET UNIVERSITY

A Basic Debugging Paradigm

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 37 Inc.

2000
2000

OPNET UNIVERSITY

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

Packets are evenly routed between 4 nodes via a hub Scenario node_0 model hub model •

node_0 model

routed between 4 nodes via a hub Scenario node_0 model hub model • Open Project Editor

hub model

between 4 nodes via a hub Scenario node_0 model hub model • Open Project Editor and

Open Project Editor and load pksw_net

Open lab1 scenario

Debugging Simulation Models Intro

Title 38

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 38 Inc.

2000
2000

OPNET UNIVERSITY

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:

* Program:

* Function: sim_err_print (severity_level, str0, str1)

* Error:

20:28:15 Sun Aug 06 2000

op_runsim (Version 7.0.B PL6 Build 1086)

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 39 Inc.

2000
2000

OPNET UNIVERSITY

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 : 8.9356938109 sec,
3. cont to continue until event 6
(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)"

4. fulltrace to toggle global tracing

5. next to execute pending event

Debugging Simulation Models Intro

Title 40

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 40 Inc.

2000
2000

OPNET UNIVERSITY

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 THREAD 236: strm. is empty.

(0)

THREAD 236: strm. index THREAD 236: strm. is empty. (0) * THREAD 236: op_dist_outcome (dist_ptr) THREAD

* THREAD 236: op_dist_outcome (dist_ptr)

THREAD 236: dist. ptr. THREAD 236: distribution THREAD 236: outcome

(0x00901EA8)

(uniform_int (0.000000000e+000, 3.0000000000e+000))

(1.0)

<<< Program Abort >>>

* Time:

* Program:

* Function: sim_err_print (severity_level, str0, str1)

* Error:

20:44:52 Sun Aug 06 2000

op_runsim (Version 7.0.B PL6 Build 1086)

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 41 Inc.

2000
2000

OPNET UNIVERSITY

Lab 1: Correct the Error

1.In the Project Editor double click on

OPNET Technologies, Inc.

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

to

Change pkptr = op_pk_get (RCV_IN_STRM)

of xmt state to Change pkptr = op_pk_get (RCV_IN_STRM) pkptr = op_pk_get (SRC_IN_STRM) 3. Compile process
of xmt state to Change pkptr = op_pk_get (RCV_IN_STRM) pkptr = op_pk_get (SRC_IN_STRM) 3. Compile process

pkptr = op_pk_get (SRC_IN_STRM)

3. Compile process model

Debugging Simulation Models Intro

3. Compile process model Debugging Simulation Models Intro Title – 42 Copyright © 2000 OPNET Technologies,

Title 42

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 42 Inc.

2000
2000

OPNET UNIVERSITY

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

Debugging Simulation Models Intro

Title 43

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 43 Inc.

2000
2000

OPNET UNIVERSITY

Debugging Simulation Models Intro

Break

OPNET Technologies, Inc.

Title 44

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 44 Inc.

2000
2000

OPNET UNIVERSITY

Maps

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 45 Inc.

2000
2000

OPNET UNIVERSITY

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: Hierarchical name of object Obj Type: Description of class of object Parent ID: Object ID of parent object

Unique integer identifying object

Debugging Simulation Models Intro

Title 46

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 46 Inc.

2000
2000

OPNET UNIVERSITY

Maps: Basic Commands

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 47

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 47 Inc.

2000
2000

OPNET UNIVERSITY

Entity Information

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 48 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 49

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 49 Inc.

2000
2000

OPNET UNIVERSITY

Entity Information: Example

OPNET Technologies, Inc.

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

Debugging Simulation Models Intro

Title 50

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 50 Inc.

2000
2000

OPNET UNIVERSITY

Entity Information: Obtaining

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 51 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Lab 2: Using Entity Information

Problem: Unexpected simulation results: all packets are received

by node_0

simulation results: all packets are received by node_0 • The error may indicate a problem with

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 52 Inc.

2000
2000

OPNET UNIVERSITY

Lab 2: Unexpected Results

prompt% op_runsim -net_name pksw_net-lab1

OPNET Technologies, Inc.

|-----------------------------------------------------------------------------|

|

|

|

|-----------------------------------------------------------------------------|

| Module (11), (top.pksw1.node_0.proc)

| From procedure: pksw_nd_proc1 () [end enter execs]

| From procedure: pksw_nd_proc1 () [end enter execs] | Node node_0: received 89 packets.

| Node node_0: received 89 packets.

|-----------------------------------------------------------------------------|

|

|

|

|-----------------------------------------------------------------------------|

| Module (22), (top.pksw1.node_1.proc)

| From procedure: pksw_nd_proc1 () [end enter execs]

| From procedure: pksw_nd_proc1 () [end enter execs] | Node node_1: received 0 packets. < Other

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

|

|-----------------------------------------------------------------------------|

Debugging Simulation Models Intro

Title 53

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 53 Inc.

2000
2000

OPNET UNIVERSITY

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 : execution ID (5), schedule ID (#10), type (self intrpt)

* Source : execution ID (-1), top.pksw1.node_1.src (ideal generator)

* Data

> Module : top.pksw1.node_1.src (ideal generator)

: 8.9356938109 sec, [00d 00h 00m 08s . 935ms 693us 810ns 900ps]

:

code (0)

odb> next

* THREAD 305: generating packet THREAD 305: packet ID

(0)

THREAD 305: bulk size

(9600)

THREAD 305: total size

(9600)

Debugging Simulation Models Intro

Title 54

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 54 Inc.

2000
2000

OPNET UNIVERSITY

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
4. next to observe a packet field being set
odb> next
* THREAD 305: op_pk_get (instrm_index)
THREAD 305: strm. index
THREAD 305: packet ID
(1)
(0)
* THREAD 305: op_pk_nfd_set (pkptr, fd_name, value, <
>)
THREAD 305: packet ID
THREAD 305: field name
(0)
(dest_address)
THREAD 305: field type
(integer)
THREAD 305: field value
THREAD 305: field size
(1)
(0)
* THREAD 305: op_pk_send (pkptr, outstrm_index)
THREAD 305: packet ID
THREAD 305: stream index
(0)
(0)

Debugging Simulation Models Intro

Title 55

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 55 Inc.

2000
2000

OPNET UNIVERSITY

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

:

0

THREAD 305: tree ID

:

0

THREAD 305: address THREAD 305: format

: 0x8AAB90 : 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
dest_address

integer

1
1

0

Debugging Simulation Models Intro

Title 56

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 56 Inc.

2000
2000

OPNET UNIVERSITY

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 : execution ID (15), schedule ID (#25), type (stream intrpt)

* Source : execution ID (14), top.pksw1.hub.rcv3 (pt-pt receiver)

* Data

> Module : top.pksw1.hub.hub (processor)

:

9.9356938109 sec, [00d 00h 00m 09s . 935ms 693us 810ns 900ps]

:

instrm (3), packet ID (0)

breakpoint trapped : "stop at event (15)"

Debugging Simulation Models Intro

Title 57

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 57 Inc.

2000
2000

OPNET UNIVERSITY

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:
9. Observe further manipulation of packet
odb> next
* THREAD 305: op_pk_get (instrm_index)
THREAD 305: strm. index
THREAD 305: packet ID
(3)
(0)
* THREAD 305: op_pk_nfd_set (pkptr, fd_name, value, <
>)
THREAD 305: packet ID
THREAD 305: field name
THREAD 305: field type
THREAD 305: field value
THREAD 305: field size
(0)
(dest_address)
(integer)
(0)
(0)
* THREAD 305: op_pk_send (pkptr, outstrm_index)
THREAD 305: packet ID
(0)
THREAD 305: stream index
(0)

Debugging Simulation Models Intro

Title 58

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 58 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Lab 2: Tracing One Packet (continued)

10. pkprint to observe contents of packet fields odb> pkprint * THREAD 305: packet contents:
10. pkprint to observe contents of packet fields
odb> pkprint
* THREAD 305: packet contents:
THREAD 305: ID
:
0
THREAD 305: tree ID
THREAD 305: address
THREAD 305: format
:
0
: 0x8AAB90
: pksw_format
THREAD 305: creation module : top.pksw1.node_1.src
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
:
8.93569
: top.pksw1.node_1.src
:
8.93569
:
9600
:
9600
: top.pksw1.hub.strm_8
:
NONE
:
on
:
off
:
NONE
THREAD 305: Index
Name
Type
Value
Size
THREAD 305: 0
dest_address
integer
0
0

Debugging Simulation Models Intro

Title 59

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 59 Inc.

2000
2000

OPNET UNIVERSITY

Lab 2: Localization of Error

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 60 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Lab 2: Correct the Error

1. In the project editor double click on

Correct the Error 1. In the project editor double click on • node hub to see

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 61 Inc.

2000
2000

OPNET UNIVERSITY

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]

| From procedure: pksw_nd_proc2 () [end enter execs] | Node node_0: received 22 packets.

| Node node_0: received 22 packets.

|-----------------------------------------------------------------------------|

|

|

|

| Node node_1: received 23 packets.

| Module (22), (top.pksw1.node_1.proc)

| From procedure: pksw_nd_proc2 () [end enter execs]

| From procedure: pksw_nd_proc2 () [end enter execs]

|-----------------------------------------------------------------------------|

<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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 62 Inc.

2000
2000

OPNET UNIVERSITY

Diagnostic Block

OPNET Technologies, Inc.

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

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

Title 63

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 63 Inc.

2000
2000

OPNET UNIVERSITY

Diagnostic Block: Example

Code in Diagnostic block:

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 64 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 65 Inc.

2000
2000

OPNET UNIVERSITY

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

Debugging Simulation Models Intro

Title 66

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 66 Inc.

2000
2000

OPNET UNIVERSITY

Memory

OPNET Technologies, Inc.

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

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

Title 67

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 67 Inc.

2000
2000

OPNET UNIVERSITY

Memory: Commands

memstats

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 68 Inc.

2000
2000

OPNET UNIVERSITY

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 other

176

67

-

67

13

-

-

-

-

72

packet

136

36153

0

37001

4915

packet field block (pksw_format) process descriptor

24

36154

0

36201

849

152

5

0

1001

149

--------------------------------------------------------------------------------

……………

--------------------------------------------------------------------------------

Total (KB)

15299

Debugging Simulation Models Intro

Title 69

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 69 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 70 Inc.

2000
2000

OPNET UNIVERSITY

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 71 Inc.

2000
2000

OPNET UNIVERSITY

Summary

Determine the nature of the problem first

Simulation Log

err_log, op_vuerr

OPNET Technologies, Inc.

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 © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 72 Inc.

2000
2000

OPNET UNIVERSITY

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

OPNET Technologies, Inc.

Title 73

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 73 Inc.

2000
2000

OPNET UNIVERSITY

OPNET Technologies, Inc.

Question & Answer

Debugging Simulation Models Intro

Title 74

Copyright © 2000 OPNET Technologies, Inc.

Copyright © 2000 OPNET Technologies, 74 Inc.