Professional Documents
Culture Documents
NS PMIPv6 Implementation
Tcl C++
Tcl Object C++ Object Tcl Object C++ Object TclClass Tcl C++ object
set mag [new Agent/PMIPv6/MAG]
NS (1/4)
Tcl: instproc
Classifier/Addr/PMIPv6Dest instproc install {dst target} { $self instvar classifier_ $classifier_ install $dst $target }
NS (2/4)
Tcl C++
Tcl Type , , C++ Object .
NS (3/4)
Tcl C++ : Tcl > C++
Tcl C++ command Tcl : C++ : cmd
Tcl C++
Classifier/Addr/PMIPv6Dest instproc clear { dst } { $self instvar classifier_ $classifier_ clear $dst } Classifier/Addr/PMIPv6Dest instproc clear-by-dest { addr } { $self cmd clear $addr }
NS (4/4)
Tcl C++ (contd)
C++ Tcl
Tcl::eval, Tcl::evalf
Tcl& tcl = Tcl::instance(); tcl.evalf("%s setup-route %ld %ld", name(), bule->mn_prefix(), bule->lmaa());
C++ Tcl
Tcl::result
tcl.evalf ("%s getRXThresh",netif_->name()); RXThreshold_ = atof (tcl.result());
Packet *p = allocpkt(); hdr_cmn *hdrc = HDR_CMN(p); hdr_ip *iph = HDR_IP(p); hdr_pmipv6 *h = HDR_PMIPv6(p); hdrc->size() = IPv6_HEADER_SIZE; hdrc->ptype() = PT_PBU; hdrc->size() += PBU_SIZE; iph->saddr() = proxy_coa; iph->sport() = port();
List List
List
BULEntry *MAGAgent::find_bule(int32_t mn_id) { for(BULEntry *bule=bul_list_.lh_first; bule; bule=bule->next_entry()) { if(bule->mn_id() == mn_id) return bule; } return NULL; }
Timer - Tcl
ns simulator at 1. timeout
Node instproc record {} { set ns [Simulator instance] .. }
2. Timer
Node instproc start { mnaddr } { $self instvar RTimer_ set ns [Simulator instance] set now [$ns now] if {![info exists RTimer_($mnaddr)] || $RTimer_($mnaddr) == ""} { $ns at [expr $now + 1.0] $self record } }
Node instproc stop { mnaddr } { $self instvar RTimer_ set ns [Simulator instance] if {[info exists RTimer_($mnaddr)] && $RTimer_($mnaddr) != ""} { $ns cancel $RTimer_($mnaddr) set Rtimer_($mnaddr) } }
3. timer
resched cancel
bule->BULTimer_.resched(1.0); bule->BULTimer_.cancel ();
General Initialization
Hierarchical routing MN LMA routing
# set up for hierarchical routing (needed for routing over a basestation) $ns node-config -addressType hierarchical AddrParams set domain_num_ 5 ;# domain number AddrParams set cluster_num_ {1 1 1 1 1} AddrParams set nodes_num_ {1 2 1 1 1}
Wireless configuration
# Parameter for wireless nodes set opt(chan) Channel/WirelessChannel ;# channel type set opt(prop) Propagation/TwoRayGround ;# radio-propagation model set opt(netif) Phy/WirelessPhy ;# network interface type set opt(mac) Mac/802_11 ;# MAC type set opt(ifq) Queue/DropTail/PriQueue ;# interface queue type set opt(ll) LL ;# link layer type set opt(ant) Antenna/OmniAntenna ;# antenna model set opt(ifqlen) 50 ;# max packet in ifq set opt(adhocRouting) DSDV ;# routing protocol
set lma [$ns node 1.0.0] #attach Agent/PMIPv6/LMA to the LMA set lma_pm [$lma install-lma] #BE CAREFUL!. PMIPv6 agent must be installed before connecting link(duplex-link) $ns duplex-link $lma $router 100Mb $opt(dfLinkDelay) DropTail
process_new_mn() -find_bule
send_pbu() create_pbu()
send()
setup_route()
bule_state: BUL_S_SETUP
setup_route()
bule_state: BUL_S_DELETE
clear-route/TCL
link->recv()
link->recv()
process_new_mn() -find_bule
send_pbu() create_pbu()
send()
pmip6-agent
int Mac802_11::command(int argc, const char*const* argv) { else if (strcmp(argv[1], "pmip6-agent") == 0) { if(use_pmip6_ext_==0) return TCL_ERROR; pmip6_agent_ = (Agent *)TclObject::lookup(argv[2]); return TCL_OK; }
Link
void Mac802_11::link_disconnect (link_down_reason_t reason) { //PMIPv6 if(!mih_) { //If disconnected, it automatically starts scanning Tcl& tcl = Tcl::instance(); tcl.evalf ("%s autoscan", name()); } //PMIPv6 end
process_new_mn() -find_bule
send_pbu() create_pbu()
send()
process_new_mn
setup_route()
mn_id = h->mn_id(); bce = find_bce(mn_id); if(!bce) { if(h->lifetime()==0) { send_pback(p, 0); return; } if((mnaddr=find_mn_prefix(mn_id))==-1) { send_pback(p, 1); return; } bce = create_bce(mn_id); bce->proxy_coa() = iph->saddr(); bce->mn_prefix() = mnaddr; bce->insert_entry(&bcache_list_); }
bule_state: BUL_S_SETUP
setup_route()
bule_state: BUL_S_DELETE
clear-route/TCL
address classifier