E-Book, Englisch, 512 Seiten
Issariyakul / Hossain Introduction to Network Simulator NS2
2. Auflage 2012
ISBN: 978-1-4614-1406-3
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark
E-Book, Englisch, 512 Seiten
ISBN: 978-1-4614-1406-3
Verlag: Springer
Format: PDF
Kopierschutz: 1 - PDF Watermark
Introduction to Network Simulator NS2 is a primer providing materials for NS2 beginners, whether students, professors, or researchers for understanding the architecture of Network Simulator 2 (NS2) and for incorporating simulation modules into NS2. The authors discuss the simulation architecture and the key components of NS2 including simulation-related objects, network objects, packet-related objects, and helper objects. The NS2 modules included within are nodes, links, SimpleLink objects, packets, agents, and applications. Further, the book covers three helper modules: timers, random number generators, and error models. Also included are chapters on summary of debugging, variable and packet tracing, result compilation, and examples for extending NS2. Two appendices provide the details of scripting language Tcl, OTcl and AWK, as well object oriented programming used extensively in NS2.
Autoren/Hrsg.
Weitere Infos & Material
1;Introduction to Network Simulator NS2;3
1.1;Preface;7
1.2;Acknowledgment;13
1.3;Contents;15
1.4;Chapter1 Simulation of Computer Networks;25
1.4.1;1.1 Computer Networks and the Layering Concept;25
1.4.1.1;1.1.1 Layering Concept;26
1.4.1.2;1.1.2 OSI and TCP/IP Reference Models;28
1.4.1.2.1;1.1.2.1 Application Layer;28
1.4.1.2.2;1.1.2.2 Transport Layer;28
1.4.1.2.3;1.1.2.3 Network Layer;29
1.4.1.2.4;1.1.2.4 Link Layer;29
1.4.1.2.5;1.1.2.5 Physical Layer;29
1.4.2;1.2 System Modeling;29
1.4.2.1;1.2.1 Analytical Approach;30
1.4.2.2;1.2.2 Simulation Approach;30
1.4.3;1.3 Basics of Computer Network Simulation;30
1.4.3.1;1.3.1 Simulation Components;31
1.4.3.1.1;1.3.1.1 Entities;31
1.4.3.1.2;1.3.1.2 Resources;32
1.4.3.1.3;1.3.1.3 Activities and Events;32
1.4.3.1.4;1.3.1.4 Scheduler;32
1.4.3.1.5;1.3.1.5 State and Global Variables;32
1.4.3.1.6;1.3.1.6 Random Number Generator;32
1.4.3.1.7;1.3.1.7 Statistics Gatherer;33
1.4.3.2;1.3.2 Simulation Performance;33
1.4.3.3;1.3.3 Confidence Interval;33
1.4.3.4;1.3.4 Choices for Network Simulation Tools;33
1.4.3.4.1;1.3.4.1 Simulation Platform;34
1.4.3.4.2;1.3.4.2 Types of Simulation Tools;34
1.4.3.4.3;1.3.4.3 User Interface;35
1.4.3.4.4;1.3.4.4 Examples of Simulation Tools;35
1.4.4;1.4 Time-Dependent Simulation;35
1.4.4.1;1.4.1 Time-Driven Simulation;36
1.4.4.2;1.4.2 Event-Driven Simulation;37
1.4.5;1.5 A Simulation Example: A Single-Channel Queuing System;38
1.4.5.1;1.5.1 Entities;38
1.4.5.2;1.5.2 State Global Variables;39
1.4.5.3;1.5.3 Resource;39
1.4.5.4;1.5.4 Events;39
1.4.5.5;1.5.5 Simulation Performance Measures and Statistics Gatherers;40
1.4.5.6;1.5.6 Simulation Program;40
1.4.6;1.6 Chapter Summary;43
1.4.7;1.7 Exercises;44
1.5;Chapter2 Introduction to Network Simulator 2 (NS2);45
1.5.1;2.1 Introduction;45
1.5.2;2.2 Basic Architecture;46
1.5.3;2.3 Installation;47
1.5.3.1;2.3.1 Installing an All-In-One NS2 Suiteon Unix-Based Systems;48
1.5.3.2;2.3.2 Installing an All-In-One NS2 Suiteon Windows-Based Systems;48
1.5.4;2.4 Directories and Convention;49
1.5.4.1;2.4.1 Directories;49
1.5.4.2;2.4.2 Convention;49
1.5.4.2.1;2.4.2.1 Terminology;49
1.5.4.2.2;2.4.2.2 Notations;50
1.5.5;2.5 Running NS2 Simulation;51
1.5.5.1;2.5.1 NS2 Program Invocation;51
1.5.5.2;2.5.2 Main NS2 Simulation Steps;52
1.5.6;2.6 A Simulation Example;53
1.5.7;2.7 Including C++ Modules into NS2 and the make Utility;59
1.5.7.1;2.7.1 An Invocation of a make Utility;59
1.5.7.2;2.7.2 A make Descriptor File;59
1.5.7.3;2.7.3 NS2 Descriptor File;62
1.5.8;2.8 Chapter Summary;62
1.5.9;2.9 Exercises;63
1.6;Chapter3 Linkage Between OTcl and C++ in NS2;65
1.6.1;3.1 The Two-Language Concept in NS2;66
1.6.1.1;3.1.1 The Natures of OTcl and C++ Programming Languages;66
1.6.1.2;3.1.2 C++ Programming Styles and Its Applicationin NS2;67
1.6.1.2.1;3.1.2.1 Basic C++ Programming;67
1.6.1.2.2;3.1.2.2 C++ Programming with Input Arguments;68
1.6.1.2.3;3.1.2.3 C++ Programming with Configuration Files;69
1.6.2;3.2 Class Binding;70
1.6.2.1;3.2.1 Class Binding Process;70
1.6.2.2;3.2.2 Defining Your Own Class Binding;71
1.6.2.3;3.2.3 Naming Convention for Class TclClass;72
1.6.3;3.3 Variable Binding;72
1.6.3.1;3.3.1 Variable Binding Methodology;72
1.6.3.2;3.3.2 Setting the Default Values;73
1.6.3.3;3.3.3 NS2 Data Types;74
1.6.3.3.1;3.3.3.1 Real and Integer Variables;74
1.6.3.3.2;3.3.3.2 Bandwidth;74
1.6.3.3.3;3.3.3.3 Time;75
1.6.3.3.4;3.3.3.4 Boolean;75
1.6.3.4;3.3.4 Class Instvar;77
1.6.4;3.4 Execution of C++ Statements from the OTcl Domain;77
1.6.4.1;3.4.1 OTcl Commands in a Nutshell;77
1.6.4.1.1;3.4.1.1 OTcl Command Invocation;77
1.6.4.1.2;3.4.1.2 C++ Definition of OTcl Commands;78
1.6.4.1.3;3.4.1.3 Creating Your Own OTcl Commands;78
1.6.4.2;3.4.2 The Internal Mechanism of OTcl Commands;79
1.6.4.2.1;3.4.2.1 OTcl Command Invocation Mechanism;79
1.6.4.2.2;3.4.2.2 OTcl Default Returning Structure;80
1.6.4.2.3;3.4.2.3 Interpretation of the Returned Values;80
1.6.4.3;3.4.3 An Alternative for OTcl Command Invocation;83
1.6.4.4;3.4.4 Non-OOP Tcl Command;83
1.6.4.5;3.4.5 Invoking a TclCommand;83
1.6.4.5.1;3.4.5.1 Creating a TclCommand;84
1.6.4.5.2;3.4.5.2 Defining Your Own TclCommand;85
1.6.5;3.5 Shadow Object Construction Process;86
1.6.5.1;3.5.1 A Handle of a TclObject;86
1.6.5.2;3.5.2 TclObjects Construction Process;87
1.6.5.3;3.5.3 TclObjects Destruction Process;91
1.6.6;3.6 Access the OTcl Domain from the C++ Domain;91
1.6.6.1;3.6.1 Obtain a Reference to the Tcl Interpreter;92
1.6.6.2;3.6.2 Execution of Tcl Statements;92
1.6.6.3;3.6.3 Pass or Receive Results to/from the Interpreter;93
1.6.6.3.1;3.6.3.1 Passing Results to the OTcl Domain;93
1.6.6.3.2;3.6.3.2 Retrieving Results from the OTcl Domain;94
1.6.6.4;3.6.4 TclObject Reference Retrieval;95
1.6.7;3.7 Translation of Tcl Code;96
1.6.8;3.8 Chapter Summary;97
1.6.9;3.9 Exercises;97
1.7;Chapter4 Implementation of Discrete-Event Simulation in NS2;100
1.7.1;4.1 NS2 Simulation Concept;100
1.7.2;4.2 Events and Handlers;101
1.7.2.1;4.2.1 An Overview of Events and Handlers;101
1.7.2.2;4.2.2 Class Object: A Child Class of ClassHandler;102
1.7.2.3;4.2.3 Classes Packet and AtEvent: Child Classes of Class Event;103
1.7.3;4.3 The Scheduler;105
1.7.3.1;4.3.1 Main Components of the Scheduler;105
1.7.3.2;4.3.2 Data Encapsulation and Polymorphism Concepts;105
1.7.3.3;4.3.3 Main Functions of the Scheduler;106
1.7.3.4;4.3.4 Two Auxiliary Functions;108
1.7.3.5;4.3.5 Dynamics of the Unique ID of an Event;109
1.7.3.6;4.3.6 Scheduling–Dispatching Mechanism;109
1.7.3.7;4.3.7 Null Event and Dummy Event Scheduling;111
1.7.3.7.1;4.3.7.1 Scheduling of a Null Event;111
1.7.3.7.2;4.3.7.2 Scheduling of a Dummy Event;111
1.7.4;4.4 The Simulator;112
1.7.4.1;4.4.1 Main Components of a Simulation;112
1.7.4.1.1;4.4.1.1 Interperted Hierarchy;112
1.7.4.1.2;4.4.1.2 Compiled Hierarchy;113
1.7.4.2;4.4.2 Retrieving the Instance of the Simulator;113
1.7.4.3;4.4.3 Simulator Initialization;114
1.7.4.4;4.4.4 Running Simulation;115
1.7.4.5;4.4.5 Instprocs of OTcl Class Simulator;116
1.7.5;4.5 Chapter Summary;116
1.7.6;4.6 Exercises;117
1.8;Chapter5 Network Objects: Creation, Configuration,and Packet Forwarding;119
1.8.1;5.1 Overview of NS2 Components;120
1.8.1.1;5.1.1 Functionality-Based Classification of NS2 Modules;120
1.8.1.2;5.1.2 C++ Class Hierarchy;120
1.8.2;5.2 NsObjects: A Network Object Template;122
1.8.2.1;5.2.1 ClassNsObject;122
1.8.2.2;5.2.2 Packet Forwarding Mechanism of NsObjects;123
1.8.3;5.3 Connectors;123
1.8.3.1;5.3.1 Class Declaration;124
1.8.3.2;5.3.2 OTcl Configuration Commands;125
1.8.3.3;5.3.3 Packet Forwarding Mechanism of Connectors;128
1.8.3.3.1;5.3.3.1 Immediate Packet Forwarding;128
1.8.3.3.2;5.3.3.2 Delayed Packet Forwarding;128
1.8.4;5.4 Chapter Summary;130
1.8.5;5.5 Exercises;131
1.9;Chapter6 Nodes as Routers or Computer Hosts;132
1.9.1;6.1 An Overview of Nodes in NS2;132
1.9.1.1;6.1.1 Routing Concept and Terminology;132
1.9.1.2;6.1.2 Architecture of a Node;133
1.9.1.3;6.1.3 Default Nodes and Node Configuration Interface;134
1.9.2;6.2 Classifiers: Multi-Target Packet Forwarders;135
1.9.2.1;6.2.1 Class Classifier and Its Main Components;135
1.9.2.1.1;6.2.1.1 C++ Variables;135
1.9.2.1.2;6.2.1.2 C++ Functions;136
1.9.2.1.3;6.2.1.3 Main Configuring Interface;137
1.9.2.1.4;6.2.1.4 Main Internal Mechanism;137
1.9.2.2;6.2.2 Port Classifiers;139
1.9.2.3;6.2.3 Hash Classifiers;140
1.9.2.3.1;6.2.3.1 An Overview of Hash Classifiers;140
1.9.2.3.2;6.2.3.2 C++ Implementation of Class HashClassifier;141
1.9.2.3.3;6.2.3.3 Child Classes of Class HashClassifier;143
1.9.2.3.4;6.2.3.4 C++ ClassDestHashClassifier;143
1.9.2.4;6.2.4 Creating Your Own Classifiers;146
1.9.3;6.3 Routing Modules;146
1.9.3.1;6.3.1 An Overview of Routing Modules;146
1.9.3.2;6.3.2 C++ Class RoutingModule;147
1.9.3.3;6.3.3 OTcl Class RtModule;150
1.9.3.3.1;6.3.3.1 Initialization Instprocs;150
1.9.3.3.2;6.3.3.2 Instprocs for Configuring Classifiers;151
1.9.3.4;6.3.4 Built-in Routing Modules;152
1.9.3.4.1;6.3.4.1 The List of Built-in Routing Modules;152
1.9.3.4.2;6.3.4.2 C++ Class BaseRoutingModule and OTcl Class RtModule/Base;152
1.9.4;6.4 Route Logic;153
1.9.4.1;6.4.1 C++ Implementation;153
1.9.4.2;6.4.2 OTcl Implementation;154
1.9.5;6.5 Node Construction and Configuration;155
1.9.5.1;6.5.1 Key Variables of the OTcl Class Nodeand Their Relationship;156
1.9.5.1.1;6.5.1.1 Routing-Related Instvars;156
1.9.5.1.2;6.5.1.2 Classifier-Related Instvars;157
1.9.5.2;6.5.2 Installing Classifiers in a Node;158
1.9.5.3;6.5.3 Bridging a Node to a Transport Layer Protocol;159
1.9.5.4;6.5.4 Adding/Deleting a Routing Rule;161
1.9.5.5;6.5.5 Node Construction and Configuration;161
1.9.5.5.1;6.5.5.1 Node Construction;162
1.9.5.5.2;6.5.5.2 Agent and Route Configuration;164
1.9.6;6.6 Chapter Summary;168
1.9.7;6.7 Exercises;169
1.10;Chapter7 Link and Buffer Management;171
1.10.1;7.1 Introduction to SimpleLink Objects;171
1.10.1.1;7.1.1 Main Components of a SimpleLink;171
1.10.1.1.1;7.1.1.1 Basic Objects;172
1.10.1.1.2;7.1.1.2 Tracing Objects;172
1.10.1.2;7.1.2 Instprocs for Configuring a SimpleLink Object;173
1.10.1.3;7.1.3 The Constructor of Class SimpleLink;174
1.10.2;7.2 Modeling Packet Departure;175
1.10.2.1;7.2.1 Packet Departure Mechanism;175
1.10.2.2;7.2.2 C++ Class LinkDelay;176
1.10.3;7.3 Buffer Management;178
1.10.3.1;7.3.1 Class PacketQueue: A Model for Packet Buffering;179
1.10.3.2;7.3.2 Queue Handler;180
1.10.3.3;7.3.3 Queue Blocking and Callback Mechanism;181
1.10.3.3.1;7.3.3.1 Queue Blocking;181
1.10.3.3.2;7.3.3.2 Callback Mechanism;181
1.10.3.4;7.3.4 Class DropTail: A Child Class of Class Queue;183
1.10.4;7.4 A Sample Two-Node Network;185
1.10.4.1;7.4.1 Network Construction;185
1.10.4.2;7.4.2 Packet Flow Mechanism;185
1.10.5;7.5 Chapter Summary;186
1.10.6;7.6 Exercises;187
1.11;Chapter8 Packets, Packet Headers, and Header Format;188
1.11.1;8.1 An Overview of Packet Modeling Principle;188
1.11.1.1;8.1.1 Packet Architecture;188
1.11.1.2;8.1.2 A Packet as an Event: A Delayed Packet Reception Event;191
1.11.1.3;8.1.3 A Link List of Packets;192
1.11.1.4;8.1.4 Free Packet List;193
1.11.2;8.2 Packet Allocation and Deallocation;194
1.11.2.1;8.2.1 Packet Allocation;194
1.11.2.2;8.2.2 Packet Deallocation;197
1.11.3;8.3 Packet Header;199
1.11.3.1;8.3.1 An Overview of First Level Packet Composition: Offseting Protocol-Specific Header on the Packet Header;200
1.11.3.2;8.3.2 Common Packet Header;201
1.11.3.3;8.3.3 IP Packet Header;202
1.11.3.4;8.3.4 Payload Type;203
1.11.3.5;8.3.5 Protocol-Specific Headers;205
1.11.3.5.1;8.3.5.1 Protocol-Specific Header C++ Classes;205
1.11.3.5.2;8.3.5.2 A Protocol-Specific Header OTcl Class;206
1.11.3.5.3;8.3.5.3 A Protocol-Specific Header Mapping Class;206
1.11.3.6;8.3.6 Packet Header Access Mechanism;209
1.11.3.6.1;8.3.6.1 Retrieving a Reference to Protocol-Specific Header;209
1.11.3.6.2;8.3.6.2 Accessing Packet Attributes in a Protocol-Specific Header;211
1.11.3.7;8.3.7 Packet Header Manager;212
1.11.3.8;8.3.8 Protocol-Specific Header Compositionand Packet Header Construction;213
1.11.4;8.4 Data Payload;219
1.11.5;8.5 Customizing Packets;221
1.11.5.1;8.5.1 Creating Your Own Packet;221
1.11.5.1.1;8.5.1.1 Defining a New Packet Header;222
1.11.5.1.2;8.5.1.2 Defining a New Data Payload;223
1.11.5.2;8.5.2 Activate/Deactivate a Protocol-Specific Header;224
1.11.6;8.6 Chapter Summary;225
1.11.7;8.7 Exercises;226
1.12;Chapter9 Transport Control Protocols Part 1: An Overview and User Datagram Protocol Implementation;228
1.12.1;9.1 UDP and TCP Basics;228
1.12.1.1;9.1.1 UDP Basics;228
1.12.1.2;9.1.2 TCP Basics;229
1.12.1.2.1;9.1.2.1 Error Control Using Basic Acknowledgment and Timeout;230
1.12.1.2.2;9.1.2.2 Window-Based Congestion Control;231
1.12.1.2.3;9.1.2.3 TCP Variants;233
1.12.2;9.2 Basic Agents;233
1.12.2.1;9.2.1 Applications, Agents, and a Low-Level Network;234
1.12.2.2;9.2.2 Agent Configuration;236
1.12.2.3;9.2.3 Internal Mechanism for Agents;237
1.12.2.3.1;9.2.3.1 Related C++ and OTcl Variables;237
1.12.2.3.2;9.2.3.2 Key C++ Functions;237
1.12.2.4;9.2.4 Guidelines to Define a New Transport Layer Agent;241
1.12.3;9.3 UDP and Null Agents;241
1.12.3.1;9.3.1 Null (Receiving) Agents;241
1.12.3.2;9.3.2 UDP (Sending) Agent;242
1.12.3.3;9.3.3 Setting Up a UDP Connection;246
1.12.4;9.4 Chapter Summary;246
1.12.5;9.5 Exercises;247
1.13;Chapter10 Transport Control Protocols Part 2:Transmission Control Protocol;248
1.13.1;10.1 An Overview of TCP Agents in NS2;248
1.13.1.1;10.1.1 Setting Up a TCP Connection;248
1.13.1.2;10.1.2 Packet Transmission and AcknowledgmentMechanism;249
1.13.1.3;10.1.3 TCP Header;250
1.13.1.4;10.1.4 Defining TCP Sender and Receiver;250
1.13.1.4.1;10.1.4.1 Step 3: Implement the Constructor;251
1.13.2;10.2 TCP Receiver;254
1.13.2.1;10.2.1 Class Acker;256
1.13.2.2;10.2.2 Class TcpSink;259
1.13.3;10.3 TCP Sender;261
1.13.4;10.4 TCP Packet Transmission Functions;261
1.13.4.1;10.4.1 Function sendmsg(nbytes);262
1.13.4.2;10.4.2 Function send_much(force,reason,maxburst);263
1.13.4.3;10.4.3 Function output(seqno,reason);265
1.13.4.4;10.4.4 Function send_one() ;267
1.13.5;10.5 ACK Processing Functions;268
1.13.5.1;10.5.1 Function recv(p,h);269
1.13.5.2;10.5.2 Functionrecv_newack_helper(pkt);270
1.13.5.3;10.5.3 Function newack(pkt);272
1.13.5.4;10.5.4 Function dupack_action() ;272
1.13.6;10.6 Timer-Related Functions;273
1.13.6.1;10.6.1 RTT Sample Collection;273
1.13.6.2;10.6.2 RTT Estimation;275
1.13.6.3;10.6.3 Overview of State Variables;276
1.13.6.4;10.6.4 Retransmission Timer;277
1.13.6.5;10.6.5 Function Overview;278
1.13.6.6;10.6.6 Function rtt_update(tao);279
1.13.6.7;10.6.7 Function rtt_timeout();281
1.13.6.8;10.6.8 Function rtt_backoff();282
1.13.6.9;10.6.9 Function set_rtx_timer() and Function reset_rtx_timer( mild,backoff) ;283
1.13.6.10;10.6.10 Function newtimer(pkt);283
1.13.6.11;10.6.11 Function timeout(tno);284
1.13.7;10.7 Window Adjustment Functions;286
1.13.7.1;10.7.1 Function opencwnd() ;287
1.13.7.2;10.7.2 Function slowdown(how);288
1.13.8;10.8 Chapter Summary;290
1.13.9;10.9 Exercises;290
1.14;Chapter11 Application: User Demand Indicator;292
1.14.1;11.1 Relationship Between an Application and a Transport Layer Agent;292
1.14.2;11.2 Applications;295
1.14.2.1;11.2.1 Functions of Classes Application and Agent;296
1.14.2.2;11.2.2 Public Functions of Class Application;297
1.14.2.3;11.2.3 Related Public Functions of Class Agent;299
1.14.2.4;11.2.4 OTcl Commands of Class Application;299
1.14.3;11.3 Traffic Generators;299
1.14.3.1;11.3.1 An Overview of Class TrafficGenerator;300
1.14.3.2;11.3.2 Main Mechanism of a Traffic Generator;302
1.14.3.3;11.3.3 Built-in Traffic Generators in NS2;303
1.14.3.3.1;11.3.3.1 Constant Bit Rate (CBR) Traffic;303
1.14.3.3.2;11.3.3.2 Exponential On/Off Traffic;304
1.14.3.3.3;11.3.3.3 Pareto On/Off Traffic;304
1.14.3.3.4;11.3.3.4 Traffic Trace;305
1.14.3.4;11.3.4 Class CBR_Traffic: An Example TrafficGenerator;306
1.14.4;11.4 Simulated Applications;308
1.14.4.1;11.4.1 File Transfer Protocol;309
1.14.4.2;11.4.2 Telnet;309
1.14.5;11.5 Chapter Summary;310
1.14.6;11.6 Exercises;311
1.15;Chapter12 Wireless Mobile Ad Hoc Networks;312
1.15.1;12.1 An Overview of Wireless Networking;313
1.15.1.1;12.1.1 Mobile Node;313
1.15.1.2;12.1.2 Architecture of Mobile Node;313
1.15.1.2.1;12.1.2.1 Regular Node Part;314
1.15.1.2.2;12.1.2.2 Mobile Extension Part;315
1.15.1.3;12.1.3 General Packet Flow in a Wireless Network Implementation;316
1.15.1.4;12.1.4 Mobile Node Configuration Process;317
1.15.1.4.1;12.1.4.1 Step 1: Mobile Node configuration;318
1.15.1.4.2;12.1.4.2 Step 2: Mobile Node Construction;320
1.15.2;12.2 Network Layer: Routing Agents and Routing Protocols;324
1.15.2.1;12.2.1 Preliminaries for the AODV Routing Protocol;324
1.15.2.1.1;12.2.1.1 Terminology;324
1.15.2.1.2;12.2.1.2 Packet Types;325
1.15.2.2;12.2.2 The Principles of AODV;325
1.15.2.2.1;12.2.2.1 Route Discovery: Identifying a Route to the Destination;326
1.15.2.2.2;12.2.2.2 Route and Neighbor Maintenance;327
1.15.2.3;12.2.3 An Overview of AODV Implementation in NS2;327
1.15.2.3.1;12.2.3.1 File and Class Structure;328
1.15.2.3.2;12.2.3.2 Route Entries and Packet Header;329
1.15.2.4;12.2.4 AODV Routing Agent Construction Process;330
1.15.2.5;12.2.5 General Packet Flow Mechanismin a Wireless Network;331
1.15.2.6;12.2.6 Packet Reception and Processing Function of AODV;331
1.15.2.7;12.2.7 AODV Time-Driven Actions;332
1.15.3;12.3 Data Link Layer: Link Layer Models, Address Resolution Protocols, and Interface Queues;334
1.15.3.1;12.3.1 Link Layer Objects;334
1.15.3.2;12.3.2 Address Resolution Protocol ;334
1.15.3.3;12.3.3 Interface Queues;336
1.15.4;12.4 Medium Access Control Layer: IEEE 802.11;336
1.15.4.1;12.4.1 Description of IEEE 802.11 MAC Protocol;337
1.15.4.2;12.4.2 NS2 Classes Mac and Mac802_11;338
1.15.4.3;12.4.3 Basic Functions of NS2 Classes Macand Mac802_11;340
1.15.4.4;12.4.4 Timer Concepts for Implementation of IEEE 802.11;342
1.15.4.5;12.4.5 Packet Reception Mechanism of IEEE 802.11;342
1.15.4.6;12.4.6 Implementation of Packet Retransmission in NS2;345
1.15.4.7;12.4.7 Implementation of Carrier-Sensing, Backoff, and NAV;348
1.15.4.7.1;12.4.7.1 Basic Carrier Sensing;348
1.15.4.7.2;12.4.7.2 Pausing and Resuming Backoff Timer;349
1.15.4.7.3;12.4.7.3 Network Allocation Vector;350
1.15.5;12.5 Physical Layer: Physical Network Interfaces and Channel;350
1.15.5.1;12.5.1 Physical Network Interface;350
1.15.5.2;12.5.2 Wireless Channels;352
1.15.5.3;12.5.3 Sender Operations at the Physical Layer;352
1.15.5.4;12.5.4 Receiver Operations at the Physical Layer;353
1.15.6;12.6 An Introduction to Node Mobility;356
1.15.6.1;12.6.1 Basic Mobility Configuration;356
1.15.6.2;12.6.2 General Operation Director ;357
1.15.6.3;12.6.3 Random Mobility;358
1.15.6.4;12.6.4 Mobility and Traffic Generators: Standalone Helper Utility;359
1.15.6.4.1;12.6.4.1 Mobility Generation Utility ``setdest';360
1.15.6.4.2;12.6.4.2 Traffic Generation Utility ``cbrgen.tcl';361
1.15.6.4.3;12.6.4.3 Working with Scenario Files;362
1.15.7;12.7 Chapter Summary;362
1.15.8;12.8 Exercises;363
1.16;Chapter13 Developing New Modules for NS2;364
1.16.1;13.1 Automatic Repeat reQuest;364
1.16.1.1;13.1.1 The Design;365
1.16.1.1.1;13.1.1.1 Architecture;365
1.16.1.1.2;13.1.1.2 Packet Forwarding Mechanism;366
1.16.1.1.3;13.1.1.3 Callback Mechanism;366
1.16.1.2;13.1.2 C++ Implementation;367
1.16.1.2.1;13.1.2.1 Class ARQTxs;368
1.16.1.2.2;13.1.2.2 Class ARQHandler;369
1.16.1.2.3;13.1.2.3 Classes ARQRx, ARQAcker, and ARQNacker;369
1.16.1.2.4;13.1.2.4 Callback Mechanism;369
1.16.1.2.5;13.1.2.5 Packet Forwarding Mechanism;371
1.16.1.2.6;13.1.2.6 Processing ACK and NACK Messages;371
1.16.1.2.7;13.1.2.7 Actions and Status of ARQ Transmitters;373
1.16.1.3;13.1.3 OTcl Implementation;373
1.16.1.3.1;13.1.3.1 Instproc SimpleLink::link-arq{limit};374
1.16.1.3.2;13.1.3.2 Instproc Simulator::link-arq{limit from to};374
1.16.1.4;13.1.4 ARQ Under a Delayed (Error-Free) Feedback Channel;376
1.16.1.4.1;13.1.4.1 Function recv(p,h) of ARQ Receivers;376
1.16.1.4.2;13.1.4.2 Binding Variable delay_;377
1.16.1.4.3;13.1.4.3 Configuration in the OTcl Domain;377
1.16.2;13.2 Packet Scheduling for Multi-Flow Data Transmission;378
1.16.2.1;13.2.1 The Design;378
1.16.2.1.1;13.2.1.1 Architecture of a SimpleLink with a Packet Scheduler;378
1.16.2.1.2;13.2.1.2 Packet Forwarding and Callback Mechanism;379
1.16.2.2;13.2.2 C++ Implementation;379
1.16.2.2.1;13.2.2.1 Class FlowClassifier;379
1.16.2.2.2;13.2.2.2 Class PktScheduler;380
1.16.2.2.3;13.2.2.3 Class RRScheduler;382
1.16.2.3;13.2.3 OTcl Implementation;382
1.16.2.3.1;13.2.3.1 Instproc insert-sched {num_queues} of class SimpleLink;383
1.16.2.3.2;13.2.3.2 Instproc insert-sched-to-SL{from to num_queues} of class Simulator;384
1.16.3;13.3 Chapter Summary;386
1.16.4;13.4 Exercises;387
1.17;Chapter14 Postsimulation Processing: Debugging, Tracing, and Result Compilation;388
1.17.1;14.1 Debugging: A Process to Remove Programming Errors;388
1.17.1.1;14.1.1 Types of Programming Errors;388
1.17.1.1.1;14.1.1.1 Compilation Errors (C++ Only);389
1.17.1.1.2;14.1.1.2 Runtime Errors;389
1.17.1.2;14.1.2 Debugging Guidelines;390
1.17.2;14.2 Variable Tracing;393
1.17.2.1;14.2.1 Activation Process for Variable Tracing;393
1.17.2.2;14.2.2 Traceable Variable;394
1.17.2.3;14.2.3 Components and Architecture for Variable Tracing;395
1.17.2.3.1;14.2.3.1 TclObjects;395
1.17.2.3.2;14.2.3.2 Traceable Variables: OTcl Linkage;396
1.17.2.3.3;14.2.3.3 Traceable Variables: Tracing Capability;397
1.17.2.3.4;14.2.3.4 Tracers;397
1.17.2.3.5;14.2.3.5 Trace Channels;400
1.17.2.3.6;14.2.3.6 Trace Files and Trace Format;400
1.17.2.4;14.2.4 Tracing in Action: An Example of Class TcpAgent;400
1.17.2.5;14.2.5 Setting Up Variable Tracing;400
1.17.2.5.1;14.2.5.1 Specifying Traceable Variables;401
1.17.2.5.2;14.2.5.2 Attaching a Trace File to a Tracer;402
1.17.3;14.3 Packet Tracing;403
1.17.3.1;14.3.1 OTcl Configuration Interfaces;404
1.17.3.2;14.3.2 C++ Main Packet Tracing Class Trace;408
1.17.3.2.1;14.3.2.1 Main C++ Variable of Class Trace;408
1.17.3.2.2;14.3.2.2 Main C++ Functions of Class Trace;408
1.17.3.2.3;14.3.2.3 Main OTcl Commands of a Packet Tracing Object;410
1.17.3.3;14.3.3 C++ Helper Class BaseTrace;411
1.17.3.4;14.3.4 Various Types of Packet Tracing Objects;413
1.17.3.5;14.3.5 Format of Trace Strings for Packet Tracing;416
1.17.3.5.1;14.3.5.1 Normal Packet Trace Format;416
1.17.3.5.2;14.3.5.2 Wireless Packet Trace Format;418
1.17.3.5.3;14.3.5.3 New Wireless Trace Format;419
1.17.4;14.4 Compilation of Simulation Results;421
1.17.5;14.5 Chapter Summary;425
1.17.6;14.6 Exercises;426
1.18;Chapter15 Related Helper Classes;428
1.18.1;15.1 Timers;428
1.18.1.1;15.1.1 Implementation Concept of Timer in NS2;428
1.18.1.2;15.1.2 OTcl Implementation;430
1.18.1.3;15.1.3 C++ Class Implementation;432
1.18.1.3.1;15.1.3.1 Timer Life Cycle;432
1.18.1.3.2;15.1.3.2 Brief Overview of Class TimerHandler;433
1.18.1.3.3;15.1.3.3 Internal Waiting Mechanism;435
1.18.1.3.4;15.1.3.4 Expiration Actions;436
1.18.1.3.5;15.1.3.5 Interface Functions to Start, Restart, and Cancel a Timer;436
1.18.1.3.6;15.1.3.6 Cross-Referencing a Timer with Another Object;438
1.18.1.4;15.1.4 Guidelines for Implementing Timers in NS2;442
1.18.2;15.2 Implementation of Random Numbers in NS2;443
1.18.2.1;15.2.1 Random Number Generation;443
1.18.2.2;15.2.2 Seeding a Random Number Generator;444
1.18.2.3;15.2.3 OTcl and C++ Implementation;446
1.18.2.3.1;15.2.3.1 OTcl Commands and Instprocs;446
1.18.2.3.2;15.2.3.2 C++ Functions;447
1.18.2.4;15.2.4 Randomness in Simulation Scenarios;448
1.18.2.4.1;15.2.4.1 Deterministic Setting;448
1.18.2.4.2;15.2.4.2 Single-Stream Random Setting;448
1.18.2.4.3;15.2.4.3 Multiple-Stream Random Setting;448
1.18.2.5;15.2.5 Random Variables;450
1.18.2.5.1;15.2.5.1 Random Number Generator;451
1.18.2.5.2;15.2.5.2 OTcl Commands;451
1.18.2.5.3;15.2.5.3 Exponential Random Variable;452
1.18.2.6;15.2.6 Guidelines for Random Number Generation in NS2;453
1.18.3;15.3 Built-in Error Models;454
1.18.3.1;15.3.1 OTcl Implementation: Error Model Configuration;455
1.18.3.1.1;15.3.1.1 Parameter Configuration;456
1.18.3.1.2;15.3.1.2 Network Configuration;456
1.18.3.2;15.3.2 C++ Implementation: Error Model Simulation;459
1.18.3.2.1;15.3.2.1 Variables;459
1.18.3.2.2;15.3.2.2 Functions;461
1.18.3.2.3;15.3.2.3 Main Mechanism;462
1.18.3.2.4;15.3.2.4 Simulating Transmission Errors;463
1.18.3.3;15.3.3 Guidelines for Implementing a New Error Model in NS2;467
1.18.4;15.4 Bit Operations in NS2;468
1.18.4.1;15.4.1 Bit Masking;468
1.18.4.1.1;15.4.1.1 Subnet Masking;468
1.18.4.1.2;15.4.1.2 Modulo Masking;469
1.18.4.2;15.4.2 Bit Shifting and Decimal Multiplication;470
1.18.5;15.5 Chapter Summary;471
1.18.6;15.6 Exercises;471
1.19;A Programming Essentials;473
1.19.1;A.1 Tcl Programming;473
1.19.1.1;A.1.1 Program Invocation;473
1.19.1.2;A.1.2 Syntax;474
1.19.1.3;A.1.3 Variables and Basic Operations;475
1.19.1.4;A.1.4 Logical and Mathematical Operations;478
1.19.1.5;A.1.5 Control Structure;479
1.19.1.5.1;A.1.5.1 Repetition Structure;480
1.19.1.5.2;A.1.5.2 Jumping Structure;480
1.19.1.6;A.1.6 Modularization;481
1.19.1.6.1;A.1.6.1 Storing a Program Portion into a File and File Sourcing;481
1.19.1.6.2;A.1.6.2 Storing a Program Portion into a Procedure;481
1.19.1.6.3;A.1.6.3 Global and Local Variables;483
1.19.1.7;A.1.7 Advanced Input/Output: Files and Channels;483
1.19.1.7.1;A.1.7.1 Tcl Channels;484
1.19.1.8;A.1.8 Data Types;485
1.19.1.8.1;A.1.8.1 String;485
1.19.1.8.2;A.1.8.2 List;486
1.19.1.8.3;A.1.8.3 Associative Array;486
1.19.2;A.2 Objected-Oriented Tcl Programming;487
1.19.2.1;A.2.1 OTcl Language Structure;488
1.19.2.2;A.2.2 Classes and Inheritance;488
1.19.2.3;A.2.3 Objects and Object Construction Process;489
1.19.2.3.1;A.2.3.1 Object Construction Methods;489
1.19.2.3.2;A.2.3.2 Object Construction Process;489
1.19.2.4;A.2.4 Member Variables and Functions;490
1.19.2.4.1;A.2.4.1 Instance Variables;490
1.19.2.4.2;A.2.4.2 Instance Procedures;491
1.19.2.4.3;A.2.4.3 Non-Inheritable Members;492
1.19.2.5;A.2.5 A List of Useful Instance Procedures;492
1.19.3;A.3 AWK Programming;494
1.19.3.1;A.3.1 Program Invocation;495
1.19.3.2;A.3.2 An AWK Script;496
1.19.3.3;A.3.3 AWK Programming Structure;496
1.19.3.4;A.3.4 Pattern Matching;497
1.19.3.5;A.3.5 Basic Actions;497
1.19.3.5.1;A.3.5.1 Arithmetic Operation;498
1.19.3.5.2;A.3.5.2 Variables;498
1.19.3.5.3;A.3.5.3 Outputs;498
1.19.3.6;A.3.6 Redirection and Output to Files;499
1.19.3.7;A.3.7 Control Structure;500
1.19.4;A.4 Exercises;500
1.20;B A Review of the Polymorphism Concept in OOP;502
1.20.1;B.1 Fundamentals of Polymorphism;502
1.20.2;B.2 Type Casting and Function Ambiguity;505
1.20.3;B.3 Virtual Functions;506
1.20.4;B.4 Abstract Classes and Pure Virtual Functions;507
1.20.5;B.5 Class Composition: An Application of Type Casting Polymorphism;508
1.20.6;B.6 Programming Polymorphism with No Type Casting:An Example;509
1.20.7;B.7 A Scalability Problem Caused by Non-Type Casting Polymorphism;510
1.20.8;B.8 The Class Composition Programming Concept;511
1.21;C BSD Link List and Bit Level Functions;515
1.21.1;C.1 BSD Link List;515
1.21.2;C.2 Bit Level Functions;515
1.22;References;517
1.23;General Index;519
1.24;Code Index;523




