[ns] Help to add new protocol in ns2

2015-04-25 Thread israe iken

Hi every body
I have to implement  enfat-aodv protocol in ns2 for that i should add some
fonctions in files aodv.h and aodv.cc the thing that i don't know how to do

this is the example i'm working in, please help me and thanks in advance.



*set ns [new Simulator]*

*# Create a nam trace datafile.*

*set namfile [open AODV_final.nam w]*

*set Time [open time.tr  w]*

*#This Block Is For Congestion Window Trace file. Here 5 sample trace file*

*set cwnd1 [open cwnd1.tr  w]*

*set cwnd2 [open cwnd2.tr  w]*

*set cwnd3 [open cwnd3.tr  w]*

*set cwnd4 [open cwnd4.tr  w]*

*set cwnd5 [open cwnd5.tr  w]*

*#This Block Is For Bandwidth Calculation Trace file. Here 5 sample trace
file*

*set b1 [open b1.tr  w]*

*set b2 [open b2.tr  w]*

*set b3 [open b3.tr  w]*

*set b4 [open b4.tr  w]*

*set b5 [open b5.tr  w]*

*$ns namtrace-all $namfile*

*# - Setup wireless environment. *

*set wireless_tracefile [open AODV_final.trace w]*

*set topography [new Topography]*

*$ns trace-all $wireless_tracefile*

*$ns namtrace-all-wireless $namfile 3000  1600 *

*$topography load_flatgrid 3000  1600*

*#TN means Total number of  wireless node*

*global TN*

*set TN 21*

*set god_ [create-god $TN]*

*#global node setting*

*$ns node-config -adhocRouting AODV \*

* -llType LL \*

* -macType Mac/802_11\*

* -ifqLen 50 \*

* -ifqType Queue/DropTail/PriQueue \*

* -antType Antenna/OmniAntenna \*

* -propType Propagation/TwoRayGround \*

* -phyType Phy/WirelessPhy \*

* -channel [new Channel/WirelessChannel] \*

* -topoInstance $topography \*

* -agentTrace ON \*

* -routerTrace ON \*

* -macTrace ON \*

* -movementTrace ON*

*# Create wireless nodes.*

*#I have used few loop and to set in  diffrent position i have use few
defined value*

*#Here X and Y is the axix*

*set x1 150*

*set y1 150*

*set x2 150*

*set y2 250*

*set x3 150*

*set y3 350*

*set x4 150*

*set y4 450*

*set x5 350*

*set y5 150*

*set x6 350*

*set y6 250*

*set x7 350*

*set y7 350*

*set x8 350*

*set y8 450*

*set x9 550*

*set y9 150*

*set x10 550*

*set y10 250*

*set x11 550*

*set y11 350*

*set x12 550*

*set y12 450*

*set x13 750*

*set y13 150*

*set x14 750*

*set y14 250*

*set x15 750*

*set y15 350*

*set x16 750*

*set y16 450*

*set x17 950*

*set y17 150*

*set x18 950*

*set y18 250*

*set x19 950*
*set y19 350*

*set x20 950*

*set y20 450*

*set x21 1100*
*set y21 300*

*#Setting node position block*

*for {set i 0} {$i < $TN} {incr i} {*

*set node($i) [$ns node]*

*$node($i) random-motion 0*

*$ns at 0.0 "$node($i) label Node_($i)"*

*$ns initial_node_pos $node($i) 50.00*

*}*

*for {set j 0} {$j < $TN} {incr j} {*

* set Tcp($j) [new Agent/TCP]*

*$ns attach-agent $node($j) $Tcp($j)*

*$ns color 1 "black"*

*$Tcp($j) set fid_ $j*

*$Tcp($j) set packetSize_ 512*

*$Tcp($j) set window_ 20*

*$Tcp($j) set windowInit_ 1*

*$Tcp($j) set maxcwnd_ 0*

*#Set TCPSink*

*set TcpSink($j) [new Agent/TCPSink]*

*$ns attach-agent $node($j) $TcpSink($j)*

*$TcpSink($j) set packetSize_ 210*

*#Set Trafic Source*



*set Ftp($j) [new Application/FTP]*

*$Ftp($j) attach-agent $Tcp($j)*

*$Ftp($j) set maxpkts_ 2048*

*}*





* for {set j1 0} {$j1 < $TN} {incr j1 21} {*

* incr x1 0*

* incr y1 150*

* $node($j1) set X_ $x1*

* $node($j1) set Y_ $y1*

*$node($j1) set Z_ 0*

* $node($j1) color "green"*

*$ns at 0.00 "$node($j1) setdest $x1 $y1 0.00"*



* }*



* for {set j2 1} {$j2 < $TN} {incr j2 21} {*

* incr x2 0*

* incr y2 140*

* $node($j2) set X_ $x2*

* $node($j2) set Y_ $y2*

*$node($j2) set Z_ 0*

* $node($j2) color "blue"*

*$ns at 0.00 "$node($j2) setdest $x2 $y2 0.00"*

* }*




* for {set j3 2} {$j3 < $TN} {incr j3 21} {*

* incr x3 0*

* incr y3 140*

* $node($j3) set X_ $x3*

* $node($j3) set Y_ $y3*

*$node($j3) set Z_ 0*

* $node($j3) color "red"*

*$ns at 0.00 "$node($j3) setdest $x3 $y3 0.00"*

* }*



* for {set j4 3} {$j4 < $TN} {incr j4 21} {*

* incr x4 0*

* incr y4 150*

* $node($j4) set X_ $x4*

* $node($j4) set Y_ $y4*

*$node($j4) set Z_ 0*

* $node($j4) color "blue"*

*$ns at 0.00 "$node($j4) setdest $x4 $y4 0.00"*

* }*






* for {set j5 4} {$j5 < $TN} {incr j5 21} {*

* incr x5 0*

* incr y5 140*

* $node($j5) set X_ $x5*

* $node($j5) set Y_ $y5*

*$node($j5) set Z_ 0*

* $node($j5) color "black"*

*$ns at 0.00 "$node($j5) setdest $x5 $y5 0.00"*

* }*



* for {set j6 5} {$j6 < $TN} {incr

Re: [ns] Help to add new protocol in ns2

2015-04-25 Thread knudfl

> @ israe iken
> enfat-aodv

The text you show looks like a simulation file, AODV_final.tcl, which you
can get here
http://www.28im.com/cpp/a3714481.html
... There is one typo in "AODV_final.tcl". I have uploaded the edited file
as AODV_final-1.tcl.txt.
Link 
https://drive.google.com/file/d/0B7S255p3kFXNY1owekgtXzNxREU/view?usp=sharing

About ENFAT-AODV : There is some code here ...
http://www.academia.edu/7706617/wireless_sensor_network_report_on_implementation_of_ENFANT-AODV_on_TOSSIM
→ →  And you can download the report as `Final_stage3_2.doc´, to get the
code.
** I have no idea if the code is usable in ns2.

-



--
View this message in context: 
http://network-simulator-ns-2.7690.n7.nabble.com/Help-to-add-new-protocol-in-ns2-tp29941p29943.html
Sent from the ns-users mailing list archive at Nabble.com.



[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