[ns] plz help me to solve this error is urgent

2015-04-25 Thread alok kumar

sir,
   when i run make  command  then it give the  following  error given   below:


common/packet.h:387:3: error: stray ‘\’ in program
   return ( (type) == PT_MKC ||  \ //hi
   ^
common/packet.h:388:5: error: stray ‘\’ in program
 (type) == PT_MKC_ACK ||  \   //hi ack
 ^
common/packet.h: In static member function ‘static bool
p_info::data_packet(packet_t)’:
common/packet.h:398:24: error: expected primary-expression before ‘)’ token
);
^
common/packet.h: In static member function ‘static void p_info::initName()’:
common/packet.h:439:21: warning: deleting array ‘p_info::name_’
[enabled by default]
   delete [] name_;
 ^
common/packet.h:440:9: error: incompatible types in assignment of
‘char**’ to ‘char* [76]’
   name_ = nameNew;
 ^
common/packet.h: In static member function ‘static packet_t
p_info::getType(const char*)’:
common/packet.h:565:12: error: invalid conversion from ‘unsigned int’
to ‘packet_t’ [-fpermissive]
 return i;
^
make: *** [common/scheduler.o] Error 1





this error in packet.h file.Below  is packet.h   code is:
plz sir don't change  code  just only  error




packet.h





#ifndef ns_packet_h
#define ns_packet_h

#include 
#include 

#include "config.h"
#include "scheduler.h"
#include "object.h"
#include "lib/bsd-list.h"
#include "packet-stamp.h"
#include "ns-process.h"

// Used by wireless routing code to attach routing agent
#define RT_PORT 255 /* port that all route msgs are sent to */

#define HDR_CMN(p)  (hdr_cmn::access(p))
#define HDR_ARP(p)  (hdr_arp::access(p))
#define HDR_MAC(p)  (hdr_mac::access(p))
#define HDR_MAC802_11(p) ((hdr_mac802_11 *)hdr_mac::access(p))
#define HDR_MAC_TDMA(p) ((hdr_mac_tdma *)hdr_mac::access(p))
#define HDR_SMAC(p) ((hdr_smac *)hdr_mac::access(p))
#define HDR_LL(p)   (hdr_ll::access(p))
#define HDR_HDLC(p) ((hdr_hdlc *)hdr_ll::access(p))
#define HDR_IP(p)   (hdr_ip::access(p))
#define HDR_RTP(p)  (hdr_rtp::access(p))
#define HDR_TCP(p)  (hdr_tcp::access(p))
#define HDR_SCTP(p) (hdr_sctp::access(p))
#define HDR_SR(p)   (hdr_sr::access(p))
#define HDR_TFRC(p) (hdr_tfrc::access(p))
#define HDR_TORA(p) (hdr_tora::access(p))
#define HDR_IMEP(p) (hdr_imep::access(p))
#define HDR_CDIFF(p)(hdr_cdiff::access(p))  /* chalermak's diffusion*/
//#define HDR_DIFF(p) (hdr_diff::access(p))  /* SCADD's diffusion
ported into ns */
#define HDR_LMS(p)  (hdr_lms::access(p))

/* */

/*
 * modified ns-2.33, adding support for dynamic libraries
 *
 * packet_t is changed from enum to unsigned int in order to allow
 * dynamic definition of  new packet types within dynamic libraries.
 * Pre-defined packet types are implemented as static const.
 *
 */

enum packet_t {
PT_MKC,
PT_MKC_ACK,
PT_TCP,
PT_UDP,
PT_CBR,
PT_AUDIO,
PT_VIDEO,
PT_ACK,
PT_START,
PT_STOP,
PT_PRUNE,
PT_GRAFT,
PT_GRAFTACK,
PT_JOIN,
PT_ASSERT,
PT_MESSAGE,
PT_RTCP,
PT_RTP,
PT_RTPROTO_DV,
PT_CtrMcast_Encap,
PT_CtrMcast_Decap,
PT_SRM,
/* simple signalling messages */
PT_REQUEST, 
PT_ACCEPT,  
PT_CONFIRM, 
PT_TEARDOWN,
PT_LIVE,// packet from live network
PT_REJECT,

PT_TELNET,  // not needed: telnet use TCP
PT_FTP,
PT_PARETO,
PT_EXP,
PT_INVAL,
PT_HTTP,

/* new encapsulator */
PT_ENCAPSULATED,
PT_MFTP,

/* CMU/Monarch's extnsions */
PT_ARP,
PT_MAC,
PT_TORA,
PT_DSR,
PT_AODV,
PT_IMEP,

// RAP packets
PT_RAP_DATA,
PT_RAP_ACK,

PT_TFRC,
PT_TFRC_ACK,
PT_PING,

// Diffusion packets - Chalermek
PT_DIFF,

// LinkState routing update packets
PT_RTPROTO_LS,

// MPLS LDP header
PT_LDP,

// GAF packet
PT_GAF,

// ReadAudio traffic
PT_REALAUDIO,

// Pushback Messages
PT_PUSHBACK,

#ifdef HAVE_STL
// Pragmatic General Multicast
PT_PGM,
#endif //STL

// LMS packets
PT_LMS,
PT_LMS_SETUP,

PT_SCTP,
PT_SCTP_APP1,

// SMAC packet
PT_SMAC,

// DCCP packets
 PT_DCCP,
 PT_DCCP_REQ,
 PT_DCCP_RESP,
 PT_DCCP_ACK,
 PT_DCCP_DATA,
 PT_DCCP_DATAACK,
 PT_DCCP_CLOSE,
 PT_DCCP_CLOSEREQ,
 PT_DCCP_RESET,

// HDLC packet
 PT_HDLC,

// XCP packet
PT_XCP,

// PBC p

[ns] plz help me to solve this error is urgent

2015-04-25 Thread alok kumar

sir,
   when i run make  command  then it give the  following  error given   below:


common/packet.h:387:3: error: stray ‘\’ in program
   return ( (type) == PT_MKC ||  \ //hi
   ^
common/packet.h:388:5: error: stray ‘\’ in program
 (type) == PT_MKC_ACK ||  \   //hi ack
 ^
common/packet.h: In static member function ‘static bool
p_info::data_packet(packet_t)’:
common/packet.h:398:24: error: expected primary-expression before ‘)’ token
);
^
common/packet.h: In static member function ‘static void p_info::initName()’:
common/packet.h:439:21: warning: deleting array ‘p_info::name_’
[enabled by default]
   delete [] name_;
 ^
common/packet.h:440:9: error: incompatible types in assignment of
‘char**’ to ‘char* [76]’
   name_ = nameNew;
 ^
common/packet.h: In static member function ‘static packet_t
p_info::getType(const char*)’:
common/packet.h:565:12: error: invalid conversion from ‘unsigned int’
to ‘packet_t’ [-fpermissive]
 return i;
^
make: *** [common/scheduler.o] Error 1





this error in packet.h file.Below  is packet.h   code is:
plz sir don't change  code  just only  error




packet.h





#ifndef ns_packet_h
#define ns_packet_h

#include 
#include 

#include "config.h"
#include "scheduler.h"
#include "object.h"
#include "lib/bsd-list.h"
#include "packet-stamp.h"
#include "ns-process.h"

// Used by wireless routing code to attach routing agent
#define RT_PORT 255 /* port that all route msgs are sent to */

#define HDR_CMN(p)  (hdr_cmn::access(p))
#define HDR_ARP(p)  (hdr_arp::access(p))
#define HDR_MAC(p)  (hdr_mac::access(p))
#define HDR_MAC802_11(p) ((hdr_mac802_11 *)hdr_mac::access(p))
#define HDR_MAC_TDMA(p) ((hdr_mac_tdma *)hdr_mac::access(p))
#define HDR_SMAC(p) ((hdr_smac *)hdr_mac::access(p))
#define HDR_LL(p)   (hdr_ll::access(p))
#define HDR_HDLC(p) ((hdr_hdlc *)hdr_ll::access(p))
#define HDR_IP(p)   (hdr_ip::access(p))
#define HDR_RTP(p)  (hdr_rtp::access(p))
#define HDR_TCP(p)  (hdr_tcp::access(p))
#define HDR_SCTP(p) (hdr_sctp::access(p))
#define HDR_SR(p)   (hdr_sr::access(p))
#define HDR_TFRC(p) (hdr_tfrc::access(p))
#define HDR_TORA(p) (hdr_tora::access(p))
#define HDR_IMEP(p) (hdr_imep::access(p))
#define HDR_CDIFF(p)(hdr_cdiff::access(p))  /* chalermak's diffusion*/
//#define HDR_DIFF(p) (hdr_diff::access(p))  /* SCADD's diffusion
ported into ns */
#define HDR_LMS(p)  (hdr_lms::access(p))

/* */

/*
 * modified ns-2.33, adding support for dynamic libraries
 *
 * packet_t is changed from enum to unsigned int in order to allow
 * dynamic definition of  new packet types within dynamic libraries.
 * Pre-defined packet types are implemented as static const.
 *
 */

enum packet_t {
PT_MKC,
PT_MKC_ACK,
PT_TCP,
PT_UDP,
PT_CBR,
PT_AUDIO,
PT_VIDEO,
PT_ACK,
PT_START,
PT_STOP,
PT_PRUNE,
PT_GRAFT,
PT_GRAFTACK,
PT_JOIN,
PT_ASSERT,
PT_MESSAGE,
PT_RTCP,
PT_RTP,
PT_RTPROTO_DV,
PT_CtrMcast_Encap,
PT_CtrMcast_Decap,
PT_SRM,
/* simple signalling messages */
PT_REQUEST, 
PT_ACCEPT,  
PT_CONFIRM, 
PT_TEARDOWN,
PT_LIVE,// packet from live network
PT_REJECT,

PT_TELNET,  // not needed: telnet use TCP
PT_FTP,
PT_PARETO,
PT_EXP,
PT_INVAL,
PT_HTTP,

/* new encapsulator */
PT_ENCAPSULATED,
PT_MFTP,

/* CMU/Monarch's extnsions */
PT_ARP,
PT_MAC,
PT_TORA,
PT_DSR,
PT_AODV,
PT_IMEP,

// RAP packets
PT_RAP_DATA,
PT_RAP_ACK,

PT_TFRC,
PT_TFRC_ACK,
PT_PING,

// Diffusion packets - Chalermek
PT_DIFF,

// LinkState routing update packets
PT_RTPROTO_LS,

// MPLS LDP header
PT_LDP,

// GAF packet
PT_GAF,

// ReadAudio traffic
PT_REALAUDIO,

// Pushback Messages
PT_PUSHBACK,

#ifdef HAVE_STL
// Pragmatic General Multicast
PT_PGM,
#endif //STL

// LMS packets
PT_LMS,
PT_LMS_SETUP,

PT_SCTP,
PT_SCTP_APP1,

// SMAC packet
PT_SMAC,

// DCCP packets
 PT_DCCP,
 PT_DCCP_REQ,
 PT_DCCP_RESP,
 PT_DCCP_ACK,
 PT_DCCP_DATA,
 PT_DCCP_DATAACK,
 PT_DCCP_CLOSE,
 PT_DCCP_CLOSEREQ,
 PT_DCCP_RESET,

// HDLC packet
 PT_HDLC,

// XCP packet
PT_XCP,

// PBC p

[ns] how to generate nam and xgraph

2015-04-30 Thread alok kumar

hello sir,
 how to generate  ns(nam)  and xgraph  for  below  .tcl  file


--mkc-T1-heterogeneous.tcl--

# create scheduler
set ns [new Simulator]

# turn tracing on
#set ns_f [open HeteroFlow.tr w]
#$ns trace-all $ns_f
#$ns namtrace-all [open out.nam w]

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 5

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + 
[expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 100
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 10

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {


exit 0
}

$ns run



[ns] how to generate nam file and xgraph

2015-05-01 Thread alok kumar

sir,
   I am not understand  how to generate nam file and xgraph for below
.tcl file.Plz send me solution  according to below  .tcl file.

---mkc-T1-heterogeneous.tcl--

# create scheduler
set ns [new Simulator]

# turn tracing on
set ns_f [open HeteroFlow.tr w]
$ns trace-all $ns_f
$ns namtrace-all [open out.nam w]

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 5

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + 
[expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 100
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 10

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {
global ns ns_f  mkcq
$ns flush-trace
close $mkcq
puts "running nam..."
exec nam out.nam &
exit 0
}

$ns run



[ns] error in validate

2015-05-10 Thread alok kumar

sir,
  I am getting error on validation time:

 "validate overall report: some tests failed:
 ./test-all-tcpLinux
"
how to erro

thank you



[ns] error in tcl file

2015-05-11 Thread alok kumar

sir,
  when i am  trying to generate  nam  file  it
  gives  error :   "Flow 1 starts at time 0.00
Segmentation fault (core dumped)"


plz give me solution how to solve this  problem


thank you



[ns] error in tcl file

2015-05-11 Thread alok kumar

 when i am  trying to generate  nam  file  it
  gives  error :   "Flow 1 starts at time 0.00
Segmentation fault (core dumped)"


plz give me solution how to solve this  problem


mkc.tcl---

# create scheduler
set ns [new Simulator]


set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf
# turn tracing on
#set ns_f [open HeteroFlow.tr w]
#$ns trace-all $ns_f

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 2

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + 
[expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 100
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 10

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns f nf
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {
global ns f nf

$ns flush-trace
close $f
close $nf

puts "running nam"
exec nam out.nam &

#exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &
exit 0
}

$ns run





thank you



[ns] nam problem in ns2

2015-05-14 Thread alok kumar

sir,
   i am getting  nam error :
"Segmentation fault (core dumped)"  in ns2  while i am
already  try  nam_1.15-10_i386.deb   package.But its give   again
this  above error.


thank you



[ns] nam problem in ns2 it is urgent

2015-05-15 Thread alok kumar

sir,
I am getting error  when I am entered in  root  then type nam it
gives  error:
   "root@HP:/home/alok# nam
Segmentation fault (core dumped)"

plz solve this problem


thank you



[ns] tcl script problem in ns2 it is urgent

2015-05-15 Thread alok kumar

 when I am  running  below tcl file  it gives  again  error :"Flow
1 starts at time 0.00

Segmentation fault (core dumped)"


--mkc.tcl---
# create scheduler
set ns [new Simulator]


set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf
# turn tracing on
#set ns_f [open HeteroFlow.tr w]
#$ns trace-all $ns_f

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 2

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 100Mb [expr
100 + [expr
$i - 1] * 300]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 1
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 1

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {
global ns f nf

$ns flush-trace
close $f
close $nf

puts "running nam"
exec nam out.nam &

#exec xgraph out0.tr out1.tr out2.tr -geometry 800x400 &
exit 0
}

$ns run


thank you



[ns] problem in generating nam file

2015-05-16 Thread alok kumar

sir,
  I am  running  below tcl script  but it give error:"Flow 1 starts at
time 0.00

Segmentation fault (core dumped)"


mkc.tcl---

# create scheduler
set ns [new Simulator]

# turn tracing on
set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 2

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + 
[expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 100
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 10

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {

global ns f nf
$ns flush-trace
close $f
close $nf
puts "running nam"
exec nam out.nam &

exit 0
}

$ns run




plz  solve  this problem its urgent


thank  you



[ns] error in tcl script

2015-05-16 Thread alok kumar

sir,
   When  i am running  below  tcl script  it gives  error:"Flow 1
starts at time 0.00

  Segmentation fault (core dumped)"
   but  in other tcl script  is work better  than  below tcl
script...
   I am not  understand  what error  in below tcl script when nam is
work properly.


---mkc-T2.tcl

# create scheduler
set ns [new Simulator]

set f [open out3.tr w]
$ns trace-all $f
set nf [open out3.nam w]
$ns namtrace-all $nf
# create topology

# set number of flows
set N 4

# set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

# set the physical source and sink

for {set i 1} {$i <= $N} {incr i} {
set R_($i) [$ns node]
}

$ns duplex-link $R_(1) $R_(2) 20Mb 10ms MKCQueue
set mkcq_(1) [[$ns link $R_(1) $R_(2)] queue]
$mkcq_(1) set C 2000
$mkcq_(1) set T 0.1
$mkcq_(1) set rid 1

$ns duplex-link $R_(2) $R_(4) 10Mb 1000ms MKCQueue
set mkcq_(2) [[$ns link $R_(2) $R_(4)] queue]
$mkcq_(2) set C 1700
$mkcq_(2) set T 0.1
$mkcq_(2) set rid 2

$ns duplex-link $R_(4) $R_(3) 20Mb 10ms MKCQueue
set mkcq_(4) [[$ns link $R_(4) $R_(3)] queue]
$mkcq_(4) set C 2000
$mkcq_(4) set T 0.1
$mkcq_(4) set rid 3

$ns duplex-link $R_(3) $R_(1) 10Mb 1000ms MKCQueue
set mkcq_(3) [[$ns link $R_(3) $R_(1)] queue]
$mkcq_(3) set C 1700
$mkcq_(3) set T 0.1
$mkcq_(3) set rid 4


#create and attach BWCSink agents
set Snk_(2) [new Agent/MKCSink]
$Snk_(2) set packetSize_ 40
$ns attach-agent $R_(2) $Snk_(2)

set Snk_(1) [new Agent/MKCSink]
$Snk_(1) set packetSize_ 40
$ns attach-agent $R_(4) $Snk_(1)

set Snk_(4) [new Agent/MKCSink]
$Snk_(4) set packetSize_ 40
$ns attach-agent $R_(3) $Snk_(4)

set Snk_(3) [new Agent/MKCSink]
$Snk_(3) set packetSize_ 40
$ns attach-agent $R_(1) $Snk_(3)


set Src_(2) [new Agent/MKC]
$ns attach-agent $R_(1) $Src_(2)
$Src_(2) set alpha_ 20
$Src_(2) set beta_ 0.5
$Src_(2) set packetSize_ 200
$Src_(2) set init_rate_ 10
$Src_(2) set fid_ 2

set Src_(1) [new Agent/MKC]
$ns attach-agent $R_(1) $Src_(1)
$Src_(1) set alpha_ 20
$Src_(1) set beta_ 0.5
$Src_(1) set packetSize_ 200
$Src_(1) set init_rate_ 10
$Src_(1) set fid_ 1


set Src_(4) [new Agent/MKC]
$ns attach-agent $R_(4) $Src_(4)
$Src_(4) set alpha_ 20
$Src_(4) set beta_ 0.5
$Src_(4) set packetSize_ 200
$Src_(4) set init_rate_ 10
$Src_(4) set fid_ 4


set Src_(3) [new Agent/MKC]
$ns attach-agent $R_(4) $Src_(3)
$Src_(3) set alpha_ 20
$Src_(3) set beta_ 0.5
$Src_(3) set packetSize_ 200
$Src_(3) set init_rate_ 10
$Src_(3) set fid_ 3


# connect each pair of sender and receiver
for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

$ns cost $R_(4) $R_(3) 1
$ns cost $R_(4) $R_(2) 10

$ns compute-routes
set routelogic [$ns get-routelogic]

# schedule the events

set starttime_(1) 0
set starttime_(2) 30
set starttime_(3) 60
set starttime_(4) 90
$ns at 0 "$Src_(1) start"
$ns at 30 "$Src_(2) start"
$ns at 60 "$Src_(3) start"
$ns at 90 "$Src_(4) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at $starttime_($i) "record $Src_($i) $out_($i)"
}

set tfinish 500

for {set i 1} {$i<=$N} {incr i} {
$ns at $tfinish "$Src_($i) stop"
}

$ns at $tfinish "finish"

proc record {bwcsrc file} {
global ns f nf
set step 0.1
set now [$ns now]
set rate_ [$bwcsrc set rate_]
set pkt_loss_ [$bwcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $bwcsrc $file"
}

proc finish {} {
global ns f nf
$ns flush-trace
close $f
close $nf

puts "running nam"
exec nam out3.nam &
exit 0
}
$ns run



plz  anybody   check  above tcl script  and  find  out  where is  the
error.and  how to solve this error.

thank you



[ns] problem in tcl script

2015-05-20 Thread alok kumar

sir,
  I am running  below tcl  script   it gives   the error:

  Flow 1 starts at time 0.00
--- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
_o12: no target for slot 4294967295
_o12 type: Classifier/Hash/Dest
content dump:
classifier _o12
0 offset
0 shift
1073741823 mask
1 slots
slot 0: _o109 (Classifier/Port)
-1 default
-- Finished standard no-slot{} default handler --



here tcl script  :--

-mkct2.tcl

set ns [new Simulator]

set f [open out.tr w]
$ns trace-all $f
set nf [open out.nam w]
$ns namtrace-all $nf


set r_(1) [$ns node]
set r_(2) [$ns node]
set r_(3) [$ns node]
set r_(4) [$ns node]


$ns duplex-link $r_(1) $r_(2)  20Mb  10ms MKCQueue
set mkcq_(1) [[$ns link $r_(1) $r_(2)] queue]
$mkcq_(1) set C 200
$mkcq_(1) set T 0.1
$mkcq_(1) set rid 1


$ns duplex-link $r_(2) $r_(4)  20Mb  15ms MKCQueue
set mkcq_(2) [[$ns link $r_(2) $r_(4)] queue]
$mkcq_(2) set C 170
$mkcq_(2) set T 0.1
$mkcq_(2) set rid 2


$ns duplex-link $r_(4) $r_(3)  20Mb  10ms MKCQueue
set mkcq_(3) [[$ns link $r_(2) $r_(4)] queue]
$mkcq_(3) set C 200
$mkcq_(3) set T 0.1
$mkcq_(3) set rid 3


$ns duplex-link $r_(3) $r_(1)  20Mb  15ms MKCQueue
set mkcq_(4) [[$ns link $r_(3) $r_(1)] queue]
$mkcq_(4) set C 170
$mkcq_(4) set T 0.1
$mkcq_(4) set rid 4


set Snk_(2)  [new Agent/MKCSink]
$Snk_(2) set packetSize_ 40
$ns attach-agent $r_(2) $Snk_(2)

set Snk_(1)  [new Agent/MKCSink]
$Snk_(1) set packetSize_ 40
$ns attach-agent $r_(4) $Snk_(2)

set Snk_(4)  [new Agent/MKCSink]
$Snk_(4) set packetSize_ 40
$ns attach-agent $r_(3) $Snk_(4)

set Snk_(3)  [new Agent/MKCSink]
$Snk_(3) set packetSize_ 40
$ns attach-agent $r_(1) $Snk_(3)


set Src_(2) [new Agent/MKC]
$ns attach-agent $r_(1)  $Src_(2)
$Src_(2) set alpha_ 20
$Src_(2) set beta_ 0.5
$Src_(2) set packetSize_ 200
$Src_(2) set init_rate_ 10
$Src_(2) set fid_ 2



set Src_(1) [new Agent/MKC]
$ns attach-agent $r_(1)  $Src_(1)
$Src_(1) set alpha_ 20
$Src_(1) set beta_ 0.5
$Src_(1) set packetSize_ 200
$Src_(1) set init_rate_ 10
$Src_(1) set fid_ 1


set Src_(4) [new Agent/MKC]
$ns attach-agent $r_(4)  $Src_(4)
$Src_(4) set alpha_ 20
$Src_(4) set beta_ 0.5
$Src_(4) set packetSize_ 200
$Src_(4) set init_rate_ 10
$Src_(4) set fid_ 4


set Src_(3) [new Agent/MKC]
$ns attach-agent $r_(4)  $Src_(3)
$Src_(3) set alpha_ 20
$Src_(3) set beta_ 0.5
$Src_(3) set packetSize_ 200
$Src_(3) set init_rate_ 10
$Src_(3) set fid_ 3


$ns connect  $Src_(1)   $Snk_(1)
$ns connect  $Src_(2)   $Snk_(2)
$ns connect  $Src_(3)   $Snk_(3)
$ns connect  $Src_(4)   $Snk_(4)

$ns  cost $r_(4) $r_(3) 1
$ns  cost $r_(4) $r_(2) 10



$ns at 0 "$Src_(1)  start"
$ns at 10 "$Src_(2)  start"
$ns at 20 "$Src_(3)  start"
$ns at 30 "$Src_(4)  start"

$ns at 85 "$Src_(1)  stop"
$ns at 90 "$Src_(2)  stop"
$ns at 95 "$Src_(3)  stop"
$ns at 100 "$Src_(4)  stop"


$ns at 100.0  "finish"


proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}

$ns run



 plz   solve this  problem  give me  solution.


thank you



[ns] problem in schedule the events in tcl script

2015-05-21 Thread alok kumar

sir
   I have proble in below tcl script  when  schedule event part is
running plz  tell me  how tosolve error.
I have attached  related document  of mkc to  help  in  generate  tcl script
---mkc.tcl-

# create scheduler
set ns [new Simulator]

# turn tracing on
set f [open out11.tr w]
$ns trace-all $f
set nf [open out11.nam w]
$ns namtrace-all $nf

#set stat [open stat.txt w]

#create topology

#set number of flows
set N 2

#set the output file
for {set i 1} {$i<=$N} {incr i} {
set out_($i) [open out$i.txt w]
}

#source
for {set i 1} {$i<=$N} {incr i} {
set R_($i) [$ns node]
}

#bottleneck
set R_([expr $N + 1]) [$ns node]

#sink
set R_([expr $N + 2]) [$ns node]

#create the link connecting the source and sink
for {set i 1} {$i<=$N} {incr i} {
$ns duplex-link $R_($i) $R_([expr $N + 1]) 500Mb [expr 100 + 
[expr
$i - 1] * 900]ms MKCQueue
}

$ns duplex-link $R_([expr $N + 1]) $R_([expr $N + 2]) 10Mb 10ms MKCQueue

for {set i 1} {$i<=$N} {incr i} {
set mkcq_($i) [[$ns link $R_($i) $R_([expr $N + 1])] queue]
}

set mkcq_([expr $N + 1]) [[$ns link $R_([expr $N + 1]) $R_([expr $N +
2])] queue]

# link capacity
for {set i 1} {$i<=$N} {incr i} {
$mkcq_($i) set C 5
# the router sampling interval
#$mkcq_($i) set T 0.1
$mkcq_($i) set T [expr 0.1 * [expr $i - 1]]
$mkcq_($i) set rid $i
}

# the bottleneck link capacity
$mkcq_([expr $N + 1]) set C 1000
# the router sampling interval
$mkcq_([expr $N + 1]) set T 0.1
$mkcq_([expr $N + 1]) set rid [expr $N + 1]


#create and attach MKC agent

for {set i 1} {$i<=$N} {incr i} {
# create a new MKC sender
set Src_($i) [new Agent/MKC]

# attach the sender at the source node
$ns attach-agent $R_($i) $Src_($i)

$Src_($i) set alpha_ 100
$Src_($i) set beta_ 0.5
$Src_($i) set fid_ $i

# set the initial rate
$Src_($i) set init_rate_ 10

# set the data packet size
$Src_($i) set packetSize_ 200
}

#create and attach MKCSink agents

for {set i 1} {$i<=$N} {incr i} {
set Snk_($i) [new Agent/MKCSink]

# set ACK packet size
$Snk_($i) set packetSize_ 40

# attach the receiver at the sink node
$ns attach-agent $R_([expr $N + 2]) $Snk_($i)
}


# connect each pair of sender and receiver

for {set i 1} {$i<=$N} {incr i} {
$ns connect $Src_($i) $Snk_($i)
}

# schedule the events

$ns at 0 "$Src_(1) start"
$ns at 5 "$Src_(2) start"

for {set i 1} {$i<=$N} {incr i} {
$ns at 0 "record $Src_($i) $out_($i)"
}


for {set i 1} {$i<=$N} {incr i} {
$ns at 100.0 "$Src_($i) stop"
}

$ns at 100.0 "finish"

proc record {mkcsrc file} {
global ns f nf
set step 0.1
set now [$ns now]
set rate_ [$mkcsrc set rate_]
set pkt_loss_ [$mkcsrc set pkt_loss_]
puts $file "$now $rate_ $pkt_loss_"
$ns at [expr $now+$step] "record $mkcsrc $file"
}

proc finish {} {

global ns f nf
$ns flush-trace
close $f
close $nf
puts "running nam"
exec nam out11.nam &

exit 0
}

$ns run


thank you


[ns] how to implement mkc

2015-05-24 Thread alok kumar

sir,
  I want   to implement  max-min kelly controlalgorithm  in ns2
.how to  implement   sender,sink,queue  for mkc   plz tell  algorithm
or  source code  of mkc (sender,sink,queue)  for ns2 .


plz anybody  help me.


thank you



[ns] problem in .cc file and .h file

2015-05-27 Thread alok kumar

sir,
  I am working on  Max-min kelly control  but in which mkc-queue.cc
file   and  mkc-queue.h
  does not  work  properly  .In which something missing  but i am not
understand  where is the  fault  in this file.


--mkc-queue.cc
/*
 * Author: Yueping Zhang, Internet Research Lab (IRL), Texas A&M University
 * Email: yuep...@cs.tamu.edu
 * File Name: mkc_queue.cc
 * Functionality: implementation of mkc router
 * Last modified on Nov. 14, 2005
 */
#include 
#include 
#include "config.h"
#include "template.h"
#include "random.h"
#include "flags.h"
#include "delay.h"
#include "mkc-queue.h"

/*
 * Delare the class of the MKC router
 */
static class MKCQueueClass : public TclClass {
public:
MKCQueueClass() : TclClass("Queue/MKCQueue") {}
TclObject* create(int, const char*const*) {
return (new MKCQueue);
}
} class_MKC_queue;

/*
 * Constructor of the MKC router class
 */
MKCQueue::MKCQueue()
{
double now = Scheduler::instance().clock();
q_ = new PacketQueue();// underlying queue



bind("bytes", &bytes_ );
bind("setbit", &setbit_);
bind("C",   &C_);  // capacity
bind("T",   &delta_);  // sampling interval
bind("rid", &rid_);// router ID

MKCp_.rcv_rate = 0;
MKCp_.pkt_loss = 2;
MKCp_.volume = 0;
MKCp_.pkt_loss_seqno = -1;

// start the timer
tFinish_ = now + delta_;
tStart_ = now;
duration_ = delta_;

isFirstPkt = 1;
}

/*
 * Receive function, called upon each packet arrival
 */
void MKCQueue::recv(Packet* p, Handler* h){
double now = Scheduler::instance().clock();
hdr_cmn* ch = hdr_cmn::access(p);

if(ch->ptype() == PT_MKC)  // check if the incoming packet is an
MKC data packet
{
if(isFirstPkt){
// record the starting time of the current sampling 
interval
tStart_ = now;
tFinish_=tStart_ + delta_;
isFirstPkt = 0;
}

q_->enque(p);
p = q_->deque();

// if the current sampling interval ends, we proceed to 
synthesis the feedback
compute_ack(p);

// write ACK in the packet header
do_on_packet_arrival(p);

if(p != 0){
Queue::recv(p,h);
}
// if the incoming packet is an MKC ACK, forward it immediately
}
else if (ch->ptype()==PT_MKC_ACK)
{
if(p != 0){
Queue::recv(p,h);   
}
}
}

/*
 * Return the top packet in the queue
 */
Packet* MKCQueue::deque()
{
Packet *p = q_->deque();
return (p);
}

/*
 * Place the packet at the tail of the queue
 */
void MKCQueue::enque(Packet* pkt)
{
q_ -> enque(pkt);
}

/*
 * Write feedback information in the packet header
 */
void MKCQueue::do_on_packet_arrival(Packet *p)
{
hdr_mkc* header_mkc;
header_mkc = hdr_mkc::access(p);

MKCp_.volume += header_mkc->psize;

// if the local packet loss is computed, override the packet header
if the packet loss carried in
// header is less than the local packet loss, or the current router
is the first router for the packet
if ((header_mkc->flost < MKCp_.pkt_loss|| header_mkc->is_changed ==
0) && MKCp_.pkt_loss != 2)
{
header_mkc->flost = MKCp_.pkt_loss;
header_mkc->rid = rid_;
header_mkc->delta = duration_;
header_mkc->loss_seqno = MKCp_.pkt_loss_seqno;
header_mkc->is_changed = 1;
}
// if the packet loss is not ready, mark the ACK invalid
else if (MKCp_.pkt_loss == 2)
{
header_mkc->flost = 2;
header_mkc->is_changed = 1;
}
}

/*
 * Compute the feedback information, called upon each timer expiration
 */
void MKCQueue::compute_ack(Packet *p)
{
hdr_mkc* header_mkc;
header_mkc = hdr_mkc::access(p);
double now = Scheduler::instance().clock();
if(now >= tFinish_ && now > tStart_)
{   
duration_ = now - tStart_; // duration of the delta interval

// increment packet loss seqence number by one
MKCp_.pkt_loss_seqno++;

// calculate the incoming rate during the last interval delta_
MKCp_.rcv_rate=(double)MKCp_.volume/duration_;

// calculate the packet loss
if (MKCp_.rcv_rate != 0)
MKCp_.pkt_loss = (double)(MKCp_.rcv_rate - C_) / 
MKCp_.rcv_rate;
else
MKCp_.p

[ns] problem in generating xgraph

2015-05-31 Thread alok kumar

sir,
  when i am using to  generate  nam file its properly  work  in ns2.35
 but when I am using to  generate   xgraph  we modify  nam file  it
gives the following error:
  "invalid command name "Agent/TCPSink/Sack1/DeAck"
while executing
"Agent/TCPSink/Sack1/DeAck create _o108 "
invoked from within
"catch "$className create $o $args" msg"
invoked from within
"if [catch "$className create $o $args" msg] {
if [string match "__FAILED_SHADOW_OBJECT_" $msg] {
delete $o
return ""
}
global errorInfo
error "class $..."
(procedure "new" line 3)
invoked from within
"new Agent/TCPSink/Sack1/DeAck"
invoked from within
"set Sink0 [new Agent/TCPSink/Sack1/DeAck]"
(file "blue.tcl" line 75)"




this tcl  file for nam:

--blue.tcl
for nam file it properly work--
#script illustrating the BLUE algorithm
#Senders are TCP-SACK senders, and receivers are TCP-SACK sinks

set ns [new Simulator]

# turn on ns and nam tracing
set f [open out.tr w]
$ns trace-all $f
$ns namtrace-all [open out.nam w]

#set the no of TCP flows here
set nodenum 5

set start_time 1.0
set finish_time 100

# create the nodes

#First create TCP senders and receivers

for {set i 0} {$i < $nodenum} {incr i} {

set s($i) [$ns node]
set r($i) [$ns node]
}

#Then create the 2 back-bone routers
set n1 [$ns node]
set n2 [$ns node]

# create the links
#betwwen the senders and n1, receivers and n2
for {set i 0} {$i < $nodenum} {incr i} {

$ns duplex-link $s($i) $n1 10Mb 1ms DropTail
$ns duplex-link $r($i) $n2 10Mb 1ms DropTail

}

#Bottle neck link between between n1 and n2
$ns simplex-link $n1 $n2 1Mbps 100ms Blue
$ns simplex-link $n2 $n1 1Mbps 100ms DropTail

#Configure BLUE queue parameters here
set blueq [[$ns link $n1 $n2] queue]
$blueq set decrement 0.00025
$blueq set increment 0.0025
$blueq set dhold-time 100ms
$blueq set ihold-time 100ms

#Enable ECN here
$blueq set setbit true

#set the queue-limit between n1 and n2
$ns queue-limit $n1 $n2 50

#set up queue monitor, sample every 0.5 seconds
set qfile [open "test-blue-qsize.out" w]
set qm [$ns monitor-queue $n1 $n2 $qfile 0.5]
[$ns link $n1 $n2] queue-sample-timeout

#create the random number generator
set rng [new RNG]


# create TCP agents
for {set i 0} {$i < $nodenum} {incr i} {

set tcp($i) [new Agent/TCP/Sack1]
$tcp($i) set fid_ [expr ($i + 1)]
$tcp($i) set ecn_ 1
set sink($i) [new Agent/TCPSink/Sack1/DelAck]
$sink($i) set ecn_ 1
$ns attach-agent $s($i) $tcp($i)
$ns attach-agent $r($i) $sink($i)
$ns connect $tcp($i) $sink($i)
set ftp($i) [new Application/FTP]
$ftp($i) attach-agent $tcp($i)
set p($i) [new Application/Traffic/Pareto]
$p($i) set packetSize_ 1000
$p($i) set burst_time_ 200ms
$p($i) set idle_time_ 200ms
$p($i) set shape_ 1.5
$p($i) set rate_ 1K
$p($i) attach-agent $tcp($i)
set start_time [$rng uniform 0 1]
$ns at $start_time "$ftp($i) start"
$ns at $start_time "$p($i) start"
}


$ns at $finish_time "finish"


proc finish {} {
global ns sink nodenum  qfile
$ns flush-trace
close $qfile
puts "running nam..."
exec nam out.nam &
#exec xgraph out.tr -geometry 800x400 &
exit 0
}

$ns run



---blue.tcl---after
modify above blue.tcl for xgraph but  it gives  above
error



#script illustrating the BLUE algorithm
#Senders are TCP-SACK senders, and receivers are TCP-SACK sinks

set ns [new Simulator]

# turn on ns and nam tracing
$ns color 0 red

#set the no of TCP flows here


set f0 [open out0.tr w]
set f1 [open out1.tr w]
set f2 [open out2.nam w]
$ns namtrace-all $f2

# create the nodes

#First create TCP senders and receivers

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]



# create the links
#betwwen the senders and n1, receivers and n2
$ns  duplex-link $n0 $n2  10Mb 1ms DropTail
$ns  duplex-link $n1 $n2  10Mb 1ms DropTail

#Bottle neck link between between n1 and n2
$ns simplex-link $n2 $n3 1Mbps 100ms Blue
$ns simplex-link $n4 $n3 1Mbps 100ms DropTail
$ns simplex-link $n5 $n3 1Mbps 100ms DropTail



#Configure BLUE queue parameters here
set blueq [[$ns link $n2 $n3] queue]
$blueq set decrement 0.00025
$blueq set increment 0.0025
$blueq set dhold-time 100ms
$blueq set ihold-time 100ms

#Enable ECN here
$blueq set setbit true

#set the queue-limit between n1 and n2
$ns queue-limit $n2 $n3 50

#set up queue monitor, sample every 0.5 seconds
set qfile [open "test-blue-qsize.out" w]
set qm [$ns monitor-queue $n2 $n3 $qfile 0.5]
[$ns link $n2 $n3] queue-sample-timeout

#create the random number generator
#set rng [new RNG]


# create TCP agents
set tcp0 [new Agent/TCP/Sack1]
$tcp0 set fid_ 1
$tcp0 set ecn_ 1
$ns attach-agent $n0 $tcp0

set tcp1 [new Agent/TCP/Sack1]
$tcp1 set fid_ 2
$tcp1 set ecn_ 1
$ns attach-age

[ns] problem in generating xgraph its urgent

2015-06-07 Thread alok kumar

sir,
  I am using  below tcl  code  to generate  xgraph  but it  give the
following error:

  "can't read "n0": no such variable
while executing
"$ns attach-agent $n0 $udp0"
(procedure "attach-expoo-traffic" line 6)
invoked from within
"attach-expoo-traffic $n4 $Sink0 200 2s 1s 100k"
invoked from within
"set udp0 [attach-expoo-traffic $n4 $Sink0 200 2s 1s 100k]"
(file "blue1.tcl" line 145)"



-blue.tcl---
#script illustrating the BLUE algorithm
#Senders are TCP-SACK senders, and receivers are TCP-SACK sinks

set ns [new Simulator]

# turn on ns and nam tracing
$ns color 0 red

#set the no of TCP flows here


set f0 [open out0.tr w]
set f1 [open out1.tr w]
set f2 [open out2.nam w]
$ns namtrace-all $f2

# create the nodes

#First create TCP senders and receivers

set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
set n5 [$ns node]


# create the links
#betwwen the senders and n1, receivers and n2
$ns  duplex-link $n0 $n2  10Mb 1ms DropTail
$ns  duplex-link $n1 $n2  10Mb 1ms DropTail

#Bottle neck link between between n1 and n2
$ns simplex-link $n2 $n3 1Mbps 100ms Blue
$ns simplex-link $n4 $n3 1Mbps 100ms DropTail
$ns simplex-link $n5 $n3 1Mbps 100ms DropTail



proc finish {} {
global ns f0 f1 f2 f3

$ns flush-trace
close $f0
close $f1
close $f2
exec nam out2.nam &

exec xgraph out0.tr out1.tr -geometry 800x400 &
exit 0
}


#Configure BLUE queue parameters here
set blueq [[$ns link $n2 $n3] queue]
$blueq set decrement 0.00025
$blueq set increment 0.0025
$blueq set dhold-time 100ms
$blueq set ihold-time 100ms

#Enable ECN here
$blueq set setbit true

#set the queue-limit between n1 and n2
$ns queue-limit $n2 $n3 50

#set up queue monitor, sample every 0.5 seconds
set qfile [open "test-blue-qsize.out" w]
set qm [$ns monitor-queue $n2 $n3 $qfile 0.5]
[$ns link $n2 $n3] queue-sample-timeout


proc attach-expoo-traffic { node sink size burst idle rate } {
set ns [Simulator instance]
set udp0 [new Agent/UDP]
$udp0 set fid_ 1
$udp0 set ecn_ 1
$ns attach-agent $n0 $udp0

set udp1 [new Agent/UDP]
$udp1 set fid_ 2
$udp1 set ecn_ 1
$ns attach-agent $n1 $udp1

#set Sink0 [new Agent/TCPSink/Sack1/DeAck]
#$Sink0 set ecn_ 1
#$ns attach-agent $n4 $Sink0

#set Sink1 [new Agent/TCPSink/Sack1/DeAck]
#$Sink1 set ecn_ 1
#$ns attach-agent $n5 $Sink1



   set traffic0 [new Application/Traffic/Pareto]
   $traffic0 set packetSize_ 1000
   $traffic0 set burst_time_ 200ms
   $traffic0 set idle_time_ 200ms
   $traffic0 set shape_ 1.5
   $traffic0 set rate_ 1K
   $traffic0 attach-agent $udp0


   set traffic1 [new Application/Traffic/Pareto]
   $traffic1 set packetSize_ 1000
   $traffic1 set burst_time_ 200ms
   $traffic1 set idle_time_ 200ms
   $traffic1 set shape_ 1.5
   $traffic1 set rate_ 1K
   $traffic1 attach-agent $udp1


$ns connect $udp0 $Sink0
$ns connect $udp1 $Sink1
return $traffic0
return $traffic1
}
proc record {} {
global Sink0 Sink1  f0 f1
set ns [Simulator instance]
set time 0.5

set bw0 [$Sink0 set bytes_]
set bw1 [$Sink1 set bytes_]

set now [$ns now]

puts $f0 "$now [expr $bw0/$time*8/100]"
puts $f1 "$now [expr $bw1/$time*8/100]"

$Sink0 set bytes_ 0
$Sink1 set bytes_ 0


$ns at [expr $now+$time] "record"
}

set Sink0 [new Agent/LossMonitor]
set Sink1 [new Agent/LossMonitor]

$ns attach-agent $n4 $Sink0
$ns attach-agent $n5 $Sink1

set udp0 [attach-expoo-traffic $n4 $Sink0 200 2s 1s 100k]
set udp1 [attach-expoo-traffic $n5 $Sink1 200 2s 1s 200k]

$ns at 0.0 "record"


$ns at 10.0 "$udp0 start"
$ns at 10.0 "$udp1 start"
$ns at 90.0 "$udp0 stop"
$ns at 95.0 "$udp1 stop"

$ns at 100.0 "finish"

$ns run



plz  solve  error or  tell me how to above error.

thank  you



[ns] error found in source file

2015-06-17 Thread alok kumar

sir,
  when  i am  running tcl file  it give the below error :
 "Segmentation fault (core dumped)"
  now, below  .cc,.h and .tcl file is:--

-blue.cc---


#include 
#include 
#include 
#include "blue.h"
#include "random.h"
#include "delay.h"
#include "flags.h"

static class BlueClass : public TclClass {

 public:
BlueClass() : TclClass("Queue/Blue") {}
TclObject* create(int argc, const char*const* argv) {
return (new Blue);
}
} class_blue;


Blue::Blue() {
q_ = new PacketQueue();
pq_ = q_;
bind_bool("drop_front_", &drop_front_);
bind_bool("bytes", &bytes_ );
bind_bool("setbit", &setbit_);
bind("decrement", &decrement_);
bind("increment", &increment_);
bind_time("dhold-time", &dholdtime_);
bind_time("ihold-time", &iholdtime_);
bind("dalgorithm", &dalgorithm_);
bind("ialgorithm", &ialgorithm_);
bind("pmark", &pmark_);
bind("pktsize", &mean_pktsize_);
bind_bool("queue_in_bytes_", &qib_);
bind("blue_l_", &blue_l_);
bind("curq_", &curq_);
bind("marking_prob_trace_", &marking_prob_trace_);
}


Blue::~Blue() {
{
delete q_;
}

}

int Blue::command(int argc, const char*const* argv) {

Tcl& tcl = Tcl::instance();
if (argc == 3) {

 //attach a file for variable tracing
   if (strcmp(argv[1], "attach") == 0) {
int mode;
const char* id = argv[2];
tchan_ = Tcl_GetChannel(tcl.interp(), (char*)id, &mode);
if (tchan_ == 0) {
 tcl.resultf("BLUE: trace: can't attach %s for
writing", id);
 return (TCL_ERROR);
}
return (TCL_OK);
   }

if (strcmp(argv[1], "link") == 0) {
LinkDelay* link_  = 
(LinkDelay*)TclObject::lookup(argv[2]);
if (link_ == 0) {
tcl.resultf("Blue : No link delay Object %s\n",
argv[2]);
return(TCL_ERROR);
}
bandwidth_ = link_->bandwidth();
return(TCL_OK);
}

if (!strcmp(argv[1], "packetqueue-attach")) {
delete q_;
if (!(q_ = (PacketQueue*) TclObject::lookup(argv[2])))
return (TCL_ERROR);
else {
pq_ = q_;
return (TCL_OK);
}
}


}

return Queue::command(argc, argv);
}


void
Blue::reset()
{
Queue::reset();
ptc_ = (bandwidth_ / (8 * mean_pktsize_));
idle_ = 1;
idletime_ = Scheduler::instance().clock();
pmark_ = 0;
marking_prob_trace_ = pmark_;
ifreezetime_ = 0;
dfreezetime_ = 0;
}


void
Blue::decrement_pmark(int how)
{
double now = Scheduler::instance().clock();
if (now - dfreezetime_ > dholdtime_) {
pmark_ -= decrement_;
if (pmark_ < 0)
  pmark_ = 0.0;
marking_prob_trace_ = pmark_;
}

/*if (now - dfreezetime_ > dholdtime_) {
dfreezetime_ = now;
switch (dalgorithm_) {
case 0:
case 2:
switch (how) {
case 0:
pmark_ -= decrement_;
break;
case 1:
default:
break;
}
break;
default:
case 1:
switch (how) {
case 0:
pmark_ -= decrement_;
break;
case 1:
default:
pmark_ -= decrement_/10;
break;
}
}
if (pmark_ < 0)
pmark_ = 0.0;
}*/
}


void  Blue::increment_pmark(int how)
{
double now = Scheduler::instance().clock();
int qlen = qib_ ? q_->byteLength() : q_->length();
curq_ = qlen;

   if ((now - ifreezetime_ > iholdtime_) || (curq_ > blue_l_))
   {
  iholdtime_ = now;
  pmark_ += increment_;
  if (pmark_ > 1.0)
pmark_ = 1.00;
  marking_prob_trace_ = pmark_;
   }

   /* if (now - ifreezetime_ > iholdtime_) {
ifreezetime_ = now;
switch (ialgorithm_) {
case 0:
switch (h

[ns] how to write trace code in mkc-source .cc and .h file its urgent

2015-06-24 Thread alok kumar

sir,
  I am trying  to write  trace code in  mkc-source.cc and mkc-source.h
 file  but  I am not understand  how to  implement this code.Below
mkc-source.cc  and mkc-source.h   file here:


-mkc-source.cc---

#include 
#include 
#include 
#include "packet.h"
#include "mkc-source.h"
#include "flags.h"
#include "random.h"
#include "basetrace.h"
#include "hdr_qs.h"
#include "ip.h"

int hdr_mkc::offset_;
int hdr_mkc_ack::offset_;

/*
 * Declare the MKC packet header class
 */
static class MKCHeaderClass : public PacketHeaderClass {
public:
MKCHeaderClass() : PacketHeaderClass("PacketHeader/MKC",
sizeof(hdr_mkc)) {
bind_offset(&hdr_mkc::offset_);
}
} class_MKChdr;

/*
 * Declare the MKC acknowledgement header class
 */
static class MKC_ACKHeaderClass : public PacketHeaderClass {
public:
MKC_ACKHeaderClass() : PacketHeaderClass("PacketHeader/MKC_ACK",
sizeof(hdr_mkc_ack)) {
bind_offset(&hdr_mkc_ack::offset_);
}
} class_MKC_ackhdr;

/*
 * Declare the class of MKC sender agent
 */
static class MKCClass : public TclClass {
public:
MKCClass() : TclClass("Agent/MKC") {}
TclObject* create(int, const char*const*) {
return (new MKCAgent());
}
} class_MKC;

/*
 * Constructor of an MKC sender agent
 */
MKCAgent::MKCAgent() : Agent(PT_MKC), send_timer_(this)
{   
bind("packetSize_", &size_);
bind("rate_",   &rate_);
bind("init_rate_",  &init_rate_);
bind("alpha_",  &alpha_);   
bind("beta_",   &beta_);
bind("pkt_loss_",   &pkt_loss_);
bind("fid_",&fid_);
}

/*
 * Initialization of an MKC sender
 */
void MKCAgent::start()
{
rate_ = init_rate_;// set the initial rate
delta_ = -1;   // set delta interval to -1
loss_seqno_ = -1;  // set packet loss sequence number to -1
max_loss_seqno_ = -1;  // set maximum packet loss sequence number to -1
pkt_loss_ = 2; // set packet loss to an invalid value 2
current_ack_seqno_ = 0;// packet sequence number starts from 0
size_ = size_ * 8; // in bits
last_ack_seqno_ = 0;   // sequence number of the last non-duplicate 
feedback
cur_pkt_seqno_ = 0;// packet sequence number starts from 0
cur_rid = -1;  // bottleneck router is undecided
ref_rate = -1; // reference rate
is_rtt_expired_ = 0;   // whether an RTT elapsed after the last rate 
change
switch_in_progress = 0;// no bottleneck switching is in progress
seqno_last_rtt = 0;// sequence number of the first packet of the
last bottleneck switching
active_ = 1;   // sender is active

printf("Flow %d starts at time %f\n", fid_, 
Scheduler::instance().clock());

send_timer_.resched(size_ / rate_); // send out the first packet
}

/*
 * Termination of an MKC sender
 */
void MKCAgent::stop()
{
active_ = 0;
send_timer_.force_cancel();
}

/*
 * Definition of the tcl commands
 */
int MKCAgent::command(int argc, const char*const* argv)
{
if (argc==2) {
if (strcmp(argv[1],"start")==0) {
start();
return TCL_OK;
}
if (strcmp(argv[1],"stop")==0) {
stop();
return TCL_OK;
}
}
return (Agent::command(argc, argv));
}

/*
 * Receive a feedback from the network
 */
void MKCAgent::recv(Packet *pkt, Handler *)
{
double now = Scheduler::instance().clock();
hdr_mkc_ack *nck = hdr_mkc_ack::access(pkt);

// manage bottleneck switching
if (nck->rid != cur_rid && nck->flost != 2 && switch_in_progress == 0)
{
// authorize a bottleneck switch if and only if the difference 
between the
// old packet loss and the one carried in the ack is greater 
than 0.001
double diff = fabs(nck->flost - pkt_loss_);
if (diff > 0.01)
{
cur_rid = nck->rid; // change the membership
// In the progress of switching, delay response to 
feedbacks by one RTT
// + one Delta interval. This is accomplished by 
variable
switch_in_progress:
// 0 -- no switching in progress, 1 -- start switching,
// 2 -- one RTT elpased, 3 -- one Delta interval elapsed
switch_in_progress = 1;
seqno_last_rtt = cur_pkt_seqno_;
max_loss_seqno_ = nck->loss_seqno;
is_rtt_expired_ = 0;
printf("At time %f, bottleneck of flow %d switched to 
%d\n", now,
fid_, cur_rid);

[ns] implementation problem

2015-07-02 Thread alok kumar

sir,
   I am not understand  how to  implement  EMKC(EXPONENTIAL MAX-MIN KELLY
CONTROL) . so plz help me to implement  EMKC.


thank you