Skip to main content

Posts

Showing posts from August, 2018

How to add a Protocol in ns2 - NS2 Tutorial #13

How to add a new protocol in ns2 I am going to use the version ns-2.35 protoname was one of the best unicast routing protocol for ns2. Agent/SIMP Protoname -> Simp PROTONAME -> SIMP protoname -> simp you can download the  source code from https://www.nsnam.com There are totally 5 files in the source code protoname.cc converted to simp.cc  protoname.h -> simp.h  protoname_pkt.h -> simp_pkt.h  protoname_rtable.cc -> simp_rtable.cc  protoname_rtable.h -> simp_rtable.h New Protocol Implementation In this new protocol,  we have to 1. Add the source code (the 5 files given above) 2. existing code modification (within ns2) 3. Make an entry in the Makefile.in 4. Recompile ns2 5. Test the protocol using a TCL file. Addition of source code is done. Existing code modification - Very important. in ns2, inforamtion about compilation is scattered... we need to make modifications at multiple locations. What are the files that ar

Blackhole attack in ns2 - NS2 Tutorial # 12

How to add a black hole attack in AODV protocol in ns2. https://www.nsnam.com  You can download the source code here: https://drive.google.com/open?id=1LFRrmJM3YXiQT3X1HMSFyS9T9d8oWlIx Black hole is the basic attack in a network, here we are going mitigate this attack in ns2. Trust value, based on the trust value, if the value is less, then we can make it as an attacker node. High trust, medium trust and low trust (integer) Trusted or not (boolean) To make a node attacker node (preferanly a black hole attack, how to do that?) AODV protocol as it is easy to implement in ns2. Step 1: Declare the attacker variable We will two files aodv.h and aodv.cc files  in aodv.h file,  create a variable name as given below in the protected scope bool attacker; Step 2: initialise the attacker variable as false. In aodv.cc file, initialise the attacker to be false inside the constructor. Step 3: if a node is a blackhole, what happens to a

Finding Energy, node position and speed in AODV - NS2 Tutorial # 11.1

AODV - Part 2 Finding the node position, energy and speed of the node while it is forwarding a packet. By default, these codes are not there in AODV, so we are going to modify or append in AODV protocol.. Steps Step 1: Open aodv.h and aodv.cc, these two files will be modified Step 2: Declare variables in aodv.h file in protected mode double xpos,ypos,zpos,energy_t; int n_speed; MobileNode *t_node; FILE *fp; Step 3: initialize these values inside the constrctor of aodv.cc file xpos=ypos=zpos=0.0; n_speed=0; energy_t=0.0; fp=fopen("runtime.dat","w"); Step 4: add the following statements to the forward() function of aodv.cc fprintf(fp,"Position is X, Y, Z, Node Speed,Energy\n"); t_node=(MobileNode*)(Node::get_node_by_address(index)); ((MobileNode*) t_node)->getLoc(&xpos,&ypos,&zpos); fprintf(fp,"%d %f %f %f",index,xpos,ypos,zpos); t_node=(MobileNode*)(Node::get_node_by_address(inde

AODV simulation in NS2 (Part 1) - NS2 Tutorial # 11

Lecture 11 - AODV - Part 1 Todays topic on AODV protocol AODV - Adhoc Ondemand Distance Vector the location of the source code for Aodv is in the folder ~ns-2.35/aodv/ My suggestion is Always try to understand the header file first.. later you can move on to source file (.cc files) I will go through aodv.h file first and then aodv.cc file next.... let me explain.... I should know where my work is residing, for example in AODV should I work on Routing Table Energy Management Quality oif Service Link Failure Logs or tracing Neighbour management Attacks (Black hole, gray hole, etc...) Security so prefer to stay at the header files first... Now the action begins. how do i modify the AODV protocol as per my small piece of algorithm... I would like to print the nodes that are forwarding the packets. Two information will be recorded in a text file separately.. Name of the file: aodv_output.dat data recorded will be: forwarded packet, node index (node numbe

Creation of a New Agent in ns2 - NS2 Tutorial # 10

To create an new Agent in NS2 that describes the OTcl and C++ linkages We know that the file is stored in the folder ~ns-2.35/pradeep/tspagent.cc Open the file ns-2.35/Makefile.in and make an entry of your own file (in this case, it is tspagent.cc Find a vairable inside the Makefile.in called OBJ_CC= and make an entry there as shown below pradeep/tspagent.o \ Save the file and open a terminal, go to the folder ~ns-2.35/ and execute the command one by one $] ./configure $] make Correct any mistakes or errors in your .cc file and run the above commands. Successful OTcl and C++ linkages.... Thank you and Stay tuned for more lectures Next lecture will be on AODV protocol and its modification. Refer my website nsnam.com for downloading the source code and refer my videos at https://www.youtube.com/tspradeepkumar Share and Subscribe. Thank you...... Download the files here https://drive.google.com/open?id=1kaIrYn91xl2NUNNK64cjHrEHyiSJCIiY T S Pradee

Comparison of AODV, DSR and DSDV in ns2 - NS2 Tutorial # 9

Performance Evaluation of Adhoc Routing Protocols using NS2 Very old Project as well as a topic, but this will give an idea of how to compare multiple protocols or agents. 1 hour Project* See the video for the full project * - you should know ns2 already should know how to write AWK scripts Should know about energy model Should know about wireless networks and protocols To know the above concepts, check my Ns2 Lecture series videos in Youtube and come back to this video Youtube.com/tspradeepkumar AODV, DSDV and DSR AODV - Adhoc On Demand Distance Vector DSDV - Destination Sequenced Distance Vector DSR - Dynamic Source Routing Lcture 8 - AWK Scripts Average throughput Instant throughput Residual Energy Packet Delivery ratio To download the source codes, visit https://www.nsnam.com Going inside the project Step 1: Use the same network and same disntace, energy, etc when you compare multiple protocols Step 2: Generate Scenario, You need not write th

AWK Scripts for NS2 - NS2 Tutorial # 8

This is one of the important in ns2 as we are going to analyse the performance metrics of the network In this session, we are going to see the following metrics. 1. Average Throughput 2. instant Throughput 3. Packet Delivery Ratio 4. Residual Energy of the nodes. A - Aho W - Weinberger K - Keninghan Easy to implement and process. BEGIN { } { } END { } In ns2, new trace format, there could be as many as 52 columns. Each column specify some parameters. Viewers are requested to go through these parameters through the documentation. in aAWK, $1 refers 1st column $2 refers 2nd column and so on... awk can be run using either of these commands $] awk -f filename.awk filename.tr or $] gawk -f filename.awk filename.tr Average throughput is done You can download this source code in https://www.nsnam.com Instant Throughput with two values to plot the characteristics. Residual Energy of the individual nodes AND ALSO THE AVERAGE RESIDUAL EN