You are on page 1of 18

Modeling & Simulation

Distributed Virtual Environments (DVE) & Software Introduction

Outline
Intro: DVE example Federated Simulations Basic Services
Class Based Subscription Attribute updates Tick Synchronized delivery: Time management

A Typical DVE Node Simulator


network visual display system

Image Generator terrain database

Other Vehicle State Table own vehicle dynamics

network interface

control/ display interface

sound generator

controls and panels

Execute every 1/30th of a second: receive incoming messages & user inputs, update state of remote vehicles update local display for each local vehicle compute (integrate) new state over current time period send messages indicating new state
Reproduced from Miller, Thorpe (1995), SIMNET: The Advent of Simulator Networking, Proceedings of the IEEE, 83(8): 1114-1123.

Typical Sequence
visual display 3 6 7 4 network interface 8

1. Detect trigger press


Image Generator terrain database Other Vehicle State Table own vehicle dynamics

2. Audio fire sound 3. Display muzzel flash

control/ display interface 1

sound generator 2

4. Send fire message 5. Display muzzel flash 6. Compute trajectory, display tracer 7. Display shell impact

Controls/panels visual display

4 network interface

8 11

8. Send detonation message 9. Display shell impact 10. Compute damage 11. Send Entity state message indicating damage

Image Generator terrain database

Other Vehicle State Table own vehicle dynamics 10

control/ display interface

sound generator

Controls/panels

Federated Simulations
Interconnecting autonomous simulators Federation

Simulation (federate)

Simulation (federate)

Simulation (federate)

Interface Specification

Interface Specification

Runtime Infrastructure(RTI)
Services to create and manage the execution of the federation Federation setup / tear down Transmitting data among federates Synchronization

Federates not designed for a specific federation


Internet gaming simulations
Plug n play capability Number, type of players change dynamically

Department of Defense High Level Architecture


Model reuse: Federates may be used in different federations during its lifetime Legacy simulations: not originally designed for inclusion in federations

Message Passing Alternatives


Traditional message passing mechanisms: Sender explicitly identifies receivers
Destination process, port, etc. Poorly suited for federated simulations

Broadcast
Receiver discards messages not relevant to it Used in SIMNET, DIS (initially) Doesnt scale well to large federations

Publication / Subscription mechanisms


Analogous to newsgroups Producer of information has a means of describing data it is producing Receiver has a means of describing the data it is interested in receiving Used in High Level Architecture (HLA)

Class-Based Data Distribution (simplified)


Federation Object Model (FOM) defines type of information transmitted among federates
Object classes (e.g., tank) Attributes (e.g., position, orientation of turret)

Primitives (Federate/RTI interface)


Publish Object Class Attributes: Called by a federate to declare the
object classes and attributes it is able to update Subscribe Object Class Attributes: Declare the object classes and attributes that the federate is interested in receiving Register Object Instance: Notify RTI an instance of an object has been created within the federate Discover Object Instance: Notify federate an instance of an object of a subscribed class has been registered Update Attribute Values: notify RTI one or more attributes of an object has been modified Reflect Attribute Values: notify federate attributes to which it has subscribed have been modifed

Example
Federate 1
PublishOCA (Tank, position) handle := RegisterOI (Tank) UpdateAV (handle, position, <30,89>)

Federate 2
SubscribeOCA (Tank, position) DiscoverOI (Tank, instance) ReflectAV (instance, position, <30,89>)

RTI

OCA = Object Class Attributes OI = Object Instance AV = Attribute Values

Federated vs. RTI Initiated Services


Some services are initiated by the federate, others by the RTI Federate invoked services
Publish, subscribe, register, update Not unlike calls to a library Procedures defined in the RTI ambassador

RTI invoked services


Discover, reflect Federate defined procedures, in Federate Ambassador

Federate
Federate ambassador Update RTI ambassador Reflect

RTI

Single vs. Multi-threaded


Multi-threaded implementation
RTI software and federate code execute as separate threads of execution Switching execution between RTI and federate largely transparent to the federate

Single-threaded implementation
RTI and federate share a single thread of execution (like libraries) Federate must explicitly pass control to the RTI, e.g., to deliver messages Tick() procedure is defined for this purpose Callbacks (Discover, Reflect) made within Tick

Example: Receiving a Message


Boolean: Waiting4Message; { Waiting4Message := TRUE; while (Waiting4Message) Tick(); }

Federate
Tick

RTI

ReflectAttributeValues
return (RAV)

/* Federate ambassador */ Proc ReflectAttributeValues () { save incoming message in buffer Waiting4Message := FALSE; }

return (Tick)

Synchronizing Message Delivery


Goal: process all events (local and incoming messages) in time stamp order; To support this, RTI will Deliver messages in time stamp order (TSO) Synchronize delivery with simulation time advances
TSO messages

RTI
T

next TSO message

next local event T logical time

local events

federate
current time

Federate: next local event has time stamp T If no TSO messages w/ time stamp < T, advance to T, process local event If there is a TSO message w/ time stamp T T, advance to T and process TSO message

Next Event Request (NER)


Federate invokes Next Event Request (T) to request its logical time be advanced to time stamp of next TSO message, or T, which ever is smaller If next TSO message has time stamp T T
RTI delivers next TSO message, and all others with time stamp T RTI issues Time Advance Grant (T)

Else
RTI advances federates time to T, invokes Time Advance Grant (T) Typical execution sequences

Federate

RTI NER(T) RAV (T) RAV (T)

Federate

RTI NER(T) NER: Next Event Request TAG(T) TAG: Time Advance Grant RAV: Reflect Attribute Values Federate calls in black RTI callbacks in red

TAG(T) RTI delivers events


Wall clock time

no TSO events

Code Example: Event Stepped Federate


sequential simulator T = current simulation time PES = pending event set While (simulation not complete) T = time of next event in PES process next event in PES End-While federated simulator While (simulation not complete) T = time of next event in PES PendingNER = TRUE; NextEventRequest(T) while (PendingNER) Tick(); process next event in PES End-While /* the following federate-ambassador procedures are called by the RTI */ Procedure ReflectAttributeValues () place event in PES Procedure TimeAdvanceGrant () PendingNER = False;

Time Advance Request (TAR)


Typically used by time stepped federates Federate invokes Time Advance Request (T) to request its logical time (LT) be advanced to T RTI delivers all TSO messages with time stamp T RTI advances federates time to T, invokes Time Advance Grant (T) when it can guarantee all TSO messages with time stamp T have been delivered Grant time always matches the requested time
RTI TAR(20) RAV (14) RAV (18) Wall clock time LT=20 TAG(20) Federate calls in black RTI callbacks in red TAR: Time Advance Request RAV: Reflect Attribute Values TAG: Time Advance Grant

Typical execution sequence Federate LT=10

Code Example: Time Stepped Federate


sequential simulator T = current simulation time While (simulation not complete) update local simulation state T = T + T; End-While federated simulator While (simulation not complete) update local simulation state UpdateAttributeValues () PendingTAR = TRUE; TimeAdvanceRequest(T+ T) while (PendingTAR) Tick(); T = T + T; End-While /* the following federate-defined procedures are called by the RTI */ Procedure ReflectAttributeValues () update local state Procedure TimeAdvanceGrant () PendingTAR = False;

Summary
Distributed simulation: federates, RTI Federates
Model some subset of entities in virtual world Send messages to other federates concerning aspects of entities that are visible to entities in other federates

RTI services
Setting up and realizing communication among federates Control and management of federation execution Synchronizing message delivery (if needed)

You might also like