network simulator ns2 mobile networking n.
Skip this Video
Loading SlideShow in 5 Seconds..
Network Simulator(NS2) - Mobile Networking PowerPoint Presentation
Download Presentation
Network Simulator(NS2) - Mobile Networking

Network Simulator(NS2) - Mobile Networking

185 Vues Download Presentation
Télécharger la présentation

Network Simulator(NS2) - Mobile Networking

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Network Simulator(NS2)- Mobile Networking 2006. 5. 17 Sungkyunkwan University UTRI 2006710809 이 규 설

  2. Contents • Mobilenode: creating wireless topology • Creating Node • Network Components in a mobilenode • Different MAC layer protocols for mobile networking • Different types of Routing Agents in mobile networking • Simulation of Mobile Network

  3. The basic wireless model in ns • Various modules were added to ns-2 to simulate node mobility and wireless networking • Mobile Node • Ad-hoc Routing(DSR, DSDV, TORA, AODV) • MAC802.11 • Radio Propagation Model • Channel

  4. Mobilenode: creating wireless topology • The wireless model essentially consists of the MobileNode at the core, with additional supporting features that allows simulations of multi-hop ad-hoc networks, wireless LANs etc • The MobileNode object is a split object • The C++ class MobileNode is derived from parent class Node • Mobility features including node movement • Periodic position updates • Maintaining topology boundary etc. are implemented in C++ • Network components have been implemented in Otcl (classifiers, dmux , LL, Mac, Channel etc)

  5. Mobilenode: creating wireless topology • A MobileNode thus is the basic Node object with added functionalities of a wireless and mobile node • ability to move within a given topology • ability to receive and transmit signals to and from a wireless channel • The four ad-hoc routing protocols that are currently supported are • Destination Sequence Distance Vector (DSDV) • Dynamic Source Routing (DSR) • Temporally ordered Routing Algorithm (TORA) • Adhoc On-demand Distance Vector (AODV)

  6. Mobilenode: creating wireless topology • Location of procedure • ~ns/mobilenode.{cc.h} • ~ns/tcl/lib/ns-mobilenode.tcl • ~ns/tcl/mobility/dsdv.tcl • ~ns/tcl/mobility/dsr.tcl • ~ns/tcl/mobility/tora.tcl • Example of wireless simulation • ~ns/tcl/ex/wireless-test.tcl • ~ns/tcl/ex/wireless.tcl

  7. Creating Node • The primitive to create a mobilenode • set mnode [$opt(rp) –create-mobile-node $id] • $opt() : DSDV, AODV, TORA, DSR, $id=index of mobilenode • Note that the old APIs for creating a mobilenode depended on which routing protocol was used

  8. Creating Node • The API configures for a mobilenode with all the given values of • adhoc-routing protocol, network stack, channel, topography, propagation model, with wired routing turned on or off and tracing turned on or off at different levels (router, mac, agent) $ns_ node-config -adhocRouting $opt(adhocRouting) -llType $opt(ll) -macType $opt(mac) -ifqType $opt(ifq) -ifqLen $opt(ifqlen) -antType $opt(ant) -propInstance [new $opt(prop)] -phyType $opt(netif) -channel [new $opt(chan)] -topoInstance $topo -wiredRouting OFF -agentTrace ON -routerTrace OFF -macTrace OFF

  9. Creating Node • Options for node configuration

  10. Creating Node

  11. Creating Node

  12. Creating Node

  13. Creating Node • Create MobileNode for { set j 0 } { $j < $opt(nn)} {incr j} { set node_($j) [ $ns_ node ] $node_($i) random-motion 0 ;# disable random motion } • opt(nn) : Number of mobilenode • $mobilenode random-motion <0 or 1> • Random-motion is used to turn on random movements for the mobilenode, in which case random destinations are assigned to the node • 0 disables and 1 enables random-motion

  14. Network Components in a mobilenode

  15. Network Components in a mobilenode • Channel Class • Simulates the actual transmission of the packet at the physical layer • The basic Channel Implements a shared medium with support for contention mechanisms • It allows the MAC to carry out • carrier sense, contention, collision detection • Collision flag • If more than one transmissions overlaps in time, a channel raises the flag • By checking this flag, the MAC object can implement collision detection and handling • It schedules the packets to be delivered to the destination MAC objects after the transmission time plus the propagation delay • Implemented in ~ns/mac/channel.{cc,h}

  16. Network Components in a mobilenode • Radio Propagation Models • These models are used to predict the received signal power of each packet • At the physical layer of each wireless node, there is a receiving threshold • When a packet is received, if its signal power is below the receiving threshold, it is marked as error and dropped by the MAC layer • Free space model • The free space propagation model assumes the ideal propagation condition that there is only one clear line-of-sight path between the transmitter and receiver • $ns_ node-config -propType Propagation/FreeSpace • Two-ray ground reflection model • A single line-of-sight path between two mobile nodes is seldom the only means of propation • The two-ray ground reflection model considers both the direct path and a ground reflection path • $ns_ node-config -propType Propagation/TwoRayGround

  17. Network Components in a mobilenode • Link Layer • The LL used by mobilenode is same as described in LAN link layer • The link-layer object is responsible for simulating the data link protocols • The only difference being the link layer for mobilenode, has an ARP module connected to it which resolves all IP to hardware (Mac) address conversions • Normally for all outgoing (into the channel) packets, the packets are handed down to the LL by the Routing Agent • The LL hands down packets to the interface queue • For all incoming packets (out of the channel), the mac layer hands up packets to the LL which is then handed off at the node_entry_ point • Implemented in ~ns/mac/ll.{cc,h} and ~ns/tcl/lan/ns-ll.tcl

  18. Network Components in a mobilenode • ARP(Address Resolution Protocol) • The module receives queries from Link layer • If ARP has the hardware address for destination, it writes it into the mac header of the packet • Otherwise it broadcasts an ARP query, and caches the packet temporarily • For each unknown destination hardware address, there is a buffer for a single packet • Incase additional packets to the same destination is sent to ARP, the earlier buffered packet is dropped • Once the hardware address of a packet’s next hop is known, the packet is inserted into the interface queue • Implemented in ~ns/mac/arp.{cc,h}

  19. Network Components in a mobilenode • Interface Queue • The class PriQueue is implemented as a priority queue which gives priority to routing protocol packets, inserting them at the head of the queue • It supports running a filter overall packets in the queue and removes those with a specified destination address • Implemented in ~ns/queue/priqueue.{cc,h}

  20. Network Components in a mobilenode • Mac Layer • The Mac object simulates the medium access protocols that are necessary in the shared medium environment such as the wireless • Since the sending and receiving mechanisms are tightly coupled in most types of MAC layers, it is essential for the Mac object to be duplex • It uses a RTS/CTS/DATA/ACK pattern for all unicast packets and simply sends out DATA for all broadcast packets • The implementation uses both physical and virtual carrier sense • On the sending side, the Mac object is responsible for adding the MAC header and transmitting the packet onto the channel • On the receiving side, the Mac object asynchronously receives packets from the classifier of the physical layer • After MAC protocol processing, it passes the data packet to the link layer • Implemented in ~ns/mac-802_11.{cc,h}

  21. Network Components in a mobilenode • Network Interfaces • The Network Interphase layer serves as a hardware interface which is used by mobilenode to access the channel • The wireless shared media interface is implemented as class Phy/WirelessPhy • This interface subject to collisions and the radio propagation model receives packets transmitted by other node interfaces to the channel • The interface stamps each transmitted packet with the meta-data related to the transmitting interface like the transmission power, wavelength etc • This meta-data in pkt header is used by the propagation model in receiving network interface to determine if the packet has minimum power to be received and/or captured and/or detected (carrier sense) by the receiving node • The model approximates the DSSS radio interface (LucentWaveLan direct-sequence spread-spectrum) • Implemented in ~ns/mac/phy.{cc.h} and ~ns/mac/wireless-phy.{cc,h}

  22. Network Components in a mobilenode • Antenna • An omni-directional antenna having unity gain is used by mobilenodes • Implemented in ~ns/mobile/antenna.{cc,h}

  23. Different MAC layer protocols for mobile networking • this works is still at a preliminary stage, some practical issues, such as: contention in the preamble phase and time slot reuse in a multi-hop environment are not considered • Currently, ns supports a single hop, preamble-based TDMA MAC protocol • Within the preamble, every node has a dedicated subslot and uses it to broadcast the destination node id of outgoing packet • Other nodes listen in the preamble and record the time slots to receive packets • Like other common TDMA protocols (GSM, for example), each node has a data transmission slot to send packets

  24. Different types of Routing Agents in mobile networking • DSDV • 유선 네트워크에서 사용되고 있는 Bellman-Ford 라우팅 방식에 기초 • Destination Sequence Number를 사용하여 토폴로지변화에 의한 라우팅 루프 방지 • 라우팅 테이블 업데이트방식 • Full dump • 노드 자신이 가진 라우팅 테이블 전체를 다른노드로 브로드 케스팅 • (갱신정보가 많을경우) • Incremental dump • 새롭게 변경된 정보만 브로드 케스팅 • Destination으로부터 route-reply를 받을때 까지 패킷을 캐쉬에 저장 • 최대 버퍼 사이즈만큼 캐쉬후 폐기 • MobileNode로 들어온 모든 패킷들은 address dmux에서 port dmux로 직접 전달 • 모바일 노드에 있는 Routing Agent에 attach하기 위해 포트번호 255 사용 • 패킷에 대한 next hop을 지정후 Link Layer로 내려보냄 • Implemented in ~ns/dsdv/dsdv.{cc, h}

  25. Different types of Routing Agents in mobile networking • DSR • 모든 노드는 루트 캐쉬를 유지 • 루트 탐색 절차와 루트 관리 절차로 이루어짐 • route정보가 존재하지 않을 경우 Route Request(RREQ)를 이웃노드에 브로드 케스팅 하고 Route Reply Packet(RREP)로 응답을 받음 • RREQ를 수신한 중간노드가 route정보를 캐쉬에 가지고 있지 않을경우 자신의 주소를 RREQ에 추가하여 다시 이웃노드에 브로드케스팅 함 • Route상의 링크 오류 발생시 Route Error(RERR) 메시지를 생성하여 source노드로 전달 • RERR을 수신한 노드는 자신의 route 캐쉬에서 오류발생 링크정보를 삭제후 다른 우회 route가 있을경우 이를 이용 • 경로 정보의 관리를 위한 제어 메시지의 브로트캐스팅 오버헤드가 큼 • Implemented in ~ns/dsr/dsragent.{cc, h}

  26. Different types of Routing Agents in mobile networking • TORA • 출발지 노드와 목적지 노드간의 경로는 기본적으로 다중경로를 설정 • 경로 설정을 위한 라우팅 패킷에 의한 overhead 를 최소화하기 위해서 제어 메시지를 토플로지 변화가 비교적 적게 일어나는 어떤 일정크기의 노드의 집합 안에서만 교환 • 각각의 노드들은 바로 이웃 노드들에 대한 라우팅 정보만을 유지 • 제어를 위한 패킷들 • QRY(query) : 경로 설정시 • UPD(update) : 경로 설정과 파티션 발생을 알릴때 • CLR(clear) : 파티션 발생 인지후 파티션 내의 목적지에 대한 정보 삭제시 • Implemented in ~ns/tora/tora.{cc, h}

  27. Different types of Routing Agents in mobile networking • AODV • DSDV와 DSR를 혼합한 형태의 프로토콜 • DSDV의 Hop-by-Hop라우팅, 순차번호, Beacon메커니즘 사용 • DSR과 유사한 경로발견과 경로유지를 사용 • 루트 탐색이 필요한 경우 RREQ 메시지가 생성되어 이웃 노드로 브로드 캐스팅 • 목적지에 도달하기 위해 필요한 홉 수를 포함한 RREP 메시지는 RREQ 메시지가 전달된 루트의 반대 방향으로 유니캐스팅 • 송신 노드에 이요청을 전달하는데 참여하고 있는 모든 노드에서는 목적지까지의 전달경로를 생성하여 결국 송신노드에서 목적지 노드까지의 경로는 전체 노드에 대해서 Hop-by-Hop형태로 생성됨 • Implemented in ~ns/aodv/aodv.{cc, h}

  28. 0 1 TCP/FTP Sink Simulation of Mobile Network(1) • Scenario set node_(0) [$ns_ node] set node_(1) [$ns_ node] $node_(0) set X_ 5.0 $node_(0) set Y_ 2.0 $node_(0) set Z_ 0.0 $node_(1) set X_ 8.0 $node_(1) set Y_ 5.0 $node_(1) set Z_ 0.0 # node(0)과 node(1)이 다음좌표로 이동하기 시작 $ns_ at 3.0 "$node_(1) setdest 50.0 40.0 25.0” $ns_ at 3.0 "$node_(0) setdest 48.0 38.0 5.0” # node(1)이 다음좌표로 다시 이동하기 시작하며 전파거리가 멀어져 drop발생 $ns_ at 20.0 "$node_(1) setdest 490.0 480.0 30.0" # 3.2초부터 ftp를 시작 $ns_ at 3.2 "$ftp start" # 30초에 시뮬레이션 종료 $ns_ at 30.0 "stop" Channel#1 TCP connection Channel#2

  29. Simulation of Mobile Network(1)

  30. Simulation of Mobile Network(2) • AODV 라우팅을 시뮬레이션 할 때 라우팅 테이블의 정보를 확인 할 수있도록 AODV 라우팅 클래스에 맴버함수 rt_show()를 추가 • $NS/aodv/ => 맴버함수 정의를 추가 할 파일 • $NS/aodv/aodv_rtable.h => 정의한 함수 선언 • $NS/aodv/ => 정의한 함수를 호출할 수 있도록 설정할 파일 • 파일 수정후 $NS 디렉토리에서 재 컴파일 수행 • make clean • make

  31. Simulation of Mobile Network(2) • Destination, NextHop, RoutingHop, Expire와 Add, Delete // rt_show()함수 추가 void aodv_rtable::rt_show(nsaddr_t index) { aodv_rt_entry *rt = rthead.lh_first; printf("%lf: %i 's routing table\n", CURRENT_TIME, index); printf("DST \tNHOP \tHOPS\tEXPIRE\n"); for(; rt; rt = rt->rt_link.le_next) { printf("%i\t%i\t%i\t%lf\n", rt->rt_dst, rt->rt_nexthop, rt->rt_hops, rt->rt_expire); } printf("\n"); } //rt_add()와 rt_delete()에 다음라인 추가 printf("%lf: node%i, RT_ADD id = %i\n", CURRENT_TIME, index, id);

  32. Simulation of Mobile Network(2) • 헤더파일에 함수 선언 class aodv_rtable { public: aodv_rtable() { LIST_INIT(&rthead); } aodv_rt_entry* head() { return rthead.lh_first; } aodv_rt_entry* rt_add(nsaddr_t index, nsaddr_t id); void rt_show(nsaddr_t index); <= 추가 void rt_delete(nsaddr_t index, nsaddr_t id); aodv_rt_entry* rt_lookup(nsaddr_t id); private: LIST_HEAD(aodv_rthead, aodv_rt_entry) rthead; };

  33. Simulation of Mobile Network(2) • TCL에서 rt_show를 호출할수 있도록 command 추가 int AODV::command(int argc, const char*const* argv) { if(argc == 2) { Tcl& tcl = Tcl::instance(); if(strncasecmp(argv[1], "id", 2) == 0) { tcl.resultf("%d", index); return TCL_OK; } if(strncasecmp(argv[1], "rt_show", 7) == 0) { <----추가 rtable.rt_show(index); <----추가 return TCL_OK; <----추가 } <----추가 ....

  34. 2 1 0 TCP/FTP Sink Simulation of Mobile Network(2) • Scenario . . . $ns_ at 0.5 "$ftp start“ $ns_ at 1.2 "$ftp stop“ $ns_ at 1.1 "[$node_(0) set ragent_] rt_show" $ns_ at 1.1 "[$node_(1) set ragent_] rt_show" $ns_ at 1.1 "[$node_(2) set ragent_] rt_show“ $ns_ at 50.0 "stop“ . . . TCP connection

  35. Simulation of Mobile Network(2)

  36. Simulation of Mobile Network(2)

  37. THE END