1.1k likes | 1.39k Views
QualNet Programmer’s Guide. UbiLab 2012. Index. Directory Structure QualNet Basic Message & Event QualNet simulation architecture Protocol Model Programming Application Layer Transport Layer Network Layer Queue & Scheduler.
E N D
QualNetProgrammer’s Guide UbiLab 2012
Index • Directory Structure • QualNet Basic • Message & Event • QualNet simulation architecture • Protocol Model Programming • Application Layer • Transport Layer • Network Layer • Queue & Scheduler ※ Detailed information are referred to QualNet Programmer’s Guide document.
Directory Structure global headers model sources & headers Qualnet kernel binaries & libraries
Discrete Event Simulation Event Queue event1 • Event • arrival of packet • periodic alarm • Action • sending packet • updating system state • starting/restarting timer event2 … eventN register event event
QualNet Protocol Stack • Layer Based Architecture & Organization • Events & Messages • Events: Essential Concepts • Lifecycle • Event Handling • Packets • Timers • API: Raw Message API and Layer Specific
Protocol Stack • Layered architecture • Data moves from layer to layer • APIs were used • can skip layer whendata is transmitted
How to send packet Node 1 needs to send a packet to Node 2 message Node 1 Node 2 Event: Packet Received Packet Sent
Message • Events are implemented using Message • HOME/include/message.h • HOME/include/main.h affect transmission time not affect transmission time
Message APIs • HOME/include/message.h • HOME/main/message.cpp • MESSAGE_Alloc • MESSAGE_Free • MESSAGE_PacketAlloc • MESSAGE_AddInfo • MESSAGE_AddHeader • MESSAGE_RemoveHeader • MESSAGE_GetLayer • MESSAGE_GetProtocol • MESSAGE_GetEvent • MESSAGE_Send
Event Type • Packet • exchange of data packet between layers or nodes • communication between entities at the same layer • Timer • act as a trigger • An event is identified by the following: • Node • Layer • Protocol • Event ID
Packet Event • to simulate transmission of packets across the network • using packet field of Message structure • at each layer, packet header is attached/removed • to send packet to another layer, MESSAGE_Send()
Timer Event • periodic alarms for event scheduling • trigger • the event types are defined in • HOME/include/api.h ★ The delay time 0 means “immediate event”.
A node with • CBR application • AODV routing • 802.11 wireless HOME/main/node.cpp /partition.cpp Node HOME/libraries/developer/src/ application.cpp app_cbr.cpp transport.cpp transport_udp.cpp Protocols Layers network.cpp network_ip.cpp routing_aodv.cpp mac.cpp mac_dot11.cpp phy.cpp phy_802_11.cpp phy_connectivity.cpp HOME/libraries/wireless/src/
QualNetEventQueue QualNet Kernel Which Node’s Event? MESSAGE Node / Layer / Protocol / Event node = 4 Node Which Layer’s Event? layerType = Transport 3 Application 1 Transport Which Protocol? 4 2 UDP Which Event? protocolType = UDP call event handler function Network LINK/MAC Physical
QualNet Simulator Architecture • Initialization • Event Handling • Finalization ★ Each of these functions is performed hierarchically. Node Layer Protocol
Protocol Life Cycle Three main functions that are called by Simulator: • Initialization • Called at Time 0 • Initialization of variables • Event Processing • Called as needed • Creation • Scheduling • Handling • Finalization • Called at end of simulation • Printing Statistics
Protocol Life Cycle QualNet Event Handling: Packets, timers etc Initialization Function Message (Packet or Timer) Processing Function • Modify State Variables • Increment Local Statistics • Generate / Forward Packets QualNet FinalizationFunction
Initialization • node creation & initialization • initialization of each layer, protocol • HOME/main/partition.cpp • /application.cpp • /mac.cpp • /network.cpp • /node.cpp • /transport.cpp
Event Handling • call a dispatcher function of appropriate node, layer, protocol when a event occurs • handle & scheduling event, change system states
Finalization • call finalization function for each protocol running at that layer • print the statistics to output • free all instances and terminate simulation
CBR Example - Initialization init App Layer routing protocol init App Layer traffic generating protocol
Application Layer • Traffic-generating Protocols • Routing Protocols
Application Layer Data Structure(1) • HOME/include/application.h • AppType • lists of all Application Layer protocols
Application Layer Data Structure(2) • AppInfo • contains information about an instance of an application • application state & statistics
Application Layer Data Structure(3) • AppData • main data structure used by the Application Layer • contain AppInfo & AppType information
Application Layer Data Structure(4) • AppTimer • Application Layer timer
Application Layer APIs • Application to Transport (app_util.h / app_util.cpp) • Transport to Application (api.h)
Adding an App-Protocol application.h app_myApp.h enum { myApp, } AppType; myApp_data_structure { } include application.cpp app_myApp.cpp myApp_Init() { register NewApp; init Timer; } myApp_ProcessEvent() { case myAppEvent1: case myAppEvent2: } myApp_Finalize() APP_InitializeApplications() { myApp_Init(); } APP_ProcessEvent() { myApp_ProcessEvent(); } APP_Finalize() { myApp_Finalize(); } register Application Layer Protocol Name register Event Handler api.h enum { myAppEvent1, myAppEvent2, } register Event Types
Transport Layer • TCP • guaranteed delivery • congestion control • UDP • connectionless • RSVP-TE • control protocol at Transport Layer • QoS
Transport Layer Data Structure • HOME/include/transport.h • Transport Layer protocol type definition • Transport Data structure
APIs Application Layer HOME/main/app_util.cpp HOME/include/api.h Transport Layer HOME/libraries/developer/src/network_ip.cpp HOME/libraries/developer/src/network_ip.h Network Layer
Adding an Trans-Protocol(2) register protocol data transport.h trans_myProtocol.h myProtocol_data_structure { } PARTITION_Initialize() include transport.cpp trans_myProtocol.cpp myProtocol_Init() { register NewApp; init Timer; } myProtocol_ProcessEvent() { case myProtocolEvent1: case myProtocolEvent2: } myProtocol_Finalize() TRANSPORT_Initialize() { myProtocol_Init(); } TRANSPORT_ProcessEvent() { myProtocol_ProcessEvent(); } TRANSPORT_Finalize() { myProtocol_Finalize(); } register Transport Layer Protocol Name register Event Handler api.h enum { myProtocolEvent1, myProtocolEvent2, } register Event Types
Network Layer • Routing • determining the next hop & outgoing interface for a packet • Traffic Control • congestion & transmission rate control • Addressing • identifying nodes in network • Internetworking • interconnecting heterogeneous networks