701 likes | 731 Vues
Learn about the directory structure, basic concepts, message handling, protocol stack, and event processing in QualNet 2011. Explore how to design a layered architecture, send packets across nodes, and handle events efficiently. Understand the initialization, event handling, and finalization processes in protocol modeling and simulation. Discover the roles of network layers, unicast routing protocols, and event dispatchers in QualNet simulation design.
E N D
QualNet 2014/05/13 602430017 尉遲仲涵
Outline • Directory Structure • QualNet Basic • Message & Event • QualNet simulation architecture • Protocol Model Programming • Application Layer • Transport Layer • Network Layer • Queue & Scheduler
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/
QualNet EventQueue 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
2011.05.16. Adding a Network Layer Unicast Routing Protocol
Register Protocol Name • HONE/include/network.h
Register Protocol Administrative Distance value • HOME/include/network.h
Defining Data Structure for Protocol • In user’s Protocol.h • Protocol parameters • Protocol state • Statistics variables • Routing table AODV data structure in routing_aodv.h
IP callback functions • Network Layer routing protocol interacts with IP to route packets and to handle protocol events. • Routing protocol registers the functions with IP as part of initialization. • Home/libraries/developer/src/network_ip.cpp
APIs for MAC Layer Communication • APIs to communicate with MAC Layer for Network Layer Routing Protocols to handle an event (transmitting packets to a node’s peers using MAC Layer services)
Registering Protocol Event Type • All event types must be registered in • HOME/include/api.h
Modifying IP Function • NetworkRoutingGetAdminDistance() • definition of the priority of routing protocol • HOME/libraries/developer/src/network_ip.cpp
Processing Routing Packets • Define IP Protocol Number for user’s protocol • HOME/libraries/developer/src/network_ip.h
DeliverPacket() • IP Protocol Number from IP header based switching • checking packet’s • routing protocol type • interface • call routing protocol’s packet handler function
2011.05.23. Queuing Protocols
Data Structures • HOME/include/if_queue.h • QueueOperation • lists of the different types of dequeue operations
PacketArrayEntry • an entry in the array of stored messages
Queue • the base class that is used to derive specific queue classes • queue variables • interface functions for queue operations • refer to Programmer’s Guide 4.4.7.1(p.207)Figure 4-99, Figure 4-100, Figure 4-101
Interface Functions • HOME/libraries/developers/src/if_queue.cpp
QUEUE_Setup() create & initialize an object of • the base Queue class • a class derived from the base Queue class • HOME/include/if_queue.h /libraries/developers/src/if_queue.cpp