Adding new routing protocols
    in GloMoSim - 2.03




          A.Kathirvel, AP/CSE
B. S. Abdur Rahman University, Chenn...
Outline

    Introduction

    Compile simple c program using parsec

    Steps to adding new protocols

    Understan...
Introduction

    Each node in GloMoSim runs a protocol stack.

    Each layer provides a service to the layer above it,...
Introduction

    At the heart of a protocol model is an Event Dispatcher,
    which consists of a Wait For Event state a...
Introduction
Introduction

    Besides the Event Dispatcher, the protocol finite state
    machine has two other states: the Initializ...
Simple program in glomosim
/g lomosim-2.03/glomosim/main
Filename : hello.pc
#include <stdio.h>
int main(int argc, char **...
To Compile the program
[root@localhost main]# vi hello.pc

[root@localhost main]# pcc -clock longlong -lm -c
  hello.pc

[...
Output
[root@localhost main]# ./hello
Hello World


Execution time : 0.0002 sec
Number of events (including timeouts) proc...
Pre-Requisition

    Modify and store the protocol

    −   Myprotocol.pc
    −   Myprotocol.h


    In *.pc and *.h the...
Steps to Add a New Routing Protocol

    The files that are to be modified are


    Makent.bat

    Application.pc

 ...
Make file

    Makent.bat (windows)

    Makefile (Linux)


  Network Layer add the line
Makent.bat

  call pcc %parse...
Application.pc file

    The initialisation function of application layer
    should include the code
void
GLOMO_AppInit(...
Nwcommon.h file

    A protocol number is assigned to MYPROTOCOL by
    adding a #define statement to nwcommon.h.

    T...
Network.h file

   MYPROTOCOL should be included in the enumerated
   type NetworkRoutingProtcolType defined in network.h...
Nwip.pc file

    Include Myprotocol.h as a header file and then
    add the code to the initialize function

    The fo...
Nwip.pc file

    void NetworkIpInit(GlomoNode* node, const
    GlomoNodeInput* nodeInput)
{
...............
else if (str...
Nwip.pc file
void NetworkIpFinalize(GlomoNode *node)
{
  GlomoNetworkIp* ipLayer = (GlomoNetworkIp*)node-
  >networkData.n...
Nwip.pc file
void NetworkIpLayer(GlomoNode *node, Message *msg)
   {
   switch (msg->protocolType) {
............
   case ...
Nwip.pc file
static
void ProcessPacketForMeFromMac(GlomoNode *node,
   Message *msg)
{
   GlomoNetworkIp* ipLayer = (Glomo...
Nwip.pc file
case IPPROTO_MYPROTOCOL: {
      RoutingMyprotocolHandleProtocolPacket(node, msg,
   sourceAddress,
         ...
compile

 Windows
Makent clean
Makent


    Linux

# make clean
# make
Questions
   ?
Upcoming SlideShare
Loading in...5
×

Glomosim adding routing protocol

7,355

Published on

Published in: Education
7 Comments
2 Likes
Statistics
Notes
  • @ramanji-1982 The method shown in the slides is working for you? because i am getting so much errors. and one weird thing is author isnt telling about to edit user_nwip.pc which should be modified to add a new protocol as far as i knw.Please reply
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • hi sir i will install glomosim successfully and i will run the aodv ,dsr, bellmonford potocol but odmrp protocol did not run please help me sir
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • plz help me how to run the progams in glomosim
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • after all this.. i did ./glomosim config.in
    but it is giving that ../transport/transport.pc has RETVAL==TRUE failed, ABORTED.
    I HAVE TO ADD ARAN PROTOCOL IN NETWORK.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • I want to implement an energy aware AODV by adding a field BL on RREQ.When a node before broadcasting it compares its current energy (BL) & the minEnergy on the RREQ packets and reassign the minimum of them on minEnergy of RREQ packet.Then rebroadcast it. My question is how can I obtain current energy of each node? I tried to obtain using this: currEnergy = iNode->energy_model()->energy(); But It does not work. and how I can obtain that the destination wait for a time to choose the RREQ with the greatest BL
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total Views
7,355
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
7
Likes
2
Embeds 0
No embeds

No notes for slide

Glomosim adding routing protocol

  1. 1. Adding new routing protocols in GloMoSim - 2.03 A.Kathirvel, AP/CSE B. S. Abdur Rahman University, Chennai
  2. 2. Outline  Introduction  Compile simple c program using parsec  Steps to adding new protocols  Understanding the coding  Discussion
  3. 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. 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
  5. 5. Introduction
  6. 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. 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. 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. 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. 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. 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
  12. 12. Make file  Makent.bat (windows)  Makefile (Linux)  Network Layer add the line Makent.bat  call pcc %parsecflags% -I..include -I..network -clock longlong -c ..networkmyprotocol.pc Makefile  SIM_HDRS = ../network/aodv.h  PAR_FILES = ../network/myprotocol.pc
  13. 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. 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. 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. 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( )
  17. 17. Nwip.pc file  void NetworkIpInit(GlomoNode* node, const GlomoNodeInput* nodeInput) { ............... else if (strcmp(protocolString, "MYPROTOCOL") == 0) { ipLayer->routingProtocolChoice = ROUTING_PROTOCOL_MYPROTOCOL; RoutingMyprocotolInit( node, (GlomoRoutingMyprotocol**)&ipLayer- >routingProtocol, nodeInput); ..... }
  18. 18. Nwip.pc file void NetworkIpFinalize(GlomoNode *node) { GlomoNetworkIp* ipLayer = (GlomoNetworkIp*)node- >networkData.networkVar; switch (ipLayer->routingProtocolChoice) { case ROUTING_PROTOCOL_MYPROTOCOL: RoutingMyprotocolFinalize(node); break; ..... }
  19. 19. Nwip.pc file void NetworkIpLayer(GlomoNode *node, Message *msg) { switch (msg->protocolType) { ............ case ROUTING_PROTOCOL_MYPROTOCOL: { RoutingMyprotocolHandleProtocolEvent(node, msg); break; ......... }
  20. 20. Nwip.pc file static void ProcessPacketForMeFromMac(GlomoNode *node, Message *msg) { GlomoNetworkIp* ipLayer = (GlomoNetworkIp *)node- >networkData.networkVar; NODE_ADDR sourceAddress; NODE_ADDR destinationAddress; ..............
  21. 21. Nwip.pc file case IPPROTO_MYPROTOCOL: { RoutingMyprotocolHandleProtocolPacket(node, msg, sourceAddress, destinationAddress, ttl); break; } ........... }
  22. 22. compile  Windows Makent clean Makent  Linux # make clean # make
  23. 23. Questions ?

×