Upload
vucong
View
221
Download
3
Embed Size (px)
Citation preview
Developing New Modules Developing New Modules Developing New Modules Developing New Modules Developing New Modules Developing New Modules in NSin NS22
Developing New Modules Developing New Modules in NSin NS22
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 1
OutlineR• Recap
• Automatic Repeat reQuest• Packet Scheduling• SummarySummary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 2
RRecap• 3 Simulation Main Steps3 Simulation Main Steps1. Design and Implementation
– Things to simulate– Assumptions– Performance measure– Code Implementationp
2. Simulation– Network Configuration Phase
Si l ti Ph– Simulation Phase3. Result Compilation
– Debugging and Tracing
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
gg g g– Compute performance measures
3
D i d I l iDesign and Implementation• DesignDesign
1. What would you like to simulate? Draw a conceptual view
2 Wh t hi h d ish t b ild m d l ?2. What hierarchy do you wish to build a new module?C++, OTcl, or both Do you need to bind them?
3. What variables/functions do you need?4 D d OT l i f ?4. Do you need OTcl interface?
• Implementation1. Implement C++/OTcl codes1. Implement C /OTcl codes2. Modify makefile make
3. Develop Simulation script
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 4
OutlineR• Recap
• Automatic Repeat reQuest• Packet Scheduling• SummarySummary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 5
A i R QAutomatic Repeat reQuest• Error Control MechanismError Control Mechanism• Based on packet retransmission (i.e.,
acknowledgement (ACK))acknowledgement (ACK))• 3 Main types
– Stop and Wait– Go-back-N: TCP– Selective Repeat Request
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 6
S A d W iStop-And-Wait• Transmit and wait for ACK before Transmit and wait for ACK before
transmitting the next packetRetransmit after timeout• Retransmit after timeout
• Reset timeout upon receiving an ACK
1sender 22
timeout
receiver 1
l
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
packetACK
How many times would you retransmit the lost packet?
7
S A d W iStop-And-Wait• 1-persistent1-persistent• Infinite-persistent
i i • p-persistent: retransmit w.p. p• Finite persistent: retransmit upto K p p
times
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 8
S A d W iStop-And-Wait• Let e be error probabilityLet e be error probability
Persistent Type Pr of successful TX Persistent Type Pr. of successful TX 1 1-eInfinite 1Infinite 1p (1-e)/(1-pe)Finite 1 eK+1Finite 1-eK+1
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 9
C l ViConceptual View
n0 n1SimpleLink
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 10
C l ViConceptual View
n0 n1Lossy link
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 11
C l ViConceptual View
n0 n1Lossy link with ARQ
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 12
C l ViConceptual View• Two main mechanismsTwo main mechanisms
– ACK passingCallback mechanism– Callback mechanism
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 13
C l Vi• ACK passing
Conceptual ViewACK passing– tARQ_:
• ARQ transmitting unit • ARQ transmitting unit • Keep track of the no. of retransmissions• Decide whether to TX or drop the packetDec de whether to X or drop the packet
– acker_: inform tARQ_ of TX success– nacker : inform tARQ of TX failurenacker_ inform tARQ_ of TX failure
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 14
C l ViConceptual View• Two main mechanismsTwo main mechanisms
– ACK passingCallback mechanism– Callback mechanism
callback
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
callback
15
C l Vi• Callback mechanism
Conceptual ViewCallback mechanismQ: What does link_ do when receiving a
packet?packet?A: Schedule two events: Pkt departure
and arrival Th and arrival//~ns/link/delay.ccvoid LinkDelay::recv(Packet* p, Handler* h) {
This is a queue handler
double txt = txtime(p); Scheduler& s = Scheduler::instance(); s.schedule(target_, p, txt + delay_);
Pkt arrival:packet receptionat the next node
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
s.schedule(h, &intr_, txt); }
at the next nodePkt departure:Tell the associated queue to resume
16
C l Vi• Callback mechanism
Conceptual ViewCallback mechanismQ: What does link_errmodule do when
receiving a packet and the packet is in error?A: Drop the packet and Tell the queue to resume
// /ns/queue/errmodel cc
This is a queue //~/ns/queue/errmodel.cc
void ErrorModel::recv(Packet* p, Handler* h) {
double delay = Random::uniform(8.0*ch->size()/bandwidth_);i i
qhandler
Scheduler::instance().schedule(h, &intr_, delay);drop_->recv(p); return;
} Pkt departure:Tell the associated queue to resumeDrop the packet
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Drop the packet
17
C l Vi• link and linkerrmodule callback to
Conceptual Viewlink_ and linkerrmodule_ callback to tARQ_
• tARQ call back to queuet Q_ call back to queue_• To send packet p downstream:
– queue : recv(qh , p)q _ (q _, p)– tARQ_: recv(arqh_,p)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 18
C l ViConceptual View• Two main mechanisms
– ACK passing– Callback mechanismm m
Callback with ARQ
qh_
arqh_
callback
qh_
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
callbackwith qh_
19
C I l iC++ Implementation• ARQ Transmitter ClassesARQ Transmitter Classes
– ARQTX,ARQHandler
ARQ R i Cl ss s• ARQ Receiver Classes– ARQRX ARQAcker, ARQNacker
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 20
C I l iC++ ImplementationARQTX:ARQTX:
class ARQTx : public Connector {
called by ARQNacker
public:ARQTx();void recv(Packet*, Handler*);
id k(P k t*) id k()
called by ARQAcker
void nack(Packet*); void ack();void resume();
protected:ARQHandler arqh ;
Callback from link_ or linkerrmodule
Queue handler
Q q _;Handler* qh_; Packet* pkt_;ARQStatus status_;int blocked_;
_
Finite persistent ARQ
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
int retry_limit_; int num_rtxs_;};
21
C I l iARQTx,
C++ ImplementationARQTx::ARQTx() : arqh_(*this)ARQTx,
ARQHandler:_
{num_rtxs_ = 0; retry_limit_ = 0;qh_ = 0;pkt_ = 0;status_ = IDLE;blocked_ = 0;bind("retry_limit_", &retry_limit_);
}
enum ARQStatus {IDLE,SENT,ACKED,RTX,DROP};
class ARQHandler : public Handler {public:public:
ARQHandler(ARQTx& arq) : arq_tx_(arq) {};
void handle(Event*);private:
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
private: ARQTx& arq_tx_;
};
22
C I l iC++ ImplementationARQTX:ARQTX:
void ARQTx::recv(Packet* p, Handler* h){
qh_ = h;status_ = SENT;bl k d 1blocked_ = 1;send(p,&arqh_);
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 23
C I l iC++ ImplementationARQTX:ARQTX:
void ARQTx::recv(Packet* p, Handler* h){
qh_ = h;status_ = SENT;bl k d 1blocked_ = 1;send(p,&arqh_);
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 24
C I l iC++ Implementationnack(p)
ack()
nack(p)
num_rtxs_++;pkt_ = p;
num_rtxs_=0;status_ = ACKED;
num_rtxs_>retry_limit_<=retry_limit_
returnstatus_ = RTX; num_rtxs_ = 0;
status_ = DROP;
return
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 25
C I l iC++ Implementationresume()resume()
blocked_=0;
status_
ACKED RTX DROP
status_ = SENT;blocked_ = 1;
drop(pkt_);status_ = IDLE;
ACKED
status_ = IDLE;qh >handle(0);
RTX DROP
send(pkt_,&arqh_); qh_->handle(0);qh_->handle(0);
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
return
26
C I l iC++ Implementation• ARQ Transmitter ClassesARQ Transmitter Classes
– ARQTX,ARQHandler
ARQ R i Cl ss s• ARQ Receiver Classes– ARQRX ARQAcker, ARQNacker
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 27
C I l iC++ Implementationclass ARQRx : public Connector { ppublic:
ARQRx();int command(int argc, const char*const* argv); virtual void recv(Packet* Handler*);virtual void recv(Packet*, Handler*);virtual void resume()=0;Packet *pkt_;
protected: class ARQAcker : public ARQRx { bliARQTx* arq_tx_;
};
public:ARQAcker() {};virtual void resume();
};class ARQNacker : public ARQRx { public:
ARQNacker() {};virtual void resume();
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
();};
28
C I l iC++ Implementationint ARQRx::command(int argc, const char*const* argv) {
Tcl& tcl = Tcl::instance();if (argc == 3) {
if (strcmp(argv[1], "attach-ARQTx") == 0) {arq_tx_ = (ARQTx*)TclObject::lookup(argv[2]);return(TCL OK);return(TCL_OK);
}
} return Connector::command(argc, argv);}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 29
C I l iC++ Implementationid ( k * dl * h)void ARQRx::recv(Packet* p, Handler* h)
{pkt_ = p; handler_ = h; resume();
}
void ARQAcker::resume(){
arq_tx_->ack(); send(pkt_,handler_);}
void ARQNacker::resume(){
arq tx ->nack(pkt );
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
arq_tx_ >nack(pkt_);
}
30
OT l I l iOTcl Implementation• 2 Instprocs to put ARQ in the simple 2 Instprocs to put ARQ in the simple
link:1 Simulator:: link arq{limit from to}1. Simulator:: link-arq{limit from to}2. SimpleLink::link-arq{limit}
Simulator instproc link arq { limit from to } {Simulator instproc link-arq { limit from to } { set link [$self link $from $to] $link link-arq $limit
}
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
}
31
OT l I l iOTcl ImplementationSimpleLink instproc link-arq { limit } {
$self instvar link_ link_errmodule_ queue_ drophead_$self instvar tARQ_ acker_ nacker_ set tARQ_ [new ARQTx] set acker [ne ARQAcker]set acker_ [new ARQAcker] set nacker_ [new ARQNacker] $tARQ_ set retry_limit_ $limit $acker attach-ARQTx $tARQ $ _ Q $ Q_$nacker_ attach-ARQTx $tARQ_ $queue_ target $tARQ_ $tARQ_ target $link_errmodule_ $link_errmodule_ target $acker_ $acker_ target $link_ $tARQ_ drop-target $drophead_ $link errmodule drop target $nacker
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$link_errmodule_ drop-target $nacker_ }
32
T l Si l i S iTcl Simulation Script• Insert the following codes:Insert the following codes://tcp.tcl
set em [new ErrorModel]$em set rate_ 0.1$$em unit pkt$em ranvar [new RandomVariable/Uniform]$em drop-target [new Agent/Null]$ns link-lossmodel $em $n1 $n3$ns link-arq 2 $n1 $n3
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 33
R l C ll iResult Collection• Insert the following codes:Insert the following codes://tcp.tclproc show_tcp_seqno {} {
global tcp nsputs "At [$ns now] The final tcp sequence number is [$tcp set t seqno ]"[$tcp set t_seqno_]"
}
$ t 0 0 "$ft t t"$ns at 0.0 "$ftp start"$ns at 10.0 "show_tcp_seqno"$ns at 10.1 "$ns halt"$
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$ns run
34
Si l i R lSimulation Result>> ns tcp.tcl>> The final tcp sequence number is 37587
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 35
OutlineR• Recap
• Automatic Repeat reQuest• Packet Scheduling• SummarySummary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 36
P k S h d liPacket Scheduling• Not related to the Event SchedulingNot related to the Event Scheduling
Packet scheduler: Which packet should o first?Which packet should go first?
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 37
P k S h d liPacket Scheduling• Example of scheduler: (Give me few Example of scheduler: (Give me few
example) Round robin– Round robin
– Max rateDelay based– Delay based
– Fairness basedP i it b d– Priority based
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 38
C l ViConceptual View
n0 n1SimpleLink
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 39
C l ViConceptual ViewLinkSchedn0
n1 n1
n2
...
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 40
C l ViConceptual View• Key differencesKey differences
– Flow classifier (flow_clsfr_): Send packets from different flow to packets from different flow to different queue
– Scheduler (sch ): Determine which Scheduler (sch_) Determine which packet should go first• Round robin• Priority based
– Callback mechanism
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 41
C l ViConceptual ViewLinkSchedn0
n1 n1
n2
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 42
C l ViConceptual ViewLinkSchedn0
n1 n1
n2
Callback
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 43
C I l iC++ Implementation• Flow classifier: Flow classifier:
– Base class: ClassifierDerived class: FlowClassifier– Derived class: FlowClassifier
• Packet schedulerB l – Base class: Connector PktScheduler
– Derived class: RRScheduler
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 44
R P Cl ifiRecap: Port Classifier(1)
//~ns/classifier/classifier-port.ccint PortClassifier::classify(Packet *p)
(1)(3)
y( p){
hdr_ip* iph = hdr_ip::access(p);return iph->dport();
}
(2)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 45
Fl Cl ifiFlow Classifier• FlowClassfier (C++) FlowClassfier (C )
Classifier/Flow (OTcl)
• We only need to define function classify(p):y(p)
//classifier-flow.cc int FlowClassifier::classify(Packet *p)y p{
return hdr_ip::access(p)->flowid(); }
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 46
C I l iC++ Implementation• Flow classifier: Flow classifier:
– Base class: ClassifierDerived class: FlowClassifier– Derived class: FlowClassifier
• Packet schedulerB l – Base class: Connector PktScheduler
– Derived class: RRScheduler
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 47
C I l i• Two main functionality
C++ ImplementationTwo main functionality1. Determine the next flow and
transmitted the packettransmitted the packet2. Callback Mechanism
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 48
C I l iC++ ImplementationV i bl M iVariable Meaningblocked_ True if the PktScheduler is blockedactive_flow_id_ Flow ID of the packet being transmittedpkt_[i] HOL packet of queue iqh_[i] Queue handler corresponding to Queue i
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 49
C I l i• Declaration
C++ ImplementationDeclaration
#define MAX_FLOWS 10 class PktScheduler : public Connector { public:
P k t ti f tiPktScheduler(); virtual void handle(Event*); virtual void recv(Packet*, Handler*);
protected:
Packet reception function
Use this function to send packetsp
void send(int fid, Handler* h); virtual void resume(); int getFlowID(Packet* p) {return hdr_ip::access(p)->flowid();};virtual int nextID() = 0;
Callback function
virtual int nextID() 0; Handler* qh_[MAX_FLOWS]; Packet* pkt_[MAX_FLOWS]; int blocked_; int active flow id ;
Pure virtual function:Override by the derived class
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
int active_flow_id_;
};
50
C I l i• Functions recv(p h) and send(id h)
C++ ImplementationFunctions recv(p,h) and send(id,h)
void PktScheduler::recv(Packet* p, Handler* h)void PktScheduler::recv(Packet p, Handler h){
int fid = getFlowID(p); pkt_[fid] = p;qh_[fid] = h; if (!blocked ) {
PktScheduler
if (!blocked_) { send(fid,this); blocked_ = 1; active_flow_id_ = fid;
}
… …
pkt_ qh_
} }void PktScheduler::send(int fid_idx, Handler* h){ If blocked,
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Connector::send(pkt_[fid_idx],h); pkt_[fid_idx] = 0;
}
wait for a call back signal from link_.
51
C I l i• Functions handle() and resume()
C++ ImplementationFunctions handle() and resume()
void PktScheduler::handle(Event*) { resume();}void PktScheduler::handle(Event ) { resume();}void PktScheduler::resume() {
qh_[active_flow_id_]->handle(0); int index = nextID();
qh_
PktScheduler
int index = nextID();blocked_ = 0; if (index >= 0) {
send(index,this); bl k d 1
queue_ queue_ …Polymorphism
blocked_ = 1; active_flow_id_ = index;
}
} ue_[0]
ue_[1]
• The packet has left link
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
que
que• The packet has left link_
• Fetch another packet
52
C I l i• Packet forwarding mechanism
C++ ImplementationPacket forwarding mechanism
classify hCallback
pkt
classify qh_
this
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 53
C I l i• One missing piece
C++ ImplementationOne missing piece How would a PktScheduler select a flow? Class RRScheduler (C++) PktScheduler/RR (OTcl) int RRScheduler::nextID() {
int count = 0; c rrent id ++ c rrent id % MAX FLOWScurrent_id_++; current_id_ %= MAX_FLOWS; while((pkt_[current_id_] == 0)&&(count<MAX_FLOWS)){
current_id_++; current_id_ %= MAX_FLOWS; count++;
}} if (count == MAX_FLOWS)
return -1; else{
return current id ;
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
return current_id_; }
}
54
OT l I l iOTcl Implementation• Class LinkSch derives from Class LinkSch derives from SimpleLink
•
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 55
OT l I l iOTcl Implementation• ConstructorConstructor
Class LinkSch -superclass Link LinkSch instproc init {src dst bw delay num_queues} {
set flow clsfr [new Classifier/Flow] _ _ [ / ]set sch_ [new PktScheduler/RR] set num_queues_ $num_queues $head_ target $flow_clsfr_ for {set i 0} {$i < $num queues } {incr i} { { } { _q _} { } {
set queue_($i) [new Queue/DropTail] $queue_($i) target $sch_ $queue_($i) drop-target $drophead_
} }$sch_ target $link_ $link_ target $ttl_ $ttl_ target [$dst entry] ...
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
}
56
OT l I l iOTcl Implementation• ConstructorConstructor
Class LinkSch -superclass Link LinkSch instproc init {src dst bw delay num_queues} {
set flow clsfr [new Classifier/Flow] _ _ [ / ]set sch_ [new PktScheduler/RR] set num_queues_ $num_queues $head_ target $flow_clsfr_ for {set i 0} {$i < $num queues } {incr i} { { } { _q _} { } {
set queue_($i) [new Queue/DropTail] $queue_($i) target $sch_ $queue_($i) drop-target $drophead_
} }$sch_ target $link_ $link_ target $ttl_ $ttl_ target [$dst entry] ...
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
}
57
OT l I l iOTcl ImplementationSimulator instproc sch-link { n1 n2 bw delay num_queues} {
$self instvar link_ queueMap_ nullAgent_ useasim_ set sid [$n1 id] set did [$n2 id] set link_($sid:$did) [new LinkSch
$n1 $n2 $bw $delay $num_queues] }
Simulator instproc add-flow { n1 n2 prio } { $self instvar link_ set sid [$n1 id] set did [$n2 id] $link_($sid:$did) add-flow $fid
} LinkSch instproc add-flow { fid } { $self instvar queue_ flow_clsfr_ $flow_clsfr_ install $fid
$queue ($fid)
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$queue_($fid)}
58
T l Si l i S iTcl Simulation Script
Agent/TCP TCPSinkFTP
n1 n3LinkSch
TCPSinkAgent/TCPFTP
…… …
SimpleLink SimpleLink
TCPSinkAgent/TCPFTP
n2
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
Q: Do we need a receiving Application? Why? Why not?
59
OT l I l iOTcl Implementation$ns sch-link $n1 $n3 5Mb 2ms 10 f { t i 0} {$i $ } {i i} {for {set i 0} {$i < $num_queues} {incr i} {
$ns add-flow $n1 $n3 $i set tcp($i) [new Agent/TCP]; set sink($i) [new Agent/TCPSink] set ftp($i) [new Application/FTP] $ tt h t $ 1 $t ($i) $ tt h t $ 3 $ i k($i)$ns attach-agent $n1 $tcp($i);$ns attach-agent $n3 $sink($i) $ftp($i) attach-agent $tcp($i);$ns connect $tcp($i) $sink($i) $tcp($i) set fid_ $i $ns at 0.0 "$ftp($i) start"
}}proc show_tcp_seqno {} {
global tcp num_queues for {set i 0} {$i < $num_queues} {incr i} {
puts "The final tcp($i) sequence number isputs The final tcp($i) sequence number is [$tcp($i) set t_seqno_]"
} } $ns at 100.0 "show tcp seqno"
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008.
$ns at 100.0 show_tcp_seqno $ns at 100.1 "$ns halt" $ns run
60
Si l i R lSimulation Results
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 61
OutlineR• Recap
• Automatic Repeat reQuest• Packet Scheduling• SummarySummary
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 62
SSummary• Design and ImplementationDesign and Implementation
– Determine what to doDraw a conceptual view– Draw a conceptual view
– OTcl Main componentsC I t l M h i– C++ Internal Mechanism
• Example– Automatic Repeat reQuest– Packet Scheduling Round Robin
Textbook: T. Issariyakul and E. Hossain, Introduction to Network Simulator NS2, Springer 2008. 63