1. Adding new routing protocols
in GloMoSim - 2.03
A.Kathirvel, AP/CSE
B. S. Abdur Rahman University, Chennai
2. Outline
Introduction
Compile simple c program using parsec
Steps to adding new protocols
Understanding the coding
Discussion
3. Introduction
Each node in GloMoSim runs a protocol stack.
Each layer provides a service to the layer above it, by
using the services of the layers below it.
Protocols in GloMoSim essentially operate as a finite
state machine. The occurrence of an event
corresponds to a transition in the finite state machine.
The interface between the layers is also event based.
Each protocol can either create events that make it
change its own state (or perform some event
handling), or create events that are processed by
another protocol.
To pass data to, or request a service from, an adjacent
layer, a protocol creates an event for that layer.
4. Introduction
At the heart of a protocol model is an Event Dispatcher,
which consists of a Wait For Event state and one or more
Event Handler states.
In the Wait For Event state, the protocol waits for an
event to occur.
When an event for the protocol occurs, the protocol
transitions to the Event Handler state corresponding to
that event (e.g., when Event 1 occurs, the protocol
transitions to the Event 1 Handler state).
In this Event Handler state, the protocol performs the
actions corresponding to the event, and then returns to
the Wait For Event state.
Actions performed in the Event Handler state may include
updating the protocol state, or scheduling other events, or
both
6. Introduction
Besides the Event Dispatcher, the protocol finite state
machine has two other states: the Initialization state
and the Finalization state.
In the Initialization state, the protocol reads external
input to configure its initial state. The protocol then
transitions to the Wait For Event state.
The transition to the Finalization state occurs
automatically at the end of simulation. In the
Finalization state, protocol statistics collected during
the simulation are printed.
7. Simple program in glomosim
/g lomosim-2.03/glomosim/main
Filename : hello.pc
#include <stdio.h>
int main(int argc, char **argv){
parsec_main(argc,argv);
printf("Simulation Endednn");
}
entity driver(int argc, char **argv){
int i;
printf("Hello World nn");
}
8. To Compile the program
[root@localhost main]# vi hello.pc
[root@localhost main]# pcc -clock longlong -lm -c
hello.pc
[root@localhost main]# pcc -clock longlong
-user_main hello.o -lm -o hello
9. Output
[root@localhost main]# ./hello
Hello World
Execution time : 0.0002 sec
Number of events (including timeouts) processed : 0
Number of messages processed : 0
Number of context switches occurred : 6
Number of Local NULL messages sent : 0
Number of Remote NULL messages sent : 0
Total Number of NULL messages sent : 0
Simulation Ended
10. Pre-Requisition
Modify and store the protocol
− Myprotocol.pc
− Myprotocol.h
In *.pc and *.h the following routines are very important
− void RoutingMyprotocolInit( )
− void RoutingMyprotocolFinalize( )
11. Steps to Add a New Routing Protocol
The files that are to be modified are
Makent.bat
Application.pc
Nwcommon.h
Network.h
Nwip.pc
13. Application.pc file
The initialisation function of application layer
should include the code
void
GLOMO_AppInit(GlomoNode *node, const
GlomoNodeInput *nodeInput)
{
...........
else if (strcmp(buf, "MYPROTOCOL") == 0) {
..........
}
14. Nwcommon.h file
A protocol number is assigned to MYPROTOCOL by
adding a #define statement to nwcommon.h.
The protocol number is unique to each protocol
#define IPPROTO_MYPROTOCOL 501
15. Network.h file
MYPROTOCOL should be included in the enumerated
type NetworkRoutingProtcolType defined in network.h
typedef enum {
......
ROUTING_PROTOCOL_AODV,
ROUTING_PROTOCOL_DSR,
ROUTING_PROTOCOL_LAR1,
ROUTING_PROTOCOL_MYPROTOCOL
.........
} NetworkRoutingProtocolType;
16. Nwip.pc file
Include Myprotocol.h as a header file and then
add the code to the initialize function
The following 5 changes to be made in the file
− #include "myprotocol.h"
− Void NetworkIpInitialize( )
− Void NetworkIpFinalize( )
− Void NetworkIpLayer( )
− Static void ProcessPacketForMeFromMac( )