Page 1 of 2 12 LastLast
Results 1 to 15 of 22

Thread: NS2 and TORA Routing Protocol

  1. #1
    Join Date
    Nov 2008
    Posts
    69

    NS2 and TORA Routing Protocol

    Hi mates

    I have a strange problem regarding network. I just want to ask that anyone who has run TORA routing protocol successfully can please help me.

    I have problem that has been really bothering my work for sometime.
    I also want to execute the TORA protocol in ns2 and it really gives me headache as it gives me some errors.
    I tried creating so many attempts and tested them to run on other protocols namely DSR and AODV but when I try to use TORA, the same scripts and attempts give me errors.
    I also know that there must be a modification to do on the protocol itself or the ns2.

    Below provided is the Error Code:
    \\
    (_o17 cmd line 1)
    invoked from within
    "_o17 cmd port-dmux _o28"
    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 "_o17" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "$agent port-dmux $dmux_"
    (procedure "_o14" line 11)
    (Node/MobileNode add-target-rtagent line 11)
    invoked from within
    "$self add-target-rtagent $agent $port"
    (procedure "_o14" line 23)
    (Node/MobileNode add-target line 23)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o14" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 72)
    (Simulator create-wireless-node line 72)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    ("for" body line 2)
    invoked from within
    "for {set i 0} {$i < $val(nn) } { incr i } {
    set node_($i) [$ns node]
    }"
    (file "wrls-tora1.tcl" line 56)
    //

  2. #2
    Join Date
    May 2008
    Posts
    3,516

    Post Re: NS2 and TORA Routing Protocol

    Try this code:

    #include <agent.h>
    #include <random.h>
    #include <trace.h>
    #include <ll.h>
    #include <priqueue.h>
    #include <tora/tora_packet.h>
    #include <tora/tora.h>

    #define LOG(s)
    fprintf(stdout, "%s --- %s (index: %d, time: %f)\n",
    __PRETTY_FUNCTION__, (s), index, Scheduler::instance().clock())
    #define DEBUG
    #define CURRENT_TIME Scheduler::instance().clock()
    #define ARP_SEPARATION_DELAY 0.030
    int hdr_tora::offset_;
    static class TORAHeaderClass : public PacketHeaderClass {
    public:
    TORAHeaderClass() : PacketHeaderClass("PacketHeader/TORA",
    TORA_HDR_LEN) {
    bind_offset(&hdr_tora::offset_);
    }
    } class_toraAgent_hdr;

    static class toraAgentclass : public TclClass {
    public:
    toraAgentclass() : TclClass("Agent/TORA") {}
    TclObject* create(int argc, const char*const* argv) {
    assert(argc == 5);
    return (new toraAgent((nsaddr_t) atoi(argv[4])));
    }
    } class_toraAgent;
    toraAgent::toraAgent(nsaddr_t id) :
    rtAgent(id, PT_TORA),
    rqueue()
    {
    LIST_INIT(&dstlist);
    imepagent = 0;
    logtarget = 0;
    ifqueue = 0;
    }

    void
    toraAgent::reset()
    {
    Packet *p;
    while((p = rqueue.deque())) {
    drop(p,DROP_END_OF_SIMULATION);
    }
    }

    int
    toraAgent::command(int argc, 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;
    }
    }
    else if(argc == 3) {

    if(strcmp(argv[1], "log-target") == 0 || strcmp(argv[1], "tracetarget") == 0 ) {
    logtarget = (Trace*) TclObject::lookup(argv[2]);
    if(logtarget == 0)
    return TCL_ERROR;
    return TCL_OK;
    }
    else if(strcmp(argv[1], "drop-target") == 0) {
    int stat = rqueue.command(argc,argv);
    if (stat != TCL_OK) return stat;
    return Agent::command(argc, argv);
    }
    else if(strcmp(argv[1], "if-queue") == 0) {
    ifqueue = (PriQueue*) TclObject::lookup(argv[2]);
    if(ifqueue == 0)
    return TCL_ERROR;
    return TCL_OK;
    }
    else if(strcmp(argv[1], "imep-agent") == 0) {
    imepagent = (imepAgent*) TclObject::lookup(argv2]);
    if(imepagent == 0)
    return TCL_ERROR;
    imepagent->imepRegister((rtAgent*) this);
    return TCL_OK;
    }
    else if (strcmp(argv[1], "port-dmux") == 0) {
    dmux_ = (PortClassifier *)TclObject::lookup(argv[2]);
    if (dmux_ == 0) {
    printf (stderr, "%s: %s lookup of %s failed\n", __FILE__,
    argv[1], argv[2]);
    return TCL_ERROR;
    }
    return TCL_OK;
    }
    }
    return Agent::command(argc, argv);
    }
    TORADest*
    toraAgent::dst_find(nsaddr_t id)
    {
    TORADest* td = dstlist.lh_first;
    for( ; td; td = td->link.le_next) {
    if(td->index == id)
    return td;
    }
    return 0;
    }
    TORADest*
    toraAgent::dst_add(nsaddr_t id)
    {
    TORADest *td = new TORADest(id, this);
    assert(td);
    LIST_INSERT_HEAD(&dstlist, td, link);
    int *nblist = 0, nbcnt = 0;
    imepagent->imepGetBiLinks(nblist, nbcnt);
    for(int i = 0; i < nbcnt; i++)
    (void) td->nb_add(nblist[i]);
    if(nblist) delete[] nblist;
    return td;
    }
    void
    toraAgent::dst_dump()
    {
    TORADest *td = dstlist.lh_first;
    for( ; td; td = td->link.le_next)
    td->dump();
    }
    void
    toraAgent::forward(Packet *p, nsaddr_t nexthop, Time delay)
    {
    struct hdr_cmn *ch = HDR_CMN(p);
    #ifdef TORA_DISALLOW_ROUTE_LOOP
    if(nexthop == ch->prev_hop_) {
    log_route_loop(ch->prev_hop_, nexthop);
    drop(p, DROP_RTR_ROUTE_LOOP);
    return;
    }
    #endif
    ch->next_hop() = nexthop;
    ch->prev_hop_ = ipaddr();
    ch->addr_type() = NS_AF_INET;
    ch->direction() = hdr_cmn:: DOWN;
    if (0.0 == delay) {
    tora_output(p);
    } else {
    Scheduler::instance().schedule(target_, p, delay);
    }
    }
    void
    toraAgent::rt_resolve(Packet *p)
    {
    struct hdr_ip *ih = HDR_IP(p);
    TORADest *td;
    TORANeighbor *tn;
    td = dst_find(ih->daddr());
    if(td == 0) {
    td = dst_add(ih->daddr());
    }
    tn = td->nb_find_next_hop();
    if(tn == 0) {
    rqueue.enque(p);
    trace("T %.9f _%d_ tora enq %d->%d",
    Scheduler::instance().clock(), ipaddr(),
    ih->saddr(), ih->daddr());
    if(!td->rt_req)
    { // if no QRY pending, then send one
    sendQRY(ih->daddr());
    td->time_tx_qry = CURRENT_TIME;
    td->rt_req = 1;
    }
    }
    else {
    forward(p, tn->index);
    }
    }
    void
    toraAgent::recv(Packet *p, Handler *)
    {
    struct hdr_cmn *ch = HDR_CMN(p);
    struct hdr_ip *ih = HDR_IP(p);
    assert(initialized());
    if(ch->ptype() == PT_TORA) {
    recvTORA(p);
    return;
    }
    ch->size() += IP_HDR_LEN;

    ih->ttl_ = IP_DEF_TTL;
    }
    #ifdef TORA_DISALLOW_ROUTE_LOOP
    else if(ih->saddr() == ipaddr()) {
    drop(p, DROP_RTR_ROUTE_LOOP);
    return;
    }
    #endif
    else {
    if(--ih->ttl_ == 0) {
    drop(p, DROP_RTR_TTL);
    return;
    }
    }
    rt_resolve(p);
    }
    void
    toraAgent::recvTORA(Packet *p)
    {
    struct hdr_tora *th = HDR_TORA(p);
    TORADest *td;
    TORANeighbor *tn;
    assert(HDR_IP (p)->sport() == RT_PORT);
    assert(HDR_IP (p)->dport() == RT_PORT);
    switch(th->th_type) {
    case TORATYPE_QRY:
    recvQRY(p);
    Packet::free(p);
    return;
    case TORATYPE_UPD:
    log_recv_upd(p);
    recvUPD(p);
    break;
    case TORATYPE_CLR:
    log_recv_clr(p);
    recvCLR(p);
    break;
    default:
    fprintf(stderr,
    "%s: Invalid TORA type (%x)\n",
    __PRETTY_FUNCTION__, th->th_type);
    exit(1);
    }
    if((td = dst_find(th->th_dst)) == 0) {
    Packet::free(p);
    return;
    }
    logNextHopChange(td);
    if((tn = td->nb_find_next_hop())) {
    Packet *p0;
    Time delay = 0.0;
    while((p0 = rqueue.deque(td->index))) {
    forward(p0, tn->index, delay);
    delay += ARP_SEPARATION_DELAY;
    }
    }
    Packet::free(p);
    }
    void
    toraAgent::recvQRY(Packet *p)
    {
    struct hdr_ip *ih = HDR_IP(p);
    struct hdr_tora_qry *qh = HDR_TORA_QRY(p);
    TORADest *td;
    TORANeighbor *tn;
    if(qh->tq_dst == ipaddr()) {
    #ifdef DEBUG
    fprintf(stderr, "node %d received `QRY` for itself.\n", index);
    #endif
    return;
    }

    td = dst_find(qh->tq_dst);
    if(td == 0)
    td = dst_add(qh->tq_dst);
    if(td->rt_req) {
    return;
    }
    if(td->height.r == 0) {
    tn = td->nb_find(ih->saddr());
    if(tn && tn->time_act > td->time_upd) {
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    else {
    }
    }
    else {
    tn = td->nb_find_min_height(0);

    if(tn) {
    td->update_height(tn->height.tau,
    tn->height.oid,
    tn->height.r,
    tn->height.delta + 1,
    ipaddr());
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    else {
    td->rt_req = 1;
    td->time_rt_req = CURRENT_TIME;
    if(td->num_active > 1) {
    sendQRY(td->index);
    }
    else {
    }
    }
    }
    }
    void
    toraAgent::recvUPD(Packet *p)
    {
    struct hdr_ip *ih = HDR_IP(p);
    struct hdr_tora_upd *uh = HDR_TORA_UPD(p);
    TORADest *td;
    TORANeighbor *tn;
    if(uh->tu_dst == ipaddr()) {
    return;
    }
    td = dst_find(uh->tu_dst);
    if(td == 0)
    td = dst_add(uh->tu_dst);
    tn = td->nb_find(ih->saddr());
    if(tn == 0) {
    CURRENT_TIME, ipaddr(), ih->saddr());
    #ifdef DEBUG
    fprintf(stderr,
    "node %d received `UPD` from non-neighbor %d\n",
    index, ih->src_);
    #endif
    return;
    }
    td->update_height_nb(tn, uh);

    if(td->rt_req && tn->height.r == 0) {
    td->update_height(tn->height.tau,
    tn->height.oid,
    tn->height.r,
    tn->height.delta + 1,
    ipaddr());
    td->rt_req = 0;
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    else if(td->num_down == 0) {
    if(td->num_up == 0) {
    if (td-height.isNull ())
    return;
    else {
    td->height.Null();
    td->time_upd = Scheduler::instance().clock ();
    sendUPD(td->index);
    }
    }
    else {
    if(td->nb_check_same_ref()) { TORANeighbor *tn;
    if( (tn = td->nb_find_min_height(0)) ) { td->update_height (tn>height.tau, tn->height.oid,
    ipaddr());
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    else {
    if(td->height.oid == ipaddr()) { // II, A, 2, a, ii
    double temp_tau = td->height.tau; nsaddr_t temp_oid = td->height.oid;
    td->height.Null();
    td->num_down = 0;
    td->num_up = 0;
    for(tn = td->nblist.lh_first; tn; tn = tn->link.le_next) {
    if(tn->index == td->index) {
    tn->height.Zero();
    tn->lnk_stat = LINK_DN;
    }
    else {
    tn->height.Null();
    tn->lnk_stat = LINK_UN;
    }
    }
    sendCLR(td->index, temp_tau, temp_oid);
    }
    else {
    td->update_height(Scheduler::instance().clock(),
    ipaddr(),
    0,
    0,
    ipaddr());
    td->rt_req = 0;
    td->time_upd = Scheduler::instance().clock();
    #ifdef DEBUG
    if (logtarget)
    {
    sprintf(logtarget->pt_->buffer(), "T %.9f _%d_ rule IIA2a(ii)x fires %d",
    Scheduler::instance().clock(), ipaddr(), td->index);
    logtarget->pt_->dump();
    }
    #endif
    sendUPD(td->index);
    }
    }

    }
    else {
    TORANeighbor *n = td->nb_find_max_height();
    assert(n);
    TORANeighbor *m = td->nb_find_min_nonnull_height(&n->height);
    assert(m);
    td->update_height(m->height.tau,
    m->height.oid,
    m->height.r,
    m->height.delta - 1,
    ipaddr());
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    }
    }
    else {
    }
    }
    toraAgent::recvCLR(Packet *p)
    {
    struct hdr_ip *ih = HDR_IP(p);
    struct hdr_tora_clr *th = HDR_TORA_CLR(p);
    TORADest *td;
    TORANeighbor *tn;
    if(th->tc_dst == ipaddr()) {
    return;
    }
    td = dst_find(th->tc_dst);
    if(td == 0)
    td = dst_add(th->tc_dst);
    assert(td);
    if(td->height.tau == th->tc_tau &&
    td->height.oid == th->tc_oid &&
    td->height.r == 1) { double temp_tau = td->height.tau;
    nsaddr_t temp_oid = td->height.oid;
    td->height.Null();
    td->num_up = 0;
    td->num_down = 0;
    for(tn = td->nblist.lh_first; tn; tn = tn->link.le_next) {
    if(tn->index == td->index) {
    tn->height.Zero();
    tn->lnk_stat = LINK_DN;
    }
    else {
    tn->height.Null();
    tn->lnk_stat = LINK_UN;
    }
    }
    if(td->num_active > 1) { sendCLR(td->index, temp_tau, temp_oid);
    }
    else {
    }
    }
    else {
    tn = td->nb_find(ih->saddr());
    if(tn == 0) {
    trace("T %.9f _%d_ received `CLR` from non-neighbor %d",
    CURRENT_TIME, index, ih->saddr());
    #ifdef DEBUG
    fprintf(stderr,
    "node %d received `CLR` from non-neighbor %d\n",
    index, ih->src_);
    #endif
    return;
    }

    tn->height.Null();
    tn->lnk_stat = LINK_UN;
    for(tn = td->nblist.lh_first; tn; tn = tn->link.le_next) {
    if(tn->height.tau == th->tc_tau &&
    tn->height.oid == th->tc_oid &&
    tn->height.r == 1) {
    tn->height.Null();
    tn->lnk_stat = LINK_UN;
    }
    }
    if(td->num_down == 0) {
    if(td->num_up == 0) { if(td->height.isNull()) { }
    else {
    td->height.Null();
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    }
    else {
    td->update_height(Scheduler::instance().clock(),
    ipaddr(),
    0,
    0,
    ipaddr());
    td->rt_req = 0;
    td->time_upd = Scheduler::instance().clock();
    sendUPD(td->index);
    }
    }
    else {
    }
    }
    }

    void
    toraAgent::trace(char* fmt, ...)
    {
    va_list ap;

    if (!logtarget) return;
    va_start(ap, fmt);
    vsprintf(logtarget->pt_->buffer(), fmt, ap);
    logtarget->pt_->dump();
    va_end(ap);
    }

  3. #3
    Join Date
    Apr 2008
    Posts
    3,339

    Re: NS2 and TORA Routing Protocol

    Check this one:

    #ifndef __tora_h__
    #define __tora_h__
    #include <packet.h>
    #include <ip.h>
    #include <cmu-trace.h>
    #include <priqueue.h>
    #include <rtqueue.h>
    #include "lib/bsd-list.h"
    #include <rtproto/rtproto.h>
    #include <imep/imep.h>
    #include <tora/tora_packet.h>
    #include <tora/tora_neighbor.h>
    #include <tora/tora_dest.h>
    #include <classifier/classifier-port.h>
    LIST_HEAD(td_head, TORADest);
    #define LOGGING
    typedef double Time;
    #define TORA_DISALLOW_ROUTE_LOOP
    #define MinQueryRate 0.200
    class TORANeighbor;
    class TORADest;
    class Height;
    class toraAgent : public rtAgent {
    friend class TORANeighbor;
    friend class TORADest;
    public:
    toraAgent(nsaddr_t id);
    void recv(Packet* p, Handler*);
    int command(int argc, const char*const* argv);
    void rtNotifyLinkUP(nsaddr_t index);
    void rtNotifyLinkDN(nsaddr_t index);
    void rtNotifyLinkStatus(nsaddr_t index, u_int32_t status);
    void rtRoutePacket(Packet *p);
    private:
    nsaddr_t index;
    TORADest* dst_find(nsaddr_t id);
    TORADest* dst_add(nsaddr_t id);
    void dst_dump(void);
    void rt_resolve(Packet *p);
    void forward(Packet *p, nsaddr_t nexthop, Time delay = 0.0);
    void purge_queue(void);
    void enque(TORADest *td, Packet *p);
    Packet* deque(TORADest *td);
    void recvTORA(Packet* p);
    void recvQRY(Packet *p);
    void recvUPD(Packet *p);
    void recvCLR(Packet *p);
    void sendQRY(nsaddr_t id);
    void sendUPD(nsaddr_t id);
    void sendCLR(nsaddr_t id, double tau, nsaddr_t oid);
    void tora_output(Packet *p);
    inline int initialized() {
    return logtarget && ifqueue && imepagent;
    }

    td_head dstlist; // Active destinations
    imepAgent *imepagent;
    Trace *logtarget;
    void trace(char* fmt, ...);
    virtual void reset();
    rtqueue rqueue;
    PriQueue *ifqueue;
    void log_route_loop(nsaddr_t prev, nsaddr_t next);
    void log_link_layer_feedback(Packet *p);
    void log_link_layer_recycle(Packet *p);
    void log_lnk_del(nsaddr_t dst);
    void log_lnk_kept(nsaddr_t dst);
    void log_nb_del(nsaddr_t dst, nsaddr_t id);
    void log_recv_qry(Packet *p);
    void log_recv_upd(Packet *p);
    void log_recv_clr(Packet *p);
    void log_route_table(void);
    void log_dst_state_change(TORADest *td);
    void logNextHopChange(TORADest *td);
    void logNbDeletedLastDN(TORADest *td);
    void logToraDest(TORADest *td);
    void logToraNeighbor(TORANeighbor *tn);
    protected:
    PortClassifier *dmux_;
    };
    #endif /* __tora_h__ */

  4. #4
    Join Date
    Jan 2006
    Posts
    4,221

    Re: NS2 and TORA Routing Protocol

    You can go for this:

    set opt(imep) "ON" ;# Enable/Disable IMEP
    set opt(ragent) Agent/rtProto/TORA
    set opt(pos) NONE ;# Box or NONE
    if { $opt(pos) == "Box" } {
    puts "*** TORA using Box configuration..."
    }
    #
    Agent instproc init args {
    $self next $args
    }
    Agent/rtProto instproc init args {
    puts "DOWN HERE 2"
    $self next $args
    }
    Agent/rtProto/TORA instproc init args {
    puts "DOWN HERE"
    $self next $args
    }
    Agent/rtProto/TORA set sport_ 0
    Agent/rtProto/TORA set dport_ 0
    #
    proc create-routing-agent { node id } {
    global ns_ ragent_ tracefd opt
    #
    # Create the Routing Agent and attach it to port 255.
    #
    set ragent_($id) [new $opt(ragent) $id]
    set ragent $ragent_($id)
    $node attach $ragent [Node set rtagent_port_]
    $ragent if-queue [$node set ifq_(0)] ;# ifq between LL and MAC
    # now that the Beacon/Hello messages have been
    # moved to the IMEP layer, this is not necessary.
    $ns_ at 0.$id "$ragent_($id) start" ;# start BEACON/HELLO Messages
    #
    # XXX: The routing protocol and the IMEP agents needs handles
    # to each other.
    #
    $ragent imep-agent [$node set imep_(0)]
    [$node set imep_(0)] rtagent $ragent
    #
    # Drop Target (always on regardless of other tracing)
    #
    set drpT [cmu-trace Drop "RTR" $node]
    $ragent drop-target $drpT
    #
    # Log Target
    #
    set T [new Trace/Generic]
    $T target [$ns_ set nullAgent_]
    $T attach $tracefd
    $T set src_ $id
    $ragent log-target $T
    #
    # XXX: let the IMEP agent use the same log target.
    #
    [$node set imep_(0)] log-target $T
    proc create-mobile-node { id } {
    global ns_ chan prop topo tracefd opt node_
    global chan prop tracefd topo opt
    set node_($id) [new Node/MobileNode]
    set node $node_($id)
    $node random-motion 0 ;# disable random motion
    $node topography $topo
    #
    # This Trace Target is used to log changes in direction
    # and velocity for the mobile node.
    #
    set T [new Trace/Generic]
    $T target [$ns_ set nullAgent_]
    $T attach $tracefd
    $T set src_ $id
    $node log-target $T

    $node add-interface $chan $prop $opt(ll) $opt(mac) \
    $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant)
    #
    # Create a Routing Agent for the Node
    #
    create-routing-agent $node $id
    if { $opt(pos) == "Box" } {
    #
    # Box Configuration
    #
    set spacing 200
    set maxrow 7
    set col [expr ($id - 1) % $maxrow]
    set row [expr ($id - 1) / $maxrow]
    $node set X_ [expr $col * $spacing]
    $node set Y_ [expr $row * $spacing]
    $node set Z_ 0.0
    $node set speed_ 0.0

    $ns_ at 0.0 "$node_($id) start"
    }
    }

  5. #5
    Join Date
    Jun 2009
    Posts
    2

    Re: NS2 and TORA Routing Protocol

    Hi I wanted to TORA ins ns-2.32 and made necessary modifications in tora.cc and tora.h . There is no error when I run a tcl script with $val(rp) TORA. However I see in NAM and in tracegrapg that there is no packets being generated. Is it necessary to make any changes in any other cc files or header? Or unlike in AODV and DSR is there any other parameters to be :specified in tcl script ? Some posts had suggested using

    set tcp [new Agent/TCP/Newreno]

    but this too didn't work.

    Please suggest how to fix it.
    I would be glad if someone could post a small working script.
    I appreciate your help. Thanks

  6. #6
    Join Date
    Jul 2009
    Posts
    5

    Re: NS2 and TORA Routing Protocol

    Hi on everyone. I have the ns2 2.34 version and I am having the same problems with Tora protocol. I have made all the changes that you have proposed but I am still having problems.
    Is it better to use adhocRouting or rp when you set up the protocol? What is the difference between set val(rp) from set opt(rp)? Please tell me what to do.


    Regards,

    flogeros

  7. #7
    Join Date
    Jul 2009
    Posts
    5

    Re: NS2 and TORA Routing Protocol

    Hi Zachary. I am facing the same problem with the tora protocol. Could ou please write down step by step what changes should I made in order to work properly the tora protocol?

    Regards,

    Flogeros




    Quote Originally Posted by Zachary View Post
    You can go for this:

    set opt(imep) "ON" ;# Enable/Disable IMEP
    set opt(ragent) Agent/rtProto/TORA
    set opt(pos) NONE ;# Box or NONE
    if { $opt(pos) == "Box" } {
    puts "*** TORA using Box configuration..."
    }
    #
    Agent instproc init args {
    $self next $args
    }
    Agent/rtProto instproc init args {
    puts "DOWN HERE 2"
    $self next $args
    }
    Agent/rtProto/TORA instproc init args {
    puts "DOWN HERE"
    $self next $args
    }
    Agent/rtProto/TORA set sport_ 0
    Agent/rtProto/TORA set dport_ 0
    #
    proc create-routing-agent { node id } {
    global ns_ ragent_ tracefd opt
    #
    # Create the Routing Agent and attach it to port 255.
    #
    set ragent_($id) [new $opt(ragent) $id]
    set ragent $ragent_($id)
    $node attach $ragent [Node set rtagent_port_]
    $ragent if-queue [$node set ifq_(0)] ;# ifq between LL and MAC
    # now that the Beacon/Hello messages have been
    # moved to the IMEP layer, this is not necessary.
    $ns_ at 0.$id "$ragent_($id) start" ;# start BEACON/HELLO Messages
    #
    # XXX: The routing protocol and the IMEP agents needs handles
    # to each other.
    #
    $ragent imep-agent [$node set imep_(0)]
    [$node set imep_(0)] rtagent $ragent
    #
    # Drop Target (always on regardless of other tracing)
    #
    set drpT [cmu-trace Drop "RTR" $node]
    $ragent drop-target $drpT
    #
    # Log Target
    #
    set T [new Trace/Generic]
    $T target [$ns_ set nullAgent_]
    $T attach $tracefd
    $T set src_ $id
    $ragent log-target $T
    #
    # XXX: let the IMEP agent use the same log target.
    #
    [$node set imep_(0)] log-target $T
    proc create-mobile-node { id } {
    global ns_ chan prop topo tracefd opt node_
    global chan prop tracefd topo opt
    set node_($id) [new Node/MobileNode]
    set node $node_($id)
    $node random-motion 0 ;# disable random motion
    $node topography $topo
    #
    # This Trace Target is used to log changes in direction
    # and velocity for the mobile node.
    #
    set T [new Trace/Generic]
    $T target [$ns_ set nullAgent_]
    $T attach $tracefd
    $T set src_ $id
    $node log-target $T

    $node add-interface $chan $prop $opt(ll) $opt(mac) \
    $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant)
    #
    # Create a Routing Agent for the Node
    #
    create-routing-agent $node $id
    if { $opt(pos) == "Box" } {
    #
    # Box Configuration
    #
    set spacing 200
    set maxrow 7
    set col [expr ($id - 1) % $maxrow]
    set row [expr ($id - 1) / $maxrow]
    $node set X_ [expr $col * $spacing]
    $node set Y_ [expr $row * $spacing]
    $node set Z_ 0.0
    $node set speed_ 0.0

    $ns_ at 0.0 "$node_($id) start"
    }
    }

  8. #8
    Join Date
    Jul 2009
    Posts
    5

    Re: NS2 and TORA Routing Protocol

    Hi Bathena. I am facing the same problem with the tora protocol. Could ou please write down step by step what changes should I made in order to work properly the tora protocol?

    Regards,

    Flogeros





    Quote Originally Posted by banthena View Post
    Hi I wanted to TORA ins ns-2.32 and made necessary modifications in tora.cc and tora.h . There is no error when I run a tcl script with $val(rp) TORA. However I see in NAM and in tracegrapg that there is no packets being generated. Is it necessary to make any changes in any other cc files or header? Or unlike in AODV and DSR is there any other parameters to be :specified in tcl script ? Some posts had suggested using

    set tcp [new Agent/TCP/Newreno]

    but this too didn't work.

    Please suggest how to fix it.
    I would be glad if someone could post a small working script.
    I appreciate your help. Thanks

  9. #9
    Join Date
    Jul 2009
    Posts
    5

    Re: NS2 and TORA Routing Protocol

    Dear Zachary first of all I would like to thank for your help. The script that you write me is ready for use? Because I have saved in a tcl format and I run, but I've got again errors. Please tell me what to do next because I am lost.


    Kind regards,

    flogeros

  10. #10
    Join Date
    Jan 2006
    Posts
    4,221

    Re: NS2 and TORA Routing Protocol

    Well, i guess you should give it a try, if it gives you an error, post back regarding what you getting error...

  11. #11
    Join Date
    Jul 2009
    Posts
    5

    Re: NS2 and TORA Routing Protocol

    Dear Zachary I am sending you the error that I am getting back.
    invalid command name "Agent/rtProto/TORA"
    while executing
    "Agent/rtProto/TORA instproc init args {
    puts "DOWN HERE"
    $self next $args
    }"
    (file "tora_s.tcl" line 15)
    Can I send an email regarding the adhoc protocols? My email is korgani@hotmail.com

    Regards,

    flogeros

  12. #12
    Join Date
    Nov 2009
    Posts
    1

    Re: NS2 and TORA Routing Protocol

    Hello.
    I am trying to simulate TORA routing protocol. Can you help me please?
    I tried to change files tora.cc and tora.h.
    I added to tora.cc lines:

    else if (strcmp(argv[1], "port-dmux") == 0) {
    dmux_ = (PortClassifier*)TclObject::lookup(argv[2]);
    if (dmux_ == 0) {
    fprintf(stderr, "%s: %s lookup of %s failed\n",
    __FILE__,
    argv[1],
    argv[2]);
    printf("%s lookup of %s failed\n",
    argv[1],
    argv[2]);
    return TCL_ERROR;
    }
    return TCL_OK;
    }


    and to tora.h i added this

    #include <classifier/classifier-port.h>
    protected:
    PortClassifier *dmux_;



    Unfortunately it doesn t help me. I tried to run following tora.tcl file


    ======================================================================
    # Define options
    # ======================================================================
    set val(chan) Channel/WirelessChannel ;# channel type
    set val(prop) Propagation/TwoRayGround ;# radio-propagation model
    set val(ant) Antenna/OmniAntenna ;# Antenna type
    set val(ll) LL ;# Link layer type
    set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type
    set val(ifqlen) 50 ;# max packet in ifq
    set val(netif) Phy/WirelessPhy ;# network interface type
    set val(mac) Mac/802_11 ;# MAC type
    set val(nn) 6 ;# number of mobilenodes
    set val(rp) TORA ;# routing protocol
    set val(x) 800
    set val(y) 800

    set ns [new Simulator]
    #ns-random 0

    set f [open 1_out.tr w]
    $ns trace-all $f
    set namtrace [open 1_out.nam w]
    $ns namtrace-all-wireless $namtrace $val(x) $val(y)
    set f0 [open packets_received.tr w]
    set f1 [open packets_lost.tr w]
    #set f0 [open proj_out0.tr w]
    #set f1 [open proj_out1.tr w]
    set f2 [open proj_out2.tr w]
    set f3 [open proj_out3.tr w]

    set topo [new Topography]
    $topo load_flatgrid 800 800

    create-god $val(nn)

    set chan_1 [new $val(chan)]
    set chan_2 [new $val(chan)]
    set chan_3 [new $val(chan)]
    set chan_4 [new $val(chan)]
    set chan_5 [new $val(chan)]
    set chan_6 [new $val(chan)]

    # CONFIGURE AND CREATE NODES

    $ns node-config -adhocRouting $val(rp) \
    -llType $val(ll) \
    -macType $val(mac) \
    -ifqType $val(ifq) \
    -ifqLen $val(ifqlen) \
    -antType $val(ant) \
    -propType $val(prop) \
    -phyType $val(netif) \
    #-channelType $val(chan) \
    -topoInstance $topo \
    -agentTrace OFF \
    -routerTrace ON \
    -macTrace ON \
    -movementTrace OFF \
    -channel $chan_1 # \
    #-channel $chan_2 \
    #-channel $chan_3 \
    #-channel $chan_4 \
    #-channel $chan_5 \
    #-channel $chan_6


    proc finish {} {
    global ns f f0 f1 f2 f3 namtrace
    $ns flush-trace
    close $namtrace
    close $f0
    close $f1
    close $f2
    close $f3
    exec xgraph packets_received.tr packets_lost.tr
    #exec xgraph proj_out0.tr proj_out1.tr
    # proj_out2.tr proj_out3.tr
    exec nam -r 5m 1_out.nam &
    exit 0
    }

    proc record {} {
    global sink0 sink1 sink2 sink3 sink4 sink5 f0 f1 f2 f3
    #Get An Instance Of The Simulator
    set ns [Simulator instance]

    #Set The Time After Which The Procedure Should Be Called Again
    set time 0.05
    #How Many Bytes Have Been Received By The Traffic Sinks?
    set bw0 [$sink5 set npkts_]
    set bw1 [$sink5 set nlost_]
    #set bw2 [$sink2 set npkts_]
    #set bw3 [$sink3 set npkts_]

    #Get The Current Time
    set now [$ns now]

    #Save Data To The Files
    puts $f0 "$now [expr $bw0]"
    puts $f1 "$now [expr $bw1]"
    #puts $f2 "$now [expr $bw2]"
    #puts $f3 "$now [expr $bw3]"

    #Re-Schedule The Procedure
    $ns at [expr $now+$time] "record"
    }

    # define color index
    $ns color 0 blue
    $ns color 1 red
    $ns color 2 chocolate
    $ns color 3 red
    $ns color 4 brown
    $ns color 5 tan
    $ns color 6 gold
    $ns color 7 black

    set n(0) [$ns node]
    #$ns at 0.0 "$n(0) color red"
    $n(0) color "0"
    $n(0) shape "circle"
    set n(1) [$ns node]
    $n(1) color "blue"
    $n(1) shape "circle"
    set n(2) [$ns node]
    $n(2) color "tan"
    $n(2) shape "circle"
    set n(3) [$ns node]
    $n(3) color "red"
    $n(3) shape "circle"
    set n(4) [$ns node]
    $n(4) color "tan"
    $n(4) shape "circle"
    set n(5) [$ns node]
    $n(5) color "red"
    $n(5) shape "circle"


    for {set i 0} {$i < $val(nn)} {incr i} {
    $ns initial_node_pos $n($i) 30+i*100
    }

    $n(0) set X_ 0.0
    $n(0) set Y_ 0.0
    $n(0) set Z_ 0.0

    $n(1) set X_ 0.0
    $n(1) set Y_ 0.0
    $n(1) set Z_ 0.0

    $n(2) set X_ 0.0
    $n(2) set Y_ 0.0
    $n(2) set Z_ 0.0

    $n(3) set X_ 0.0
    $n(3) set Y_ 0.0
    $n(3) set Z_ 0.0

    $n(4) set X_ 0.0
    $n(4) set Y_ 0.0
    $n(4) set Z_ 0.0

    $n(5) set X_ 0.0
    $n(5) set Y_ 0.0
    $n(5) set Z_ 0.0

    $ns at 0.0 "$n(0) setdest 100.0 100.0 3000.0"
    $ns at 0.0 "$n(1) setdest 200.0 200.0 3000.0"
    $ns at 0.0 "$n(2) setdest 300.0 200.0 3000.0"
    $ns at 0.0 "$n(3) setdest 400.0 300.0 3000.0"
    $ns at 0.0 "$n(4) setdest 500.0 300.0 3000.0"
    $ns at 0.0 "$n(5) setdest 600.0 400.0 3000.0"

    $ns at 2.0 "$n(5) setdest 100.0 400.0 500.0"
    #$ns at 1.5 "$n(3) setdest 450.0 150.0 500.0"


    # CONFIGURE AND SET UP A FLOW


    set sink0 [new Agent/LossMonitor]
    set sink1 [new Agent/LossMonitor]
    set sink2 [new Agent/LossMonitor]
    set sink3 [new Agent/LossMonitor]
    set sink4 [new Agent/LossMonitor]
    set sink5 [new Agent/LossMonitor]
    $ns attach-agent $n(0) $sink0
    $ns attach-agent $n(1) $sink1
    $ns attach-agent $n(2) $sink2
    $ns attach-agent $n(3) $sink3
    $ns attach-agent $n(4) $sink4
    $ns attach-agent $n(5) $sink5

    #$ns attach-agent $sink2 $sink3
    set tcp0 [new Agent/TCP]
    $ns attach-agent $n(0) $tcp0
    set tcp1 [new Agent/TCP]
    $ns attach-agent $n(1) $tcp1
    set tcp2 [new Agent/TCP]
    $ns attach-agent $n(2) $tcp2
    set tcp3 [new Agent/TCP]
    $ns attach-agent $n(3) $tcp3
    set tcp4 [new Agent/TCP]
    $ns attach-agent $n(4) $tcp4
    set tcp5 [new Agent/TCP]
    $ns attach-agent $n(5) $tcp5


    proc attach-CBR-traffic { node sink size interval } {
    #Get an instance of the simulator
    set ns [Simulator instance]
    #Create a CBR agent and attach it to the node
    set cbr [new Agent/CBR]
    $ns attach-agent $node $cbr
    $cbr set packetSize_ $size
    $cbr set interval_ $interval

    #Attach CBR source to sink;
    $ns connect $cbr $sink
    return $cbr
    }

    set cbr0 [attach-CBR-traffic $n(0) $sink5 1000 .015]
    #set cbr1 [attach-CBR-traffic $n(1) $sink2 1000 .015]
    #set cbr2 [attach-CBR-traffic $n(2) $sink3 1000 .015]
    #set cbr3 [attach-CBR-traffic $n(3) $sink0 1000 .015]
    #set cbr4 [attach-CBR-traffic $n(4) $sink3 1000 .015]
    #set cbr5 [attach-CBR-traffic $n(5) $sink0 1000 .015]



    $ns at 0.0 "record"
    #$ns at 0.5 "$cbr0 start"
    #$ns at 0.5 "$cbr2 start"
    #$ns at 2.0 "$cbr0 stop"
    #$ns at 2.0 "$cbr2 stop"
    $ns at 1.0 "$cbr0 start"
    #$ns at 4.0 "$cbr3 stop"

    $ns at 10.0 "finish"

    puts "Start of simulation.."
    $ns run



    But after command ns tora.tcl I get this:

    num_nodes is set 6
    INITIALIZE THE LIST xListHead

    (_o22 cmd line 1)
    invoked from within
    "_o22 cmd port-dmux _o37"
    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 "_o22" line 2)
    (SplitObject unknown line 2)
    invoked from within
    "$agent port-dmux $dmux_"
    (procedure "_o19" line 11)
    (Node/MobileNode add-target-rtagent line 11)
    invoked from within
    "$self add-target-rtagent $agent $port"
    (procedure "_o19" line 28)
    (Node/MobileNode add-target line 28)
    invoked from within
    "$self add-target $agent $port"
    (procedure "_o19" line 15)
    (Node attach line 15)
    invoked from within
    "$node attach $ragent [Node set rtagent_port_]"
    (procedure "_o3" line 79)
    (Simulator create-wireless-node line 79)
    invoked from within
    "_o3 create-wireless-node"
    ("eval" body line 1)
    invoked from within
    "eval $self create-wireless-node $args"
    (procedure "_o3" line 23)
    (Simulator node line 23)
    invoked from within
    "$ns node"
    invoked from within
    "set n(0) [$ns node]"
    (file "tora.tcl" line 118)



    When I run a file, which was posted by Zachary I get same errors as user flogeros wrote.
    I am using ns 2.34. Can anyone help me please? Thanks

  13. #13
    Join Date
    Jun 2010
    Posts
    2

    Re: NS2 and TORA Routing Protocol

    Hey all,
    I have made necessary changes in the tora.cc and tora.h flles, but when i m trying to recompile ns-2.34 using make, i m getting following errors....

    tora/tora.cc:10: error: expected constructor, destructor, or type conversion before ‘(’ token
    tora/tora.cc: In member function ‘virtual int toraAgent::command(int, const char* const*)’:
    tora/tora.cc:92: error: cannot convert ‘_IO_FILE*’ to ‘const char*’ for argument ‘1’ to ‘int printf(const char*, ...)’
    tora/tora.cc: At global scope:
    tora/tora.cc:193: error: expected unqualified-id before ‘else’
    tora/tora.cc:198: error: expected unqualified-id before ‘else’
    make: *** [tora/tora.o] Error 1




    Anybody plz post how to fix them, any type of help would be appreciated...

    thanks in advance..

  14. #14
    Join Date
    Jun 2010
    Posts
    2

    Re: NS2 and TORA Routing Protocol

    Hey all,

    I executed my simulation using TORA on ns-2.34 by doing modifications in .cc and .h files as described above....
    bt their is one problem that has occuered is that the .tr file is not created completely, it is getting hanged somewhere at time 4.0666, while my simulation is for time units 125.

    if anybody has any soluton for that plzz help me....


    regards,
    saurabh agrawal

  15. #15
    Join Date
    Dec 2007
    Posts
    2,291

    Re: NS2 and TORA Routing Protocol

    I think that, set_sql_trace_in_session will write a trace file to to UDUMP destination. You will then need to run tkprof to put it in a readable form.
    ie,
    tkprof ...\udump\oraxxx.trc newfilename.txt explain=username/password@sid . If you are tracing a query that runs in the context of a Job( I presume you mean DBMS_JOB), then the sql trace is generated by the executing job_queue_process and not the shadow process of the Sqlplus session.
    In this case it will be created in background_dump_dest and NOT in user_dump_dest. The process name will start with "j....". Read more here.

Page 1 of 2 12 LastLast

Similar Threads

  1. Error while Simulating TORA
    By amithkhandakar in forum Networking & Security
    Replies: 1
    Last Post: 03-05-2012, 02:07 AM
  2. Cisco IOS for router for BGP routing protocol
    By Rak$sha in forum Networking & Security
    Replies: 6
    Last Post: 22-07-2011, 07:29 PM
  3. VLSM and Routing Using RIPv2 Protocol
    By Xiomar in forum Networking & Security
    Replies: 2
    Last Post: 11-01-2011, 07:03 PM
  4. What is Link state routing protocol
    By B-JOB Guru in forum Networking & Security
    Replies: 3
    Last Post: 10-01-2011, 07:39 AM
  5. Replies: 4
    Last Post: 29-12-2009, 04:39 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,259,386.75208 seconds with 16 queries