2014-02-10 6 views
0

NS2에서 타이머를 구현하는 동안 문제가 있습니다. 만료시 만료 된 타이머를 구현하고 싶습니다.세그먼트 화 오류를 일으키는 NS2의 타이머

fap.h : 코드의

void HelloTimer:: expire(Event* event) 
{ 
//agent->sendHello(); 
printf("expired\n");  
} 
int Fap::command(int argc, const char* const* argv) 
{ 
Tcl& tcl = Tcl::instance(); 
if(argc == 2) 
{ 
    if(strcmp(argv[1], "hello") == 0) 
    { 
     helloTimer.resched(30); //problem occurs here 
        helloTimer.status(); //no problem with this 
        return (TCL_OK); 
    } 
} 
else if(argc == 3) 
{ 

    if(strcmp(argv[1], "set-ll") == 0) 
    { 
     NsObject* temp; 
     temp = (NsObject*)(TclObject::lookup(argv[2])); 
     ll = temp; 
     return (TCL_OK); 
    } 


} 
else 
{ 
    printf("invalid number of args"); 

} 
Agent::command(argc,argv); 
return(TCL_OK); 

} 

만 관련 부분은 내가 타이머를 재조정하려고 added.Whenever왔다

class Fap; 
class HelloTimer : public TimerHandler 
{ 
    public: 
    HelloTimer(Fap* fapAgent) : TimerHandler(){agent = fapAgent;}  
    protected: 
    Fap* agent; 
    inline virtual void expire(Event* e);   

}; 

class Fap : public Agent 
{ 
public: 
Fap(void); 
int filter[ADDRESS_SPACE]; 
int address; 
int netId; 
int requestedIp; 
bool configured; 
nsaddr_t requestor; 
nsaddr_t initiator; 
HelloTimer helloTimer; 
TcpAgent* tcp; 
NsObject* ll; 
void recv(Packet* p, Handler*); 
void sendHello(void); 
int command(int, const char* const*); 
}; 

fap.cc은 resched 사용하여 다음과 같이 코드는() 세그먼트 화 오류가 발생합니다. 내가 놓친 게 있니?

답변

0

이것은 클래스 이름이 충돌 한 결과입니다. 타이머 클래스 이름에 접두어를 붙이기 만하면됩니다.