2011-03-10 6 views
1

ns2를 사용하는 무선 네트워크의 악의적 인 노드에서 패킷을 삭제하는 방법을 시뮬레이션 할 수 있습니까?무선 네트워크에서 패킷 손실 시뮬레이션

+1

은 우리가 질문을 이해 도와주세요 - 당신이 일 수있는 방법을 물어? '패킷'이란 무엇을 의미합니까? 악성 노드를 식별 할 수있는 시스템을 이미 갖추고 있습니까? – Aidanapword

+0

프로그래밍 질문입니까, 아니면 컴퓨터 질문입니까? 후자의 경우 수퍼 유저에게 더 적합 할 수 있습니다. –

+0

@rlb : 네트워크 시뮬레이터 인 ns2에 대한 질문입니다. 질문자는 프로그래밍을 필요로하는 그런 것을 시뮬레이션하는 방법을 묻습니다. (나는 잘 모르지만, Tcl에 쓰여졌음에도 불구하고 ns2를 전혀 모른다.) –

답변

0

먼저 수정해야합니다 aodv.ccaodv.h 파일을 수정해야합니다. aodv.h 에서

/* The Routing Agent */ 
class AODV: public Agent { 

... 

/* 

* History management 

*/ 

double  PerHopTime(aodv_rt_entry *rt); 

... 
add following line 


bool  malicious; 
With this variable we are trying to define if the node is malicious or not. In aodv.cc after 


/* 

    Constructor 

*/ 

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; 

... 
add following line 

malicious = false; 
The above code is needed to initialize, and all nodes are initially not malicious. Then we will write a code to catch which node is set as malicious. In aodv.cc after 


if(argc == 2) { 

    Tcl& tcl = Tcl::instance(); 



    if(strncasecmp(argv[1], "id", 2) == 0) { 

     tcl.resultf("%d", index); 

     return TCL_OK; 

    } 
add following line 


if(strcmp(argv[1], "hacker") == 0) { 

    malicious = true; 

    return TCL_OK; 

} 
Now we will do some work in TCL to set a malicious node. Using script in my post , we add following line to set node 5 as malicious node. 


$ns at 0.0 "[$mnode_(5) set ragent_] hacker" 
You may add this line after 


for {set i 0} {$i < $val(nn)} { incr i } { 

$ns initial_node_pos $mnode_($i) 10 

} 

... 
Alright, we have set malicious node but we did not tell malicious node what to do. As it is known, rt_resolve(Packet *p) function is used to select next hop node when routing data packets. So, we tell malicious node just drop any packet when it receives. To do that after 


/* 

Route Handling Functions 

*/ 

void 

AODV::rt_resolve(Packet *p) { 

struct hdr_cmn *ch = HDR_CMN(p); 

struct hdr_ip *ih = HDR_IP(p); 

aodv_rt_entry *rt; 

... 
We add a few lines 


// if I am malicious node 

if (malicious == true) { 

    drop(p, DROP_RTR_ROUTE_LOOP); 

    // DROP_RTR_ROUTE_LOOP is added for no reason. 

} 

그리고 악의적 인 노드를 구현하는 것은 완료되면. 안전 라우팅 프로토콜을 디자인하는 데 도움이 되길 바랍니다.

은 아래 링크를 참조

http://elmurod.net/en/index.php/archives/196

관련 문제