QualNet Tutorial

Download Report

Transcript QualNet Tutorial

QualNet Tutorial
Yi Zheng
Contents
1
Introduction
2
Using QualNet
3
4
2
Writing protocols in QualNet
Example
QualNet
Part I
Introduction
3
Introduction
What’s QualNet?
 Commercial derivative of GlomoSim
 Rapid prototyping of protocols
 Comparative performance evaluation of alternative
protocols at each layer
 Built-in measurements on each layer
 Modular, layered stack design
 Standard API for composition of protocols across
different layers
 Scalability via support for parallel execution
 GUI Tools for system/protocol modeling
4
Introduction
Installation
 Make a local copy of QualNet in your home directory
• % mkdir ~/qualnet
• % cp –r /cs/local/packages/qualnet/4.0 ~/qualnet
 Set environment variables in ~/.cshrc
• setenv QUALNET_HOME ~/qualnet/4.0
• setenv PATH ${PATH} :${QUALNET_HOME}/bin
 Test installation
• % cd ~/qualnet/4.0/bin
• % qualnet default.config
5
Introduction
Directory Structure













6
addons
bin
data
documentation
gui
include
interfaces
kernel
lib
libraries
license_dir
main
scenarios
Components developed as custom add-on modules
Executable and other runtime files
Data files for the Wireless Model Library
User’s Guide, Release Notes, etc.
Graphical components
QualNet kernel header files
Code to interface QualNet with third party tools
QualNet kernel objects used in the build process
Third party libraries used in the build process
Source code for models in QualNet model libraries
License files required for the build process
Kernel source files and Makefiles
Sample scenarios
Introduction
Simulation experiment life cycle
 Startup
• Read configuration files
• Initialize wireless environment
• Create/initialize nodes
 Execution
• Execute events
 Shutdown
• Finalize nodes
• Produce statistics files
7
QualNet
Part II
Using QualNet
8
Configuration File (1)
Configuration files
 Plain-text explanation for configuration file
• $QUALNET_HOME/scenarios/default/default.config
 Global Parameters
•
•
•
•
Experiment name
Simulation time
Coordinate system and terrain
Random seed
 Topology and subnets
 Layer/Protocol related parameters
9
Configuration File (2)
 EXPERIMENT-NAME default
 Name of experiment. Results are written to default.stat.
 SIMULATION-TIME
 SEED 1
15M
 Value used to seed the random number generator.
 COORDINATE-SYSTEM CARTESIAN
 TERRAIN-DIMENSIONS (1500, 1500)
 Cartesian xy terrain dimensions in meters
 SUBNET N16-1.0 { 1 thru 30 }
 30 nodes whose IP addresses range from 0.0.1.1 to 0.0.1.30
 Format: N<# host bits>-<address with front end 0’s omitted>
 N16-1.0 allows hosts with IP address numbered from 0.0.1.1 through
0.0.1.65534, it is equivalent to N16-0.0.1.0
10
Configuration File (3)
 NODE-PLACEMENT
GRID
UNIFORM/GRID/RANDOM/FILE
RANDOM
UNIFORM
 MULTICASTGROUPFILE ./default.member
 multicast membership file
 See $QUALNET_HOME/scenarios/default/default.member for more details.
 APPCONFIGFILE ./default.app
 Specifies a file with a list of apps/traffic generators to run
 CBR <src> <dest> <items to send> <size> <interval> <start time> <end time>
 See $QUALNET_HOME/scenarios/default/default.app for more details.
11
Configuration File (4)
 ROUTING-PROTOCOL
AODV
 Unicast routing protocol
 MULTICAST-PROTOCOL
 Multicast routing protocol
 Layer Statistics









12
APPLICATION-STATISTICS (YES|NO)
TCP-STATISTICS (YES|NO)
UDP-STATISTICS (YES|NO)
ROUTING-STATISTICS (YES|NO)
NETWORK-LAYER-STATISTICS (YES|NO)
QUEUE-STATISTICS (YES|NO)
MAC-LAYER-STATISTICS (YES|NO)
PHY-LAYER-STATISTICS (YES|NO)
MOBILITY-STATISTICS (YES|NO)
SPTM
Using QualNet
 Step 1: Prepare config files for your protocol
 Step 2: Run QualNet on the config files
 Step 3: Examine the output statistics file
Use script language (perl/awk) to
process it.
 Step 4: Use plotting tools (gnuplot) to
create graphs from above results.
13
Using QualNet
 Find fast computers in our department
 Checkout /proc/cpuinfo, /proc/meminfo, etc.
 Use “top” to check no other people is using that computer
 Some new(fast) computers








14
cse2017-pc01 ~ cse2017-pc12: E8400 3G 6M cache
cse2027-pc01 ~ cse2027-pc08: E8400
cse2023-pc01 ~ cse2023-pc08: E8400
jun01 ~ jun24: E6750 2.66G 4M cache
navy
Don’t run QualNet on Indigo/Red
Only one process in one computer.
Our QualNet license only supports 30 processes simultaneously.
Using QualNet
 Use the powerful tool: screen
 a terminal multiplexer that allows a user to access multiple
separate terminal sessions inside a single terminal window.
 allows the user to start applications from one computer, and then
reconnect from a different computer and continue using the
same application without having to restart it.
15
Tip
More Information
 Read manuals in $QUALNET_HOME/documents
 Read source codes
 Visit community forums
• http://www.scalable-networks.com/support/forums
16
QualNet
Part III
Writing protocols in QualNet
17
Writing Protocols
Message
 A message is a unit defining an interaction between
protocols and between nodes.
 Two types of messages
• Packets used for communication between nodes
• Timers allow protocols to schedule events in a future
time
18
Writing Protocols
 MESSAGE_Alloc()
 Allocate a message and provide it with standard event, layer,
protocol info
 MESSAGE_PacketAlloc()
 Allocate space for the packet within the message
 MESSAGE_InfoAlloc()
 Allocate additional user-specified space for optional information
about the event (info field)
 MESSAGE_Send()
 Send the message as an event to the specified layer
 MESSAGE_Free()
 Free the message, once it has reached its final destination
19
Writing Protocols
 Implement five main functions in routing protocol
 Initialization function
•
•
•
•
•
Create an instance of the protocol
Read configuration parameters
Initialize the state variables
register the router function
Schedule a timer event
 Packet/Event handling function
• Modify state variables
• Generate/forward packets
• Process packet/event based on packet/event type
 Router function
• Determine the next hop and outgoing interface for the packet
 Finalization function
• Print statistics
20
Writing Protocols
 Example : Simplified routing information
protocol (SRIP)
 Table-driven, distance vector protocol
 Periodic route update
 Will be Explained in Part IV
21
Writing Protocols
Add your routing protocol to QualNet
 Let QualNet know it is a network layer protocol
• Modify $QUALNET_HOME/include/network.h
–
–
–
–
–
–
–
–
–
–
–
–
–
–
22
typedef enum
{
NETWORK_PROTOCOL_IP = 0,
NETWORK_PROTOCOL_MOBILE_IP,
:
:
ROUTING_PROTOCOL_IGRP,
ROUTING_PROTOCOL_SRIP,
//InsertPatch ROUTING_PROTOCOL_TYPE
:
ROUTING_PROTOCOL_ALL,
ROUTING_PROTOCOL_NONE
}
NetworkRoutingProtocolType;
Writing Protocols
Add your routing protocol to QualNet
 Let IP module know it is an IP protocol
• Modify libraries/developer/src/network_ip.h
–
–
–
–
–
–
–
–
–
23
//
// IP protocol numbers for network- and transport-layer protocols.
//
#define IPPROTO_ICMP 1
#define IPPROTO_IGMP 2
:
#define IPPROTO_DVMRP 200
#define IPPROTO_SRIP 234
//InsertPatch ROUTING_IPPROTO
Writing Protocols
Add your routing protocol to QualNet
 Let IP module recognize the five entry functions
• Modify libraries/developer/src/network_ip.cpp
• Include routing_srip.h
–
–
–
–
–
–
–
–
24
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
:
:
#include “routing_srip.h"
//InsertPatch HEADER_FILES
Writing Protocols
Add your routing protocol to QualNet
 Have IP initialize SRIP if specified in the configuration
file
• Modify libraries/developer/src/network_ip.cpp, function
NetworkIpInit()
– else if (strcmp(protocolString, "SRIP") == 0) {
NetworkIpAddUnicastRoutingProtocolType(node,
ROUTING_PROTOCOL_SRIP, i);
if (!NetworkIpGetRoutingProtocol(node, ROUTING_PROTOCOL_SRIP)) {
SripInit(node,(SripData **) &ip->interfaceInfo[i]->routingProtocol,nodeInput,
i);
}
else {
NetworkIpUpdateUnicastRoutingProtocolAndRouterFunction(node,
ROUTING_PROTOCOL_SRIP, i);
}
– }
25
Writing Protocols
Add your routing protocol to QualNet
 When the network layer receives an event for SRIP,
dispatch it to SRIP's event handling function
• Modify libraries/developer/src/network_ip.cpp, function
NetworkIpLayer()
–
–
–
–
–
–
–
–
–
26
switch (msg->protocolType)
{
:
case ROUTING_PROTOCOL_SRIP:
{
SripHandleProtocolEvent(node, msg);
break;
}
//InsertPatch NETWORK_IP_LAYER
:
}
Writing Protocols
Add your routing protocol to QualNet
 When IP receives an SRIP route advertisement
packet, dispatch it to SRIP's packet handling function
• Modify libraries/developer/src/network_ip.cpp, function
DeliverPacket()
–
–
–
–
–
–
–
–
–
27
switch (ipProtocolNumber)
{
:
case IPPROTO_SRIP:
{
SripHandleProtocolPacket(node,msg, sourceAddress);
break;
}
//InsertPatch NETWORK_HANDLE_PACKET
:
}
Writing Protocols
Add your routing protocol to QualNet
 Call SRIP's finalizing function when IP is terminating
• Modify libraries/developer/src/network_ip.cpp, function
NetworkIpFinalize()
–
–
–
–
–
–
–
–
–
28
switch (NetworkIpGetUnicastRoutingProtocolType(node, i))
{
:
case ROUTING_PROTOCOL_SRIP:
{
SripFinalize(node);
break;
}
//InsertPatch FINALIZE_FUNCTION
:
}
Writing Protocols
Compile QualNet with the new code
 Modify libraries/developer/src/Makefile-common
–
–
–
–
DEVELOPER_SRCS = \
:
$(DEVELOPER_SRCDIR)/routing_srip.cpp \
:
 Rebuild QualNet
• cd $QUALNET_HOME/main
• make
29
QualNet
Part IV
Example: SRIP
30