hi,
    thank you for the response...
But I want to send my own created packet to the neighbors in the first
phase.Then I want to send 
the packet by embedding extra field in my created packet to the selected
neighbors through Distance vector routing .

    Now ,the example script ~/ns2.32/tcl/ex/flooding.tcl is  running by
sending predefined packet.....only..

1.Is there any backend C++ source  code for this script to modify the
packet???

2.Is it possible to use already defined DVR implementation in ns2 simulator 
to get the routing table information to be used in my C++ source code???  or
Should I write my own DVR again to get the desired routing table (which is
definitely time taking!!)

3.I am repeating the question for clarity which is in the last post 
---> 
  Is it possible to invoke user defined recv() method implicitly after
calling
  Connector::send()??

 Please anybody provide feedback for my questions....I am trying hard to
find the solutions for these in
the mailing lists..

Thank You
Rupesh








feel2chat wrote:
> 
> 
> there is an example script: /ns-allinone-2.32/ns-2.32/tcl/ex/flooding.tcl
> 
> On Sun, Apr 6, 2008 at 12:00 AM, srupesh <[EMAIL PROTECTED]> wrote:
>>
>>
>>  Hi,
>>
>>      I am a beginner  for ns2. I want to test flooding in wired nodes. I
>>  went through the posts related to it but couldn't find the solution.
>>   There is a link related to this issue but there is no solution--->
>>
>>  http://mailman.isi.edu/pipermail/ns-users/2006-January/053762.html
>>
>>  is it possible to invoke user defined recv() method implicitly after
>> calling
>>  Connector::send()??
>>
>>  anybody please give the information for this problem??
>>
>>  I am posting both C++ code and tcl code here..
>>
>>  I defined a new packet header here......
>>
>>  #ifndef BCAST_PKT_H_
>>  #define BCAST_PKT_H_
>>
>>  #include <packet.h>
>>  #include <config.h>
>>
>>  #define HDR_BCAST_PKT(p) hdr_bcast_pkt::access(p)
>>  struct hdr_bcast_pkt {
>>
>>      nsaddr_t   pkt_src_;     // Node which originated this packet
>>      u_int16_t pkt_len_;      // Packet length (in bytes)
>>      u_int8_t   pkt_seq_num_; // Packet sequence number
>>
>>      inline     nsaddr_t&   pkt_src()     { return pkt_src_; }
>>      inline     u_int16_t& pkt_len()      { return pkt_len_; }
>>      inline     u_int8_t&   pkt_seq_num() { return pkt_seq_num_; }
>>
>>      static int offset_;
>>      inline static int& offset() { return offset_; }
>>      inline static hdr_bcast_pkt* access(const Packet* p) {
>>          return (hdr_bcast_pkt*)p->access(offset_);
>>      }
>>
>>   };
>>
>>
>>
>>  #endif /*BCAST_PKT_H_*/
>>
>>  implementation of IP_BROADCAST----
>>
>>  int hdr_bcast_pkt::offset_ ;
>>  class MyAgent : public Agent{
>>  public :
>>         MyAgent();
>>  protected :
>>         int command(int argc,const char*const* argv);
>>  private:
>>         //int          my_var1;
>>         //double       my_var2;
>>         nsaddr_t           ra_addr_;
>>         void         my_func(void);
>>         void         my_bcast(Packet *p);
>>         void         recv(Packet* pkt, Handler*);
>>  };
>>  static class bcastHeaderClass : public PacketHeaderClass {
>>  public:
>>     bcastHeaderClass() : PacketHeaderClass("PacketHeader/bcast",
>>                                                sizeof(hdr_bcast_pkt)) {
>>         bind_offset(&hdr_bcast_pkt::offset_);
>>     }
>>  } class_bcast_hdr;
>>
>>  static class MyAgentClass : public TclClass {
>>  public :
>>         MyAgentClass() : TclClass("Agent/MyAgentOtcl") {}
>>         TclObject* create(int argc,const char*const* argv) {
>>                 return (new MyAgent()); 
>> //(nsaddr_t)Address::instance().str2addr(argv[4])
>>         }
>>  } class_my_agent;
>>
>>  MyAgent::MyAgent() : Agent(PT_bcast) {  //nsaddr_t id
>>         //bind("my_var1_otcl",&my_var1);
>>         //bind("my_var2_otcl",&my_var2);
>>         //ra_addr_ = id;
>>
>>  }
>>
>>  int MyAgent::command(int argc,const char*const* argv) {
>>
>>         if(argc == 2) {
>>                 if(strcmp(argv[1],"callmyfunc") == 0) {
>>                         my_func();
>>                         return (TCL_OK);
>>
>>                 }
>>                 if(strcmp(argv[1],"sendpkt") == 0) {
>>                         Packet* newpkt = allocpkt();
>>                         //some packet configuration
>>                         my_bcast(newpkt);
>>                         //recv(newpkt,0);
>>                         return (TCL_OK);
>>                 }
>>         }
>>
>>         return (Agent::command(argc,argv));
>>  }
>>
>>  void MyAgent::my_func(void) {
>>         Tcl& tcl = Tcl::instance();
>>         tcl.eval("puts \"Message from my_func\"");
>>         //tcl.evalf("puts \" my_var1= %d\"",my_var1);
>>         //tcl.evalf("puts \" my_var2 = %f\"",my_var2);
>>
>>  }
>>
>>
>>
>>  void MyAgent::my_bcast(Packet *p)
>>  {
>>  hdr_cmn* hdrcmn = HDR_CMN(p);
>>  hdr_ip* iphdr = HDR_IP(p);
>>  hdr_bcast_pkt* ph      = HDR_BCAST_PKT(p);
>>
>>  //ph ->pkt_src_                 = ra_addr_;
>>  ph ->pkt_len_                 = 64;
>>  // set all the necessary things for the common header
>>  hdrcmn ->size_                    = IP_HDR_LEN + ph->pkt_len();
>>  hdrcmn ->ptype_                   = PT_bcast;
>>  hdrcmn->next_hop_ = IP_BROADCAST;
>>  hdrcmn->prev_hop_ = this->addr();
>>  hdrcmn->direction() = hdr_cmn::DOWN;
>>  hdrcmn ->size_                    = IP_HDR_LEN + ph->pkt_len();
>>  hdrcmn ->ptype_                   = PT_bcast;
>>  // setting the ip header
>>  iphdr->saddr() = this->addr();
>>  iphdr->sport() = 254; // 1-254
>>  iphdr->daddr() = IP_BROADCAST;
>>  iphdr->dport() = 254; // 1-254
>>  iphdr->ttl() = 32;
>>  //Scheduler::instance().schedule(target_, p, 0.0);
>>  send(p,0);
>>  Tcl& tcl = Tcl::instance();
>>  tcl.eval("puts \"Message from my_bcast()\"");
>>  }
>>
>>
>>  void MyAgent::recv(Packet* pkt, Handler*)
>>  {
>>         Tcl& tcl = Tcl::instance();
>>         tcl.eval("puts \"1Message from recv()\"");
>>  hdr_cmn* hdrcmn = HDR_CMN(pkt); //Access the common header for the
>> received
>>  packet:
>>  hdr_ip* hdrip = HDR_IP(pkt); // Access the IP header for the received
>>  packet:
>>  cout << "node " << this->addr() << "received from node " <<
>>  hdrcmn->prev_hop_;
>>
>>         tcl.eval("puts \"2Message from recv()\"");
>>  }
>>
>>
>>  Front end Tcl code  :
>>
>>  set ns [new Simulator]
>>
>>  set n0 [$ns node]
>>  set n1 [$ns node]
>>  $ns duplex-link $n0 $n1 1Mb 10ms DropTail
>>
>>  set a0 [new Agent/MyAgentOtcl]
>>  $ns attach-agent $n0 $a0
>>  set a1 [new Agent/MyAgentOtcl]
>>  $ns attach-agent $n1 $a1
>>
>>  #$ns connect $a0 $a1
>>
>>  #set  myagent [new Agent/MyAgentOtcl]
>>  $a0 set my_var1_otcl 2
>>  $a0 set my_var2_otcl 3.14
>>
>>  $a0 callmyfunc
>>
>>  $a0 sendpkt
>>
>>  I am getting the error:
>>
>>  Message from my_func
>>  --- Classfier::no-slot{} default handler (tcl/lib/ns-lib.tcl) ---
>>         _o12: no target for slot -1
>>         _o12 type: Classifier/Hash/Dest
>>  content dump:
>>  classifier _o12
>>         0 offset
>>         0 shift
>>         2147483647 mask
>>         1 slots
>>                 slot 0: _o29 (Classifier/Port)
>>         -1 default
>>  ---------- Finished standard no-slot{} default handler ----------
>>
>>
>>  Regards
>>  Siva Rupesh
>>  --
>>  View this message in context:
>> http://www.nabble.com/How-to-implement-flooding-for-wired-nodes-%28IP_BROADCAST-usage%29--tp16519096p16519096.html
>>  Sent from the ns-users mailing list archive at Nabble.com.
>>
>>
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-implement-flooding-for-wired-nodes-%28IP_BROADCAST-usage%29--tp16519096p16539504.html
Sent from the ns-users mailing list archive at Nabble.com.

Reply via email to