Friday 31 October 2014

ns2 installation in ubuntu 12.04



NS2 Code for Blackhole Attack (multiple blackholes) in AODV Protocol


The following scenario consists of 25 nodes, in which 1,7 and 13 nodes are blackholenodes and other nodes are non-malicious.


          To create multiple blackhole  attackers in AODV protocol
  
i)             In aodv.h the following blue colour lines needs to be added to define balckhole attackers
    
/*
      * History management
      */
    
double               PerHopTime(aodv_rt_entry *rt);
nsaddr_t malicious1;
nsaddr_t malicious2;
nsaddr_t malicious3;
  
ii)            In  aodv.cc the following blue colour lines needs to be added to initialize the attackers
 
int
AODV::command(intargc, const char*const* argv) {
if(argc == 2) {
Tcl&tcl = Tcl::instance();
if(strncasecmp(argv[1], "id", 2) == 0) {
tcl.resultf("%d", index);
return TCL_OK;
    }
                   if(strcmp(argv[1], "blackhole1") == 0) {
     malicious1= index;
          printf("malicious %d", malicious1);
return TCL_OK;
    }
                   if(strcmp(argv[1], "blackhole2") == 0) {
malicious2=index;
                             printf("malicious %d", malicious2);
return TCL_OK;
    }
                   if(strcmp(argv[1], "blackhole3") == 0) {
                             malicious3= index;
printf("malicious %d", malicious3);
return TCL_OK;
    }
AODV::AODV(nsaddr_t id) : Agent(PT_AODV),
btimer(this), htimer(this), ntimer(this),
rtimer(this), lrtimer(this), rqueue() {
index = id;
seqno = 2;
bid = 1;
  LIST_INIT(&nbhead);
  LIST_INIT(&bihead);
malicious1=999;
  malicious2=999;
  malicious3=999;
  
   Malicious nodes 1,7 and 13 generates fake route replies using following blue colour code
//add in receive route request
if(rq->rq_dst == index) {
#ifdef DEBUG
fprintf(stderr, "%d - %s: destination sending reply\n",
index, __FUNCTION__);
#endif // DEBUG
   // Just to be safe, I use the max. Somebody may have
   // incremented the dstseqno.
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;
sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
index,                // Dest IP Address
seqno,                // Dest Sequence Num
             MY_ROUTE_TIMEOUT,     // Lifetime
rq->rq_timestamp);    // timestamp
   Packet::free(p);
 }
 //blackhole attackers
else if(index==malicious1)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;
sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }      
else if(index==malicious2)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;
sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }
else if(index==malicious3)
 {
seqno = max(seqno, rq->rq_dst_seqno)+1;
if (seqno%2) seqno++;
sendReply(rq->rq_src,           // IP Destination
             1,                    // Hop Count
rq->rq_dst,
                             seqno,
                              MY_ROUTE_TIMEOUT,
rq->rq_timestamp);    // timestamp
 //rt->pc_insert(rt0->rt_nexthop);
   Packet::free(p);
 }
Since, all attackers do not have route to destination, attacker have to disable the send (error).


The following blue colour code disables the send (error) 
 // add in route resolve function (AODV::rt_resolve(Packet *p) )
else {
 Packet *rerr = Packet::alloc();
structhdr_aodv_error *re = HDR_AODV_ERROR(rerr);
 /*
  * For now, drop the packet and send error upstream.
  * Now the route errors are broadcast to upstream
  * neighbors - Mahesh 09/11/99
  */    
assert (rt->rt_flags == RTF_DOWN);
re->DestCount = 0;
re->unreachable_dst[re->DestCount] = rt->rt_dst;
re->unreachable_dst_seqno[re->DestCount] = rt->rt_seqno;
re->DestCount += 1;
#ifdef DEBUG
fprintf(stderr, "%s: sending RERR...\n", __FUNCTION__);
#endif
if((index==malicious1)||(index==malicious2)|| (index==malicious3));
else
sendError(rerr, false);
drop(p, DROP_RTR_NO_ROUTE);

iii)    To define the blackhole attackers in tcl add these lines after node initializations
$ns at 0.0 "[$n1 set ragent_] blackhole1"
$ns at 0.0 "[$n7 set ragent_] blackhole2"
$ns at 0.0 "[$n13 set ragent_] blackhole3"
  Above scenario example tcl  file blackhole attacks scenario
Goodput calculation file goodput
 To calculate goodput:  type-> perl goodput.pl outputfile name  granularity(for 1 or 2... n seconds) > filename
 ex :-> perl goodput.pl out.tr 10 > results   

Packet Delivery Ratio (pdr) file: pdr


To calculate Packet Delivery Ratio:
 
$ perl pdr trafile_name sour-node1 sour_node2 sour_node3 sour_node4 dest_node >fname
eg :

 $perl
pdr.pl our.tr _20_ _21_ _11_ _17_ _18_  > result
If error comes Solution\
Possible Errors
1. I added this code to aodv.h and aodv.cc as per your instructions and in tcl file provided.But i can not understand about Goodput calculation file and perl script.I use ns filename.tcl command to run.but errors are there.How to run this to show results.I have ubuntu 13.04 version and ns2(2.35)simulator.PLease suggest me if any extra thing needs to be added to run this black hole attack project.
 -------------------------------------------------------------------------
2. initially i got the output for all the three mailicious nodes.
but after that i didnt ge for three instead for only one i.e node number 13(working),when i remove the comment for all three its giving floaing point error(core dumped)
so sugges were would be the problem for me.plz its very urgent.
 Solution 
This error occurs due to hop cout value is 0 of a malicious path in aodv.cc code

you should replace hop cout 0 with 1
please modify following aodv.cc code

else if(index==malicious1)
{
…………
……..
…………………..
1, // Hop Count
……………………..
……………………..
}
else if(index==malicious2)
{
…………
……..
…………………..
1, // Hop Count
……………………..
……………………..
}
else if(index==malicious3)
{
…………
……..
…………………..
1, // Hop Count
……………………..
……………………..
}
Then make clean followed by make to create new aodv object files
3. Possible error
I have replaced modified aodv.cc and aodv.h files with original aodv files..but when i m running the tcl file i m getting the following errors...
num_nodes is set 25
INITIALIZE THE LIST xListHead
ns: _o39 blackhole1:
(_o39 cmd line 1)
invoked from within
"_o39 cmd blackhole1"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o39" line 2)
(SplitObject unknown line 2)
invoked from within
"_o39 blackhole1" 
----------------------------
 If steps are not clear

Thanks for your personnel mail and attention.
I have successfully compiled the code on my machine
Steps:
cd ns-allinone folder
cd ns-2.35
make clean
make
make ./install
./configure
5. Possible error
after running the tcl script i am getting this error
num_nodes is set 25
invalid command name "-antType"
while executing
"-antType $val(ant) \
"
(file "blackhole.tcl" line 73)
what does it mean?
set val(ant) Antenna/OmniAntenna is the right command

an omnidirectional antenna is a class of antenna which radiates radio wave power uniformly in all directions in one plane, with the radiated power decreasing with elevation angle above or below the plane, dropping to zero on the antenna's axis. 
6. If you are getting like this 
num_nodes is set 25
INITIALIZE THE LIST xListHead
ns: _o39 blackhole1:
(_o39 cmd line 1)
invoked from within
"_o39 cmd blackhole1"
invoked from within
"catch "$self cmd $args" ret"
invoked from within
"if [catch "$self cmd $args" ret] {
set cls [$self info class]
global errorInfo
set savedInfo $errorInfo
error "error when calling class $cls: $args" $..."
(procedure "_o39" line 2)
(SplitObject unknown line 2)
invoked from within
"_o39 blackhole1"

this the error what I am getting
once you replace the original aodv files with blackhole aodv files
the open ns.2.xx folder
make clean
make

If it wont work follow these steps:

If it won't work follow these steps:
To overcome this problem, do the following steps 1:

1. Un-install all ns2 versions(if you have to are more) and thier path settings.
2. re-intall ns2.33 or ns2.34 version
3. follow steps mentioned in this blogg to create blackhole attacl
 
7.If u got this type of error
i am using ns2.35 and when i followed this step,
Steps:
cd ns-allinone folder
cd ns-2.35
make clean
make
make ./install
./configure

I got the following error:-
queue/priqueue.cc: In member function ‘virtual void PriQueue::recv(Packet*, Handler*)’:
queue/priqueue.cc:94:6: error: ‘PT_blackholeAODV’ was not declared in this scope
case PT_blackholeAODV:
^
make: *** [queue/priqueue.o] Error 1

I also modified aodv.cc and aodv.h file.
Solution This error indicates you have already added some blackhole patch, on top this your were trying to add our blackhole code my suggestion is better undo the previous patch then add our code or
delete the present ns2 and re-install ns2 then add our code 
8. If theis is the error
I re-installed ns2.35 and tried again.
After the make operation,this is the errors which i am getting:-
make[1]: Leaving directory `/home/ns-allinone-2.35/ns-2.35/indep-utils/webtrace-conv/ucb'
Inspiron-1545:~/ns-allinone-2.35/ns-2.35$ make./install
bash: make./install: No such file or directory 
Solution after making changes in aodv.cc and aodv.h file... Check this code
#Setup a CBR Application over UDP connection
set cbr1 [new Application/Traffic/CBR]
$cbr1 attach-agent $udp1
$cbr1 set packetSize_ 1000
$cbr1 set rate_ 0.1Mb
$cbr1 set random_ null
$ns at 20.0 "$cbr1 start"
$ns at 40.0 "$cbr1 stop"
9.The root of problems
In ns2 when a node is created it will acts like router.i.e it gets functionalities of three layers (physical,data,n/w). Now to make a particular node as source or destination ,we need to add remaining two layers functionalities (i.e transport & application). So for that purpose we are adding UDP agent over node.and then CBR application to generate traffic over udp...UDP belongs to Transport layer and CBR belongs to Application layer .Now the node will act like system ,you can make it as source or destination to transfer data from on node to another...
Now coming to above code line by line
1) Creating an object cbr1 for CBR application
2)attaching it over udp..as we know application layer comes on top of transport layer
3,4,5 lines are used to set default values for parameters like packet size, rate of generation of packets ,motion
6,7 lines are used at what time this cbr traffic(i.e generating packets) to start and when to stop ....

Hope you understand now..
Last Possible error
hello
I got the nam output .
What can I infer from that animation?
1,7,13 are the malicious nodes..How do they become the blackholes in the animation ?Please explain 
Solution In the given tcl file ,1,7,13 are the blackhole nodes.But we can see only node '1' dropping the packets in the simulation.
Because the roots established by aodv does not take in to account the other nodes.

We can check by changing the malicious nodes to 15 ..and observe the change. 

 
Many of you are getting the error

"num_nodes is set 25
INITIALIZE THE LIST xListHead
ns: _o39 blackhole1:
(_o39 cmd line 1)
invoked from within
"_o39 cmd blackhole1"
invoked from within
"catch "$self cmd $arg............"


I got the output on my first run ..
Then this error was shown..
I had updated my nam instance in between..i believe this may be the cause..also if u have installed ubuntu updates or anything ..u may also get this error..
So before making changes to aodv ,I had kept a copy of ns-allinone folder..So i recopied it and again applied the changes ..

make
make clean
make ./install
./configure

i think may be my makefile or some crucial files may have changed ,because of that i got the error..

If u do not have a copy uninstall ns2 and then install and try from scratch..

This code is 100% working :) 

Solution 2 Black Hole Attack In Wirelessz ADHOC NETWORKS in Ubuntu

Monday 27 October 2014

Dear Readers,

 I hope you all are taking advantage from my blog i mean regarding study or improving knowledge.
A request to all readers of my blog regarding name suggestion. please suggest a good name for this blog.

Thanks in advance.
SET Exam
APSET & TESET (Andhra Pradesh & Telangana) Notification released

Most Commented Posts Widget for Blogger with Comment bubbles!

 
Most of you requested how we created the Most commented widget that shows the list of Top10 most popular posts sorted by comment bubbles. You can see this widget on our sidebar under the heading "Most Discussed". What we did here was using existing script from Yahoo! Pipes that uses json to parse and display each post with highest number of comments posted on it. Using CSS3 pseudo properties, we then styled the comment count with comment bubbles. This widget is simply a copy-paste tool that can be installed within seconds. Lets add this dynamic and fast loading widget to your blogger blogs!


Looking for how we created that ribbon style background for this widget? Then try this:

Add Most Commented Widget to Blogger

  1. Go to Blogger > Layout
  2. Click "Add a Gadget"
  3. Choose HTML/JavaScript widget
  4. Paste the Following code inside it:
<style>
/* ######### Most Commented Widget by SKM ##########*/
.commentbubble {
background: #292D30;
width: 49px;
float: left;
margin: 2px 20px 35px 0px;
font-weight: bold;
font-size: 1.3em;
text-align: right;
font-family: georgia,Helvetica;
padding: 0px 0px 5px 0px;
text-align: right;
color: #FFF;
text-shadow: 4px 1px #202022;
position: relative;
top: 5px;

}
.commentbubble:after {
content: ' ';
position: absolute;
width: 0;
height: 0;
right: 0px;
top: 100%;
border-width: 5px 8px;
border-style: solid;
border-color: #292D30 #292D30 rgba(0, 0, 0, 0) rgba(0, 0, 0, 0);
top: 34px;
right: 6px;
}
</style>

<script type="text/javascript">
function getYpipePP(feed) {
document.write('<ul style="list-style:none; ">');
var i;
for (i = 0; i < feed.count ; i++)
{
var href = "'" + feed.value.items[i].link + "'";
var pTitle = feed.value.items[i].title;
var pComment = + feed.value.items[i].commentcount;
var pList = '<li style="clear:both; padding:10px 0px 30px 0px!important; border-bottom: 1px dashed #dedede; line-height:2em; "> <div class="commentbubble">' +pComment +  "&#160;&#160;</div>" +  "<a href="+ href + '" target="_blank">' + pTitle ;
document.write(pList);
//to remove comment count delete this line
document.write('</a></li>');
}
document.write('</ul>');
}
</script>
<script src="http://pipes.yahoo.com/pipes/pipe.run?
 YourBlogUrl=http://www.imraan-prrec.blogspot.com
&ShowHowMany=6
&_id=390e906036f48772b2ed4b5d837af4cd
&_callback=getYpipePP
&_render=json"
type="text/javascript"></script>

Make these small changes:
  • Replace with your Blog URL  http://www.imraan-prrec.blogspot.com
  • Replace this 6 with how many post titles you wish to display in the list.
  • To change the background color of the comment bubbles, Simply replace the yellow highlighted hexadecimal color codes ( #292D30 ) with your custom color.
  • To change the Text color of the Comment count Replace #FFF.
  • Replace #dedede if you wish to change the border color that appears below each post title. If you don't want to show a border below each list item then simply delete this line:  border-bottom: 1px dashed #dedede; 
  5. Save and you are all done!
Visit your blog and see a beautiful list of Populat Posts with Fancy comment bubbles! 

Credit Cards

For Choosing  Card Payment Gateway For Your Blog / Website?

 
 More and more people are looking for alternatives to their regular jobs. As a result, many small online businesses have surfaced especially in the past few years. And the Credit Card has facilitated the online business industry, commonly known as e-commerce. A growing number of people now want to buy stuff over the internet while sitting in the comfort of their living room, all thanks to the Credit Card which gives them the leisure. This means that now is as good a chance as any to incorporate e-commerce to your website. This also means you need to have a mechanism to accept Credit Cards on your blog / website,

Define a Payment Gateway?

For accepting payments through credit cards / debit , you need a payment gateway. A payment gateway is a company that provides e-commerce functionality. All transactions online via a credit card must go through such a gateway. In simple words, they are companies that process all credit card transactions. The services they provide are known as merchant services, and mostly, they require you to set up a merchant account with them.
Some popular Payment Gateways
There are many competitive companies out there in the industry, such as RuPay, PayPal, ProPay, Merchant Warehouse etc. So choosing the right one can be a challenge. Here are some things you need to consider before choosing a company. Hopefully, these tips will help you make a better decision.

Processing demands

This should be your first thought. Select a payment processor that best suits your business size. If your processing needs are small, say under $1,000, then you are best off with PayPal, since they don't require you to sign a contract, and the fees are quite reasonable. Their system is very easy to integrate as well, which makes PayPal the optimal solution for small businesses.

Rates and feesRates and Fees

The discount rates and other fees are influenced by many factors, such as the type of your business, how long you have been in business, the average amount of your sales, your personal credit rating etc. These factors can determine how high your costs can go. But be sure to check what the other companies will be charging, before agreeing to one company's rates. There are other types of fees as well, such as the initial cost, monthly statements, monthly minimums etc. It may be that other companies are offering lower rates for the same credentials.
Also make sure that you are not being charged for services irrelevant to your business. Some companies will give you a package plan that includes credit card swipe. Since you have an online business, credit cards on your site will be keyed in rather than swiped (passed through a machine). Hence, the swipe feature is useless for you.

Read the terms and conditions CAREFULLY!

The credit card industry is infamous for its 'shadowy' practices.Before signing on any contract, make sure you have read and understood all the terms of the agreement carefully. Read all the contracts and application forms sent to you. Pay special attention to small print. That is usually where the 'hidden' costs are mentioned. For example, many companies charge you if you stop credit card processing through them before a set amount of time. Read all such conditions carefully. Get an attorney if you need one.
Some companies also require you to maintain an account in their bank for payment processing. If this is the case, read the terms of the account carefully. Learn about how much the bank will hold back and under what circumstances, how often can you withdraw money etc. Also check under what conditions can the bank terminate our account. Reading all such conditions can save you frustrations and sticks spots in the future.

Change-back policies

Take a careful look at the change-back and refund policies for the company you want to choose. A lot of companies give customers the advantage on complaints such as "item not received" etc. In that case, not only will the customer be refunded, the company may also fine you an amount.
Refund policies

Integration

Also check whether the company's APIs are compatible with the shopping cart software you are using etc. Also, it is preferable that the company support mobile processing i.e. processing payments on the go. Check if there's an app for your smart phone. This might be a minor issue though.

Up time

The payment gateway you choose needs to be robust as well. Servers can crash, and networks can get interrupted, resulting in failed transactions. Check the service's up time statistics before making a decision.

And finally....Bargain!

Bargaining is very important here. Most companies will try to over-charge you. But most will be open to negotiations as well. If you accept the first contract they put forth, it is likely that you will over-pay them. Try bargaining on each turn, whether for discounts,  per-transaction fee, miscellaneous fee etc. Find another gateway if one doesn't relent to your demands. There are plenty of competitors out there.
That's all the tips I had for now to share with you. Hopefully you learned something from them.

me

AFTER BTECH IF COMING FOR FACULTY SIDE

BTech / BE
MTech / ME
   GATE
   NET / SET
   Ph.D