Re: [ns] Fwd: Implementing Round Robin Scheduler

2012-03-21 Thread Ricard Alegre

The question is:

Are the lines I have commented to solve the problem important or can't
affect simulations in any other way?


ns-ib.tcl:

#
# Also reset every queue
#

#foreach qn [array names link_] {
#set q [$link_($qn) queue]
#$q reset
#}

If so, there is an alternative way to solve the problem?

Regards,

2012/3/20 Teerawat@UBC teera...@ece.ubc.ca

 HI Richard,

 So, what is the question?

 Best Wishes,

 Teerawat Issariyakul
 http://www.ns2ultimate.com/
 http://www.facebook.com/pages/Teerawat-Issariyakul/358240861417
 http://twitter.com/T_Bear
 http://www.t-issariyakul.blogspot.com
 http://www.ece.ubc.ca/~teerawat


 On Mar 19, 2012, at 11:43 PM, Ricard Alegre wrote:

 
  Dear all,
 
  I wanted to implement a Round Robin packet scheduler just following the
  process in the book Introduction to Network Simulator ns2 from Ekran
  Hossain:
 
  According to the process I have created the following *.cc and *.h files:
 
  *//classifier-flow.h*
 
  #ifndef ns_gw_flow_classifier_h
  #define ns_gw_flow_classifier_h
 
  #include packet.h
  #include ip.h
  #include classifier.h
 
  class FlowClassifier : public Classifier {
  protected:
 int classify(Packet *p);
  };
 
  #endif
 
 
  *//classifier-flow.cc*
  #include gw_flow_classifier.h
  #include stdlib.h
 
 
  static class FlowClassifierClass : public TclClass {
  public:
 FlowClassifierClass() : TclClass(Classifier/Flow) {}
 TclObject* create(int, const char*const*) {
 return (new FlowClassifier());
 }
  } class_flow_classifier;
 
 
 
  int FlowClassifier::classify(Packet *p) {
 return hdr_ip::access(p)-flowid();
  }
 
 
  *//pkt-sched.h*
 
  #ifndef ns_gw_pkt_sch_h
  #define ns_gw_pkt_sch_h
 
  #include packet.h
  #include ip.h
  #include connector.h
  #include queue.h
 
  #define NS 10
 
 
  class PktScheduler : public Connector {
  public:
 PktScheduler();
 virtual void handle(Event*);
 virtual void recv(Packet*, Handler*);
  protected:
 void send(int fid, Handler* h);
 virtual void resume();
 int getFlowID(Packet* p) {return hdr_ip::access(p)-flowid();};
 virtual int nextID() = 0;
 Handler* qh_[NS];
 Packet* pkt_[NS];
 int blocked_;
 int active_flow_id_;
  };
 
  //RR
  class RRScheduler : public PktScheduler {
  public:
  RRScheduler();
  private:
 virtual int nextID();
 int current_id_;
  };
 
  #endif
 
 
  *//pkt-sched.cc*
  #include gw_pkt_sch.h
 
  PktScheduler::PktScheduler()
  {
 int i;
 for (i=0;iNS ;i++) {
 pkt_[i] = 0;
 qh_[i]=0;
 }
 blocked_ = 0;active_flow_id_ = -1;
  }
 
  void PktScheduler::recv(Packet* p, Handler* h)
  {
 int fid = getFlowID(p);
 pkt_[fid] = p;qh_[fid] = h;
 if (!blocked_) {
 send(fid,this);
 blocked_ = 1;
 active_flow_id_ = fid;
 }
  }
 
 
  void PktScheduler::send(int fid_idx, Handler* h)
  {
 Connector::send(pkt_[fid_idx],h);
 pkt_[fid_idx] = 0;
  }
 
 
  void PktScheduler::handle(Event*) { resume(); }
 
  void PktScheduler::resume()
  {
 qh_[active_flow_id_]-handle(0);
 int index = nextID();
 blocked_ = 0;
 if (index = 0) {
 send(index,this);
 blocked_ = 1;
 active_flow_id_ = index;
 }
  }
 
  //RR
  RRScheduler::RRScheduler()
  {
 current_id_ = -1;
  }
  static class RRSchedulerClass: public TclClass {
  public:
 RRSchedulerClass() : TclClass(PktScheduler/RR) {}
 TclObject* create(int, const char*const*) {
 return (new RRScheduler());
 }
  } class_rr_scheduler;
 
  int RRScheduler::nextID()
  {
 int count = 0;
 current_id_++;current_id_ %= NS;
 while((pkt_[current_id_] == 0)(count  NS)){
 current_id_++;current_id_ %= NS;
 count++;
 }
 if (count == NS)
 return -1;
 else{
 return current_id_;
 }
  }
 
  *And the following Otcl file:*
 
  *#ns-link.tcl*
 
  Class LinkSch -superclass Link
 
  LinkSch instproc init {src dst bw delay num_queues} {
 $self next $src $dst
 $self instvar link_ queue_ head_ toNode_ ttl_
 $self instvar drophead_
 $self instvar num_queues_ sch_ flow_clsfr_
 set ns [Simulator instance]
 set head_ [new Connector]
 set drophead_ [new Connector]
 set link_ [new DelayLink]
 set ttl_ [new TTLChecker]
 set flow_clsfr_ [new Classifier/Flow]
 set sch_ [new PktScheduler/RR]
 set num_queues_ $num_queues
 $head_ set link_ $self
 $drophead_ target [$ns set nullAgent_]
 $head_ target $flow_clsfr_
 for {set i 0} {$i  $num_queues_} {incr i} {
 set queue_($i) [new Queue/DropTail]
 $queue_($i) target $sch_
 $queue_($i) drop-target $drophead_
 }
 $sch_ target $link_
 $link_ target $ttl_
 $link_ drop-target $drophead_
 $link_ set bandwidth_ $bw
 $link_ set delay_ $delay
 $ttl_ target [$dst entry]
 $ttl_ drop-target $drophead_
  }
 
  LinkSch instproc add-flow { fid } {
 $self instvar queue_ flow_clsfr_
 

Re: [ns] H.264/AVC parser for ns2

2012-03-21 Thread suci


hai, i have got same problem like you
have you alredy fix that problem?
i need youre help.. 


Michail Tsagkaropoulos wrote:
 
 
 Dear All users,
 
 I am doing certain experiments with H.264 video transmission over IEEE  
 802.11 and UMTS. Currently, I am using the info from
 http://140.116.72.80/~smallko/ns2/h264.htm 
in order to encode a yuv video and parse it .
 However, the parser I use runs with H.26L encoder and not the latest H. 
 264/AVC http://iphome.hhi.de/suehring/tml/index.htm . When I try with  
 the latest encoder the parser doesn't seem to recognise the video  
 frames.
 Has anyone successfully used H.264/AVC encoder in order to parse a  
 video file into NS-2 and if yes, how ?
 Could you provide some extra info regarding my problem?
 Thank you eveyone in advance.
 
 Best regards,
 Michail Tsagkaropoulos
 
 
 

-- 
View this message in context: 
http://old.nabble.com/H.264-AVC-parser-for-ns2-tp19905196p33544595.html
Sent from the ns-users mailing list archive at Nabble.com.



[ns] Help for send H.264 video via NS 2

2012-03-21 Thread suci

hi all, i've final project about crosslayer in ns-2.29 use h.264/AVC video
I am also new to myevalvid. I tried to use this in cygwin in windows, it is
working fine. xvid, MP4BOX, mp4trace are available only in exe format
but when i use etmp4 with this command 
  $./etmp4.exe sd_foreman_0 rd_foreman_0 modified.st foreman_qcif.mp4
foreman_qcife
come to be error

  **etmp4.exe has encountered a problem and needs to close.  We are sorry
for the inconvenience.
 

 

but before that, i've done the command

 $./mp4trace -f -s 192.168.0.2 12346 foreman_qcif.mp4  modified.st

  

 **Track 1: VideoH.264  - 176x144 pixel,391 samples, 00:00:13.033

Track 2: Hint RTP - 391 samples, 00:00:13.033

 

in modified.st only have I and P layer

 

what could be the problem here?

 

suci ramadona

politeknik caltex riau

Indonesia