Table Of ContentUnlockingthePowerofOPNETModeler
Forfast,easymodeling,thispracticalguideprovidesalltheessentialinformationyou
needtoknow.Awiderangeoftopicsiscovered,includingcustomprotocols,program-
minginC++,ExternalModelAccess(EMA)modeling,andco-simulationwithexternal
systems,givingyoutheguidancenotprovidedintheOPNETdocumentation.Asetof
high-levelwrapperAPIsisalsoincludedtosimplifyprogrammingcustomOPNETmod-
els,whetheryouareanewcomertoOPNEToranexperienceduserneedingtomodel
ef(cid:383)ciently. From the basic to the advanced, you’ll (cid:383)nd topics are easy to follow with
theory kept to a minimum, many practical tips and answers to frequently asked ques-
tionsspreadthroughoutthebook,andnumerousstep-by-stepcasestudiesandreal-world
networkscenariosincluded.
ZhengLureceivedhisPh.D.fromtheUniversityofEssex,afterwhichhestayedonto
researchopticalnetworksandwirelesssensornetworks.Heisexperiencedinmodeling
network protocols and has many years of experience using OPNET Modeler in his
researchandlaboratorydemonstrations.
HongjiYangiscurrentlyaProfessorattheSoftwareTechnologyResearchLaboratory,
De Montfort University. He received his Ph.D. from Durham University in 1994 and
wasamaincontributortotheDistributedComputerNetworksprojectsponsoredbythe
ChineseMinistryofEducation,1982–1986.
Unlocking the Power
of OPNET Modeler
ZHENG LU
HONGJI YANG
cambridge university press
Cambridge,NewYork,Melbourne,Madrid,CapeTown,
Singapore,SãoPaulo,Delhi,Tokyo,MexicoCity
CambridgeUniversityPress
TheEdinburghBuilding,CambridgeCB28RU,UK
PublishedintheUnitedStatesofAmericabyCambridgeUniversityPress,NewYork
www.cambridge.org
Informationonthistitle:www.cambridge.org/9780521198745
©CambridgeUniversityPress2012
Thispublicationisincopyright.Subjecttostatutoryexception
andtotheprovisionsofrelevantcollectivelicensingagreements,
noreproductionofanypartmaytakeplacewithoutthewritten
permissionofCambridgeUniversityPress.
Firstpublished2012
PrintedintheUnitedKingdomattheUniversityPress,Cambridge
AcataloguerecordforthispublicationisavailablefromtheBritishLibrary
LibraryofCongressCataloguinginPublicationdata
Lu,Zheng.
UnlockingthepowerofOPNETmodeler/ZhengLu,HongjiYang.
p. cm.
Includesbibliographicalreferencesandindex.
ISBN978-0-521-19874-5(hardback)
1. Computernetworks–Mathematicalmodels. 2. Computernetworks–Simulationmethods.
3. Computernetworkprotocols. I. Yang,Hongji. II. Title.
TK5105.5.L825 2011
005.7(cid:2)13–dc23 2011032466
ISBN978-0-521-19874-5Hardback
Additionalresourcesforthispublicationatwww.cambridge.org/9780521198745
CambridgeUniversityPresshasnoresponsibilityforthepersistenceor
accuracyofURLsforexternalorthird-partyInternetwebsitesreferredtoin
thispublication,anddoesnotguaranteethatanycontentonsuchwebsitesis,
orwillremain,accurateorappropriate.
Contents
Preface xi
Listofabbreviations xiii
PartI PreparationforOPNETModeling 1
1 Introduction 3
1.1 Networkmodelingandsimulation 3
1.2 IntroductiontoOPNET 4
1.3 OPNETModeler 5
1.4 Summary 6
1.5 Theoreticalbackground 6
1.5.1 Simulationandprinciplesofsimulator 6
1.5.2 Hybridsimulation 9
2 InstallationofOPNETModelerandsettingupenvironments 11
2.1 SystemrequirementsforusingOPNETModeler 11
2.2 InstallationonWindows 11
2.2.1 InstallationofOPNETModeler 12
2.2.2 Installationandcon(cid:383)gurationofMicrosoftVisualC++ 15
2.2.3 OPNETModelerpreferencesforC/C++compiler 17
2.2.4 Licensing 19
2.3 InstallationonLinux 20
2.3.1 InstallationofOPNETModeler 20
2.3.2 Installationandcon(cid:383)gurationofGCCcompiler 21
2.3.3 OPNETModelerpreferencesforGCC
compiler 21
2.3.4 Licensing 22
2.4 Theoreticalbackground 23
2.4.1 Compilationandlinkingoptions 23
2.4.2 Simulationmodelscompilationandlinking 23
vi Contents
3 OPNETModeleruserinterface 24
3.1 Projectmanagement 24
3.2 Modelerpreferences 26
3.3 OPNETeditors 29
3.3.1 ProjectEditor 29
3.3.2 NodeEditor 31
3.3.3 ProcessEditor 31
3.3.4 LinkEditor 32
3.3.5 PacketFormatEditor 32
3.3.6 ICIEditor 34
3.3.7 PDFEditor 35
3.3.8 ProbeEditor 35
3.4 SimulationResultsBrowser 37
3.5 AnimationViewer 37
3.6 UsingOPNETdocumentation 39
PartII ModelingCustomNetworksandProtocols 41
4 OPNETprogramminginterfaces 43
4.1 IntroductiontoOPNETprogramming 43
4.2 OPNETAPIcategorization 44
4.3 KernelAPIs/KernelProcedures(KPs) 45
4.3.1 DistributionPackage 46
4.3.2 PacketPackage 49
4.3.3 QueuePackageandSubqueuePackage 51
4.3.4 StatisticPackage 51
4.3.5 Segmentationandreassemblypackage 52
4.3.6 Topologypackage 52
4.3.7 ProgrammingSupportAPIs 54
4.4 Theoreticalbackground 54
4.4.1 Proto-Cspeci(cid:383)cations 54
4.4.2 Processmodelandexternalmodelaccess(EMA)program 56
4.4.3 OPNETModelermodelprogrammingexternalinterfaces:
co-simulation,externaltoolsupport(ETS)andOPNET
DevelopmentKit(ODK) 56
5 CreatingandsimulatingcustommodelsusingOPNETAPIs 58
5.1 Generalprocedureforcreatingandsimulatingcustommodels 58
5.2 Custommodels 59
5.2.1 Case1 59
5.2.2 Case2 68
5.2.3 Case3 70
Contents vii
5.2.4 Case4 74
5.2.5 Case5 79
5.2.6 Case6 83
5.2.7 Case7 95
5.3 Modeloptimizationandvalidation 96
6 High-levelwrapperAPIs 100
6.1 WhyandhowtousewrapperAPIs 100
6.2 WrapperAPIsprovidedwiththebook 101
6.2.1 Geo_TopowrapperAPIs 102
6.2.2 RoutingwrapperAPIs 104
6.2.3 FlowwrapperAPIs 106
6.3 HowtowriteyourownwrapperAPI 107
7 Modelingwithhigh-levelwrapperAPIs 110
7.1 Revisitofpreviouscase 110
7.2 Creatingconnection-orientedcommunications 112
7.2.1 Single(cid:384)ow 114
7.2.2 Trunkof(cid:384)ows 119
PartIII ModelingandModifyingStandardNetworksandProtocols 123
8 Modelingwirednetworkswithstandardmodels 125
8.1 Client/serverstructure 125
8.1.1 Creatinganetworkmodel 125
8.1.2 Task,application,andpro(cid:383)lecon(cid:383)gurations 127
8.1.3 Choosingandviewingstatisticresults 131
8.2 Localareanetwork 132
8.3 WideareaIPnetwork 132
8.4 Automaticnetworkdeployment 134
8.5 Summary 135
9 Modelingwirelessnetworkswithstandardmodels 137
9.1 Basicsofwirelessmodeling 137
9.2 Wirelesslocalareanetworks(WLANs) 138
9.2.1 CommunicationwithinWLANs 138
9.3 CommunicationbetweenWLANs 140
9.4 Wirelessmobilenetworks 143
9.4.1 Movementviatrajectories 143
9.4.2 Facilitiesforrandommobility 146
9.4.3 Movementviaprogramminginterfaces 148
9.5 Automaticnetworkdeployment 148
viii Contents
10 Modifyingstandardmodels 151
10.1 Introduction 151
10.2 Casestudy 151
PartIV OPNETModelingFacilities 165
11 Debuggingsimulation 167
11.1 DebuggingfacilitiesinOPNETModeler 167
11.1.1 Prerequisitesfordebugging 168
11.1.2 Preparingsimulationscenario 168
11.1.3 DebuggingwithODB 169
11.1.4 DebuggingwithCDB/GDB 175
11.1.5 DebuggingwithMicrosoftVisualC++Debugger 177
11.1.6 Debuggingwithanimation 179
12 OPNETprogramminginC++ 182
12.1 Proto-C,C,andC++:languageandlibrarydifferences 182
12.2 MemorymanagementdifferencesbetweenProto-CAPIsand
C/C++standardlibraryfunctions 182
12.3 Proto-Cdatastructuresandalgorithmspackages,C++standardtemplate
libraries(STL)andBoostC++libraries 184
12.4 Environmentcon(cid:383)gurationsforC++programminginOPNET 185
12.5 CasestudyonprogrammingOPNETmodelsinC++ 187
13 TrafficinOPNETsimulation 194
13.1 Introduction 194
13.2 Explicittraf(cid:383)c 194
13.2.1 Explicittraf(cid:383)cbasedonapplication 195
13.2.2 Explicittraf(cid:383)cbasedontraf(cid:383)cgenerationparameters 196
13.2.3 Explicitself-similartraf(cid:383)cbasedonrawpacketgenerator(RPG)
model 197
13.3 Backgroundtraf(cid:383)candhybridsimulation 200
13.3.1 Backgroundtraf(cid:383)cbasedonbaselineload 201
13.3.2 Backgroundtraf(cid:383)cbasedontraf(cid:383)c(cid:384)ow 202
14 Externalmodelaccess(EMA) 207
14.1 WhatEMAisandreasonstouseit 207
14.2 EMAcasestudy 208
15 OPNETco-simulationwiththird-partyprograms 215
15.1 Co-simulationwithexternalprograms 215
Contents ix
15.1.1 Introduction 215
15.1.2 Co-simulationwithanexternalCprogram 216
15.1.3 Creatingsimulationmodels 217
15.1.4 CreatinganexternalCco-simulationcontrollerprogram 221
15.1.5 Runningco-simulation 224
15.1.6 Co-simulationwithothersystems 225
15.2 Co-simulationwithMATLAB 225
15.2.1 Setupofenvironmentvariables 226
15.2.2 ModifyingOPNETmodelsandexternalcode 226
16 Modelauthoringandsecurity 232
16.1 Introduction 232
16.2 Protectingamodel 232
16.3 Makingademomodel 234
16.4 Licensingamodel 234
References 236
Index 237