27
Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz, Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++ Workshop March 23 rd , 2012 TUHH TUHH Institute of Telematics Institute of Telematics Hamburg University of Technology Hamburg University of Technology

Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

  • Upload
    others

  • View
    11

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Cross-Platform Protocol DevelopmentBased on OMNeT++

Stefan Unterschütz, Andreas Weigel and Volker Turau

SIMUTools 2012: OMNeT++ Workshop

March 23rd, 2012

TUHHTUHHInstitute of TelematicsInstitute of TelematicsHamburg University of TechnologyHamburg University of Technology

Page 2: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

1

Introduction

Page 3: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

IntroductionIntroduction

Motivation

Simulation is indispensablefor the development of

(wireless) network protocols.

OMNeT++ is a powerful tool forsimulations of network protocols.

Base Station

However:Re-implementation of protocols for a target platform is

time-consuming and error-prone

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 33

Page 4: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

IntroductionIntroduction

Motivation

Simulation is indispensablefor the development of

(wireless) network protocols.

OMNeT++ is a powerful tool forsimulations of network protocols.

Base Station

However:Re-implementation of protocols for a target platform is

time-consuming and error-prone

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 33

Page 5: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

IntroductionIntroduction

Introduction

CometOS,a component-based, extensible, tiny

“operating system”

Design Goals� Single code base for protocols, whether running simulations

or executing on target hardware� “Lightweight enough” for resource constrained hardware� Flexibility, extensibility, avoidance of code redundancy� Thereby: speed up protocol development and produce safe

code

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 44

Page 6: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

IntroductionIntroduction

1 Introduction

2 Architecture and Concepts

3 Feasibility

4 Conclusion

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 55

Page 7: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

2

Architecture and Concepts

Page 8: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Architecture

User Code

Appl.

Rout.Rout.

ForkNBH

CSMA

CometOS Core

Module

InputGate

OutputGate

Message

Object

CometOSHIL

ATmega128RFA1 other platforms

SchedulerMAC AL

completely

indep

enden

t

platform

indep

enden

t

platform dependent

Hardware platform

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 77

Page 9: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Architecture

User Code

Appl.

Rout.Rout.

ForkNBH

CSMA

CometOS Core

Module

InputGate

OutputGate

Message

Object

CometOSHIL

ATmega128RFA1 other platforms

SchedulerMAC AL

completely

indep

enden

t

platform

indep

enden

t

platform dependent

Hardware platform

User Code

Appl.

Rout.Rout.

ForkNBH

CSMA

Module

InputGate

OutputGate

Message

Object

MAC AL

CometOSAdapter

OMNeT

++

completely

indep

enden

tOMNeT++ simulation

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 77

Page 10: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Gates and Message Passing

Message handlers are executed non-preemptively(millisecond precision)

� Adoption of OMNeT++ message and gate concept� Added type safety

� Gates instantiated with a certain message type� Connections between gates are checked at compile time⇒ dynamic_casts can be avoided

� Decrease of boilerplate code� Gates and self-messages directly bound to handler methods� No handleMessage() dispatch code necessary

� User-defined messages� Created by deriving from base class� Basic message types provided: Request/Confirm, Indication

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 88

Page 11: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Message Passing (2)

class MyMsg: public Message { } ;

class MyReceiver :

public Module {

public :

InputGate <MyMsg> gate In ;

MyReceiver ( ) :

ga te In ( this ,

&MyReceiver : : handle ,

" gate In " )

{ }

void handle (MyMsg *msg) {

delete msg ;

}

} ;

class MySender :

public Module {

public :

OutputGate <MyMsg> gateOut ;

MySender ( ) :

gateOut ( this , " gateOut " )

{ }

void i n i t i a l i z e ( ) {

schedule (new Message ,

&MySender : : t r a f f i c , 5 0 0 ) ;

}

void t r a f f i c ( Message *msg) {

gateOut . send (new MyMsg ) ;

delete msg ;

}

} ;

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 99

Page 12: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

MAC abstraction layer

� Goal: Basis for arbitrary, platform-independent MAC protocols(CSMA, TDMA, LPL, LPP)

� Should support Link-Layer ACKs, CCA, Random Backoffs

� Hardware-supported functions of 802.15.4 transceivers

MAL

CSMA TDMA BoxMAC . . .

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1010

Page 13: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Airframes and Serialization� Actual over-the-air packet: Managed byte array (Airframe)� Support for serialization of simple types� User-defined types (structs, classes):⇒ serialization user-provided

struct NwkHeader {

uint16_t dst ;

uint16_t source ;

}

void s e r i a l i z e ( ByteVector &bu f fe r , const NwkHeader &value ) {

s e r i a l i z e ( bu f fe r , value . ds t ) ;

s e r i a l i z e ( bu f fe r , value . source ) ;

}

. . .

NwkHeader nwk (SINK_ADDR, ge t Id ( ) ) ;

request−>getA i r f rame ( ) . s e r i a l i z e (nwk ) ;

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1111

Page 14: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Initialization

For OMNeT++

⇒ .ned, .ini files

/ / Setup f o r OMNeT++ i n NED language

/ / ( skipped d e c l a r a t i o n o f modules )

network Network {

submodules :

s : MySender ;

r : MyReceiver ;

connections :

s . gateOut −−> r . gate In ;

}

For Hardware Platforms:

⇒ C++ initialization file

/ / Setup f o r Hardware

MySender s ;

MyReceiver r ;

i n t main ( ) {

s . gateOut . connectTo ( r . ga te In ) ;

cometos : : i n i t i a l i z e ( ) ;

cometos : : run ( ) ;

return 0;

}

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1212

Page 15: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Base Station Support

� Currently under development� Python wrapper for existing CometOS C++ code (SWIG)

� Reuse protocol implementation for a base station� Usable with real testbed or OMNeT++ real-time simulation and

TCP/IP connector� Integration of powerful remote access methodology

� Read/write of variables� Remote execution of methods� Subscribe to events

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1313

Page 16: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Base Station Support

class MyModule :

public RemoteModule {

public :

MyModule ( const char * name) :

RemoteModule (name) { }

void i n i t i a l i z e ( ) {

declareRemote (&MyModule : : add ,

" add " ) ;

}

uint16_t add ( uint8_t &a ,

uint8_t &b ) {

return a+b ;

}

} ;

MyModule m( " myModule " ) ;

r =RemoteModule ( " myModule " ) ;

r . declareRemote ( " add " ,

u in t16_ t ,

u in t8_ t ,

u i n t 8 _ t )

pr in t r . add (18 , 11)

>>> 29

↑ Python console

← CometOS-Module

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1313

Page 17: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Architecture and ConceptsArchitecture and Concepts

Typical Development Steps

OMNeT++ Simulation

Base Station

OMNeT++ Simulation

C++/PythonBase Station

Real-World Deployment

C++/PythonBase Station

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1414

Page 18: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

3

Feasibility

Page 19: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

FeasibilityFeasibility

Resource Demand

� Minimum example (MySender, MyReceiver)

MCU Flash RAM

ATmega128RFA1 4148 bytes 145 bytes

LPC1763 3136 bytes 120 bytes

� 7 modules, forked protocol stack

MCU Flash RAM

ATmega128RFA1 10 kB 649 bytes

LPC1763 7 kB 580 bytes

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1616

Page 20: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

FeasibilityFeasibility

Simulation Accuracy� Comparison of RTTs from field installation (93 nodes at heliostat

power plant in Jülich) and simulation for different number of hops

1 2 3 4

10

20

30

40

hops

round-trip

time[m

s]

Fieldtest Sim

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1717

Page 21: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

4

Conclusion

Page 22: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

ConclusionConclusion

Conclusion, Future Work

� CometOS meets its design goals� Protocol implementations reusable on target hardware� “Lightweight enough”

� Field test at heliostat power plant in Jülich, Germany successfullyrunning since May 2011

� Current and Future Work:� Smart Metering application based on CometOS� Improvement and extension of interface to driver layer� Direct support for logging and statistics recording and reporting

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 1919

Page 23: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Cross-Platform Protocol DevelopmentBased on OMNeT++

Stefan Unterschütz, Andreas Weigel and Volker Turau

SIMUTools 2012: OMNeT++ Workshop

March 23rd, 2012Andreas WeigelResearch Assistant

Phone +49 / (0)40 428 78 3746

e-Mail [email protected]

http://www.ti5.tu-harburg.de/staff/weigel

TUHHTUHHInstitute of TelematicsInstitute of TelematicsHamburg University of TechnologyHamburg University of Technology

Page 24: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Resource Demand Revisited

� RAM usage depends on target architecture (e.g., 8 bit vs 32 bit)� Values for 32 bit MCU

� Module: 8 Bytes� InputGate: 16 Byte� OutputGate: 4 Byte� RemoteModule: 30 Bytes (including Module)� Standard modules Layer and Endpoint with 4 and 2 Gates require

70 bytes and 50 bytes

� ROM usage even more depends on architecture, instruction set,compiler etc.

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 2121

Page 25: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Experiment Setup

� Packets with 50 bytes payload

� 100 measurements per node

� 802.15.4 (2.4 GHz ISM band, 250 kbps)

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 2222

Page 26: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Cross-Layer Support

Communication between non-adjacent modules?

� Similar to OMNeT++’s ControlInfo or ns3’s objectaggregation:

� Attach arbitrary objects to Messages and Airframes

� Example: Setting MAC txPower from higher layer:

/ / A p p l i c a t i o n : se t t x power to −20 dBm

request−>add (new MacTxPower(−20));

. . .

/ / MAC: use MacTxPower i f se t

MacTxPower* txPower= request−>get <MacTxPower > ( ) ;

i f ( txPower != NULL) { . . . }

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 2323

Page 27: Cross-Platform Protocol Development Based on OMNeT++ · Cross-Platform Protocol Development Based on OMNeT++ Stefan Unterschütz,Andreas Weigel and Volker Turau SIMUTools 2012: OMNeT++

Cross-Layer Support

Communication between non-adjacent modules?

� Similar to OMNeT++’s ControlInfo or ns3’s objectaggregation:

� Attach arbitrary objects to Messages and Airframes

� Example: Setting MAC txPower from higher layer:

/ / A p p l i c a t i o n : se t t x power to −20 dBm

request−>add (new MacTxPower(−20));

. . .

/ / MAC: use MacTxPower i f se t

MacTxPower* txPower= request−>get <MacTxPower > ( ) ;

i f ( txPower != NULL) { . . . }

Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++Andreas Weigel Cross-Platform Protocol Development Based on OMNeT++ 2323