NAM Coding

Turn on nam tracing in your Tcl script
        - As easy as turning on normal tracing
$ns namtrace $file

Specify link orientation (or node position for
wireless)
$ns duplex-link-op $node1 $node2 orient left

Execute nam
exec nam $filename


Node options — color, shape, label
$node color red
$node shape hexagon
$node label “my text”
$node label-color blue
$node label-at up

Link options
$ns duplex-link-op $n1 $n2 color green
$ns duplex-link-op queuePos right
$ns duplex-link-op $n1 $n2 label “my text”
$ns duplex-link-op $n1 $n2 label-color blue
$ns duplex-link-op $n1 $n2 label-at down

Packet colors
$ns color $n blue
$agent set fid_ $n

Annotation
$ns at $time “$ns trace-annotate $text”

Control playback
$ns set-animation-rate 3ms

18 comments:

  1. Hi sir,
    I have installed successfully ns2.34 in fedora 14 without any errors.
    I set-up all the PATHS.
    after $ ns, i am getting the % sign
    but when I enter the "ns simple.tcl" command ,the shell shows this error below:


    ns: finish: couldn't execute "nam": permission denied
    while executing
    "exec nam lab2.nam &"
    (procedure "finish" line 6)
    invoked from within
    "finish"


    Please help me sir to correct this error...

    ReplyDelete
    Replies
    1. Hi,

      You need to check permissions given to ns-allinone-2.34. As the error shows permission error.

      Delete
    2. Network Simulator - 2: Nam Coding >>>>> Download Now

      >>>>> Download Full

      Network Simulator - 2: Nam Coding >>>>> Download LINK

      >>>>> Download Now

      Network Simulator - 2: Nam Coding >>>>> Download Full

      >>>>> Download LINK FP

      Delete
  2. I checked the permission sir.It is having permission as below..

    drwxr-xr-x. 18 vidya vidya 4096 Jan 10 03:47 ns-allinone-2.34

    Please tell me what changes I have to make in permission

    ReplyDelete
  3. hello sir
    iwan to modified dsr.cc by using this code

    void MDSRAgent::getRouteForPacket(SRPacket &p, bool retry)
    {
    Entry *e = request_table.getEntry(p.dest);
    Time time = Scheduler::instance().clock();
    if snooze==1&&recv.ACK==1
    SRPacket rrp = p;
    rrp.pkt = p.pkt->copy();
    hdr_sr *srh = hdr_sr::access(rrp.pkt);
    hdr_ip *iph = hdr_ip::access(rrp.pkt);
    hdr_cmn *cmh = hdr_cmn::access(rrp.pkt);
    iph>daddr()=Address::instance().create_ipaddr(p.dest.getNSAddr_t(),RT_PORT);
    iph->dport() = RT_PORT;
    iph>saddr()=Address::instance().create_ipaddr(net_id.getNSAddr_t(),RT_PORT);
    iph->sport() = RT_PORT;
    cmnh->ptype() = PT_DSR;
    cmnh->size() = size_;
    cmnh->num_forwards() = 0;
    }#endif

    void TcpBuS::RouteError(SRPacket& p)
    {
    hdr_sr *srh = hdr_sr::access(p.pkt);
    if (!srh->route_error())
    return;
    ID who = ID(srh->down_links()[srh->num_route_errors()-1].tell_addr, ::IP);
    if (who != net_id && who != MAC_id)
    {
    return;
    if (ch->num_forwards() > rt->rt_hops) {
    local_rt_repair(rt, p);
    {
    return = RERR_L;
    if(rt->rt_flags == RTF_UP) {
    assert(rt->rt_hops != INFINITY2);
    forward(rt, p, NO_DELAY);
    {
    return = RERR_S;
    }

    void MDSR::newack(Packet* pkt)
    {
    hdr_tcp *tcph = hdr_tcp::access(pkt);
    register int ackno = tcph->ackno();
    int progress = (ackno > highest_ack_);
    if (ackno == maxseq_) {
    cancel_rtx_timer(); // all data ACKd
    } else if (progress) {
    set_rtx_timer();
    }
    if (progress)
    highest_ack_ = ackno;
    if (t_seqno_ < highest_ack_)
    t_seqno_ = highest_ack_; // seq# to send next
    hdr_flags *fh = hdr_flags::access(pkt);
    iph>daddr()=Address::instance().create_ipaddr(p.dest.getNSAddr_t(),RT_PORT);
    iph->dport() = RT_PORT;
    iph>saddr()=Address::instance().create_ipaddr(net_id.getNSAddr_t(),RT_PORT);
    iph->sport() = RT_PORT;
    }

    when i add this code in this then we get error

    dsr/dsragent.cc:357:17: error: expected type-specifier before ‘TcpBus’
    dsr/dsragent.cc:357:17: error: expected ‘)’ before ‘TcpBus’
    dsr/dsragent.cc:357:23: error: cannot convert ‘int*’ to ‘TclObject*’ in return
    dsr/dsragent.cc: In member function ‘void DSRAgent::getRouteForPacket(SRPacket&, bool)’:
    dsr/dsragent.cc:1489:5: error: ‘snooze’ was not declared in this scope
    dsr/dsragent.cc:1489:18: error: ‘recvack’ was not declared in this scope
    dsr/dsragent.cc:1530:3: error: ‘endif’ was not declared in this scope
    dsr/dsragent.cc:1532:3: error: expected ‘;’ before ‘srh’
    dsr/dsragent.cc:1519:11: warning: unused variable ‘srh’ [-Wunused-variable]
    dsr/dsragent.cc:1596:6: error: ‘TcpBuS’ has not been declared
    dsr/dsragent.cc:1597:1: error: a function-definition is not allowed here before ‘{’ token
    dsr/dsragent.cc:2852:1: error: expected ‘}’ at end of input
    dsr/dsragent.cc: In member function ‘virtual TclObject* TcpBusClass::create(int, const char* const*)’:
    dsr/dsragent.cc:358:3: warning: control reaches end of non-void function [-Wreturn-type]
    dsr/dsragent.cc: At global scope:
    dsr/dsragent.cc:95:12: warning: ‘dsr_salvage_max_attempts’ defined but not used [-Wunused-variable]
    make: *** [dsr/dsragent.o] Error 1

    ReplyDelete
    Replies
    1. HI,

      Check the variable TcpBus. I think you need to check the header files.

      Delete
    2. sir i want to reduse end to end delay in dsr routing protocl which modification required in dsragent.cc file also cache mechanisum

      Delete
  4. Sir I wanted to partition NAM into hexagonal grids and I will have place a single node per grid in order to make uni-cast Route Request my using AODV protocol.
    Please help me in my project..
    Thinking you..

    ReplyDelete
    Replies
    1. Hi,

      You can use NSG2.1 tool for developing TCL script.

      Delete
  5. hello sir
    i want to reduce end to end delay in dsr rouing protocol. which modification required in dsr agent and cache mechanisum.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hi Sir ,
    Am a PG student.
    I need to run ns2 simulation in which out.nam should show nodes with ipadresses instead of node numbers this is needed in my academic project can you help.

    ReplyDelete
  8. please mail bskolkur@gmail.com

    ReplyDelete
  9. i am doing ns2project in geographic routing. i need ur help.. my mail id-
    jasper.ramu@gmail.com

    ReplyDelete
  10. please mail if u have coding in Geographic routing..
    and basic ns2 program
    Thanks in advance

    jasper.ramu@gmail.com

    ReplyDelete