NS2 presentation-AWK+Wireless

download NS2 presentation-AWK+Wireless

of 17

Transcript of NS2 presentation-AWK+Wireless

  • 8/19/2019 NS2 presentation-AWK+Wireless

    1/44

    Presented by,Amritha Sampath

    Department of Computer ScienceRSET

     Traces, AWK and Xgraph

  • 8/19/2019 NS2 presentation-AWK+Wireless

    2/44

     Trace i!es for Wired"et#or$s

    %& Type 'denti(er) Type of E*ent ++) a pac$et en-ueue e*ent

    +-) a pac$et de-ueue e*ent +r ) a pac$et reception e*ent

    +d ) a pac$et drop e*ent +c) a pac$et co!!ision at the .AC !e*e!

    /& Time) at #hich the pac$et tracing string is created&

    0&Source "ode ) denote the 'Ds of the source node ofthe tracing ob1ect&

    2&Destination "ode ) denote the 'Ds of thedestination

    .arch %0, /3%4/ "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    3/44

    5& Pac$et "ame) "ame of the pac$et type4& Pac$et Si6e) Si6e of the pac$et in bytes&7& !ags) A 78digit 9ag string +-) disab!e %st : +E) EC" ;E

  • 8/19/2019 NS2 presentation-AWK+Wireless

    4/44

    AWK (!eBanguage that scans through a (!e !ine by

    !ine

    Data dri*en

    Access any co!umn in the current !ine byusing specia! *ariab!es %, /, 0, etc&

    E'" F print GSTARTG H

    F print HE"D F print GSTIPG H

    .arch %0, /3%42 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    5/44

    Eg& %

    .arch %0, /3%45 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    6/44

    or TCPJLusrLbinLa#$ 8f E'"F

    data:3

    H

     

    F

    if ; %::GrG MM 2::G5G MM 5::GtcpG =F

    data N: 4

    print /,dataO?&3L/L%333333

    H

    H

     E"DF

    Jprint GComp!etedG

    H

    .arch %0, /3%44 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    7/44

    or DPJLusrLbinLa#$ 8f E'"F

    data:3

    H

     

    F

    if ; %::GrG MM 2::G2G MM 5::GcbrG =F

    data N: 4

    print /,dataO?&3L/L%333333

    H

    H

     E"DF

    Jprint GComp!etedG

    H

    .arch %0, /3%47 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    8/44

     To run a#$ scripta#$ 8f  (!ename&a#$Q input(!eQ Q 

    output(!eQ

    .arch %0, /3%4? "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    9/44

    XgraphP!otting purposes&Comes together #ith "S/ insta!!ation

    pac$age&

    Running Xgraph

  • 8/19/2019 NS2 presentation-AWK+Wireless

    10/44

    .arch %0, /3%4%3 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    11/44

    Wire!ess "et#or$s

  • 8/19/2019 NS2 presentation-AWK+Wireless

    12/44

    Adhoc "et#or$sAd8hoc net#or$s are #ire!ess net#or$s

    #here nodes communicate #ith each otherusing mu!ti8hop !in$s&

    "o stationary infrastructure or base stationfor communication&

    Each node itse!f acts as a router forfor#arding and recei*ing pac$ets toLfrom

    other nodes&

    .arch %0, /3%4%/ "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    13/44

    Basic setup

    Create simulator instance

    Eg) set ns ne# Simu!ator

    Open trace fle and activate itEg) set nt open 0nodes&tr #

      ns trace8a!! nt

    Open namtrace fle and activate it

    Eg) set nm open 0nodes&nam #

      ns namtrace8a!!8#ire!ess nm /33 /33

    .arch %0, /3%4%0 "S/ Wor$shop

    $ namtrace-all-wireless $

  • 8/19/2019 NS2 presentation-AWK+Wireless

    14/44

    Create topography :

    set [new Topography]$ load_fatgrid

    Eg) set topo ne# Topography  topo !oad9atgrid /33 /33

    Create the GOD object (General OperationsDirector:

    create!god

    Eg) create8god *a!;nn=

    .arch %0, /3%4%2 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    15/44

    Simu!ation of Adhoc"et#or$s "peci#y components o# the mobile node:

    set *a!;chan= Channe!LWire!essChanne! UJ channe! type

    set *a!;prop= PropagationLT#oRayround UJ radio8propagation mode!

    set *a!;ant= AntennaLImniAntenna UJ Antenna type

    set *a!;!!= BB UJ Bin$ !ayer typeset *a!;if-= VueueLDropTai!LPriVueue UJ 'nterface -ueue

    typeset *a!;if-!en= 53 UJ ma< pac$et in

    if-

    set *a!;netif= PhyLWire!essPhy UJ net#or$interface type

    set *a!;mac= .acL?3/%% UJ .AC typeset *a!;rp= DSD UJ ad8hoc routing

    protoco!

    set *a!;nn= / UJ number ofmobi!enodes

    .arch %0, /3%4%5 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    16/44

    Confguration o# themobile nodes

    $ node-cong ! $

    option/Q*a!ue/Q Y

    ...

      ...

      ...

    optionnQ*a!uenQ

    .arch %0, /3%4%4 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    17/44

    Eg)

    ns node8con(g 8adhocRouting *a!;rp= Y

    8!!Type *a!;!!= Y8macType *a!;mac= Y8if-Type *a!;if-= Y

    8if-Ben *a!;if-!en= Y8antType *a!;ant= Y

    8propType *a!;prop= Y8phyType *a!;netif= Y

    8topo'nstance topo Y8channe! chan Y

    8agentTrace I"Y8routerTrace I"Y8macTrace I"Y

    8mo*ementTrace I"

    .arch %0, /3%4%7 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    18/44

    inish Procedure

    proc % &%

    global

    $fush-trace

    close $e

  • 8/19/2019 NS2 presentation-AWK+Wireless

    19/44

    Creating the nodesAfter setting the con(guration options, the nodes

    are created

    set [' node]

    (g) set n3 ns node

    Enab!eLdisab!e random motion

    $

  • 8/19/2019 NS2 presentation-AWK+Wireless

    20/44

    "etting node si'e

    ' initial_node_pos' Eg) ns initia!nodepos n3 %3

    "etting initial position

    ' set _

    ' set ._

    ' set /_ ,Eg) n3 set X 3&3

      n3 set Z 3&3

      n3 set [ 3&3

    .arch %0, /3%4/3 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    21/44

    "etting node positions

    $ at 0' setdest 0

    Eg) ns at 3&3 +n% setdest %@5&3 %@5&3

    /33&3

    .arch %0, /3%4"S/ Wor$shop/%

  • 8/19/2019 NS2 presentation-AWK+Wireless

    22/44

    Eg& %Create a scenario #ith 2 nodes #ith

    random motion

    Set up TCP 9o# from node 3 to node 0

    Set up DP 9o# from node % to node 0

    .arch %0, /3%4"S/ Wor$shop//

  • 8/19/2019 NS2 presentation-AWK+Wireless

    23/44

    ")* +: Defne all mobilenode modules

    set *a!;chan%= Channe!LWire!essChanne!set *a!;prop%= PropagationLT#oRayroundset *a!;netif= PhyLWire!essPhy

    set *a!;mac= .acL?3/%%set *a!;if-= VueueLDropTai!LPriVueueset *a!;!!= BBset *a!;ant= AntennaLImniAntenna

    set *a!;if-!en= 53set *a!;nn= 2set *a!;rp= DSD

    .arch %0, /3%4/0 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    24/44

    ")* ,: Create simulatorobject

    set ns ne# Simu!ator

    .arch %0, /3%4/2 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    25/44

    ")* -: "etup race .ile

    set nt open throughput&tr #

    ns trace8a!! nt

    set nm open throughput&nam #

    ns namtrace8a!!8#ire!ess nm 033 033

    .arch %0, /3%4/5 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    26/44

    ")* /: Createopography

    set topo ne# Topography

    topo !oad9atgrid 033 033

    .arch %0, /3%4/4 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    27/44

    ")* 0: Create Object God

    create8god *a!;nn=

    .arch %0, /3%4/7 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    28/44

    ")* 1: Confgure nodesns node8con(g 8adhocRouting *a!;rp=Y

    8!!Type *a!;!!=Y8macType *a!;mac=Y8if-Type *a!;if-=Y8if-Ben *a!;if-!en=Y

    8antType *a!;ant=Y8propType *a!;prop%=Y8phyType *a!;netif=Y8channe!Type *a!;chan%=Y8topo'nstance topoY8agentTrace I"Y

    8routerTrace I"Y8macTrace I"Y8mo*ementTrace I"

    .arch %0, /3%4/? "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    29/44

    ")* 2: 3rite a fnishprocedure

    proc (nish FH F

    g!oba! nt nm ns

    ns 9ush8tracec!ose nt

    c!ose nm

    e

  • 8/19/2019 NS2 presentation-AWK+Wireless

    30/44

    STEP ?) Create nodes and startrandom motionset n3 ns nodeset n% ns nodeset n/ ns nodeset n0 ns noden3 random8motion %n% random8motion %

    n/ random8motion %n0 random8motion %n3 startn% startn/ startn0 start

    ns initia!nodepos n3 %3ns initia!nodepos n% %3ns initia!nodepos n/ %3ns initia!nodepos n0 %3

    .arch %0, /3%403 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    31/44

    STEP @) Setup tra\c 9o#

    set tcp3 ne# AgentLTCPns attach8agent n3 tcp3set sin$% ne# AgentLTCPSin$ns attach8agent n0 sin$%set ftp3 ne# App!icationLTPftp3 attach8agent tcp3ns connect tcp3 sin$%

    set udp% ne# AgentLDPns attach8agent n% udp%

    set sin$/ ne# AgentL"u!!ns attach8agent n0 sin$/set cbr% ne# App!icationLTra\cLCRcbr% attach8agent udp%ns connect udp% sin$/

    .arch %0, /3%40% "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    32/44

    STEP %3) Set Stop Time andStart Simu!ation

    ns at %&3 Gftp3 startGns at %&3 Gcbr% startG

    ns at %75&3 Gftp3 stopG

    ns at %75&3 Gcbr% stopG

    ns at %?3&% G(nishGns run

    .arch %0, /3%40/ "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    33/44

    Eg& /

    Node Time Position

     Node0 0 05 05

     Node1 0 195 195

     Node2 0 195 05

     Node1 40 30 30

     Node1 80 195 195

     Node2 90 175 50

    .arch %0, /3%400 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    34/44

    ProcedureDe(ne a!! mobi!e node modu!esCreate simu!ator ob1ectSetup Trace i!eCreate Topography of si6e /33

  • 8/19/2019 NS2 presentation-AWK+Wireless

    35/44

    Con(gure 'nitia! Positionn3 set X 5&3n3 set Z 5&3n3 set [ 3&3 

    n% set X %@5&3n% set Z %@5&3n% set [ 3&3 

    n/ set X %@5&3n/ set Z 5&3n/ set [ 3&3

    .arch %0, /3%4"S/ Wor$shop05

  • 8/19/2019 NS2 presentation-AWK+Wireless

    36/44

    "ode mo*ement ns at 3&3 Gn3 setdest 5&3 /@5&3 /33&3G ns at 3&3 Gn% setdest 5&3 5&3 /33&3G ns at 3&3 Gn/ setdest %53&3 %53&3 /33&3G ns at 3&3 Gn0 setdest /@5&3 %53&3 /33&3G ns at %&3 Gftp3 startG ns at %&3 Gcbr% startG ns at 23&3 Gn/ setdest %53&3 5&3 %5&3G ns at ?3&3 Gn/ setdest %53&3 /@5&3 %5&3G ns at %/3&3 Gn/ setdest %53&3 %53&3 %5&3G ns at %73&3 Gn3 resetG ns at %73&3 Gn% resetG

    ns at %73&3 Gn/ resetG ns at %73&3 Gn0 resetG ns at %75&3 Gftp3 stopG ns at %75&3 Gcbr% stopG ns at %?3&% G(nishG

    .arch %0, /3%4"S/ Wor$shop04

  • 8/19/2019 NS2 presentation-AWK+Wireless

    37/44

     Trace (!e for Wire!ess"et#or$s+4 5C6O7: 8s9r9D9#:

    +4 s ! sent,4 r ! received-4 D ! dropped/4 # ! #or;arded

    ,4 3)7: the time ;hen the action happened-4 3)=): the node ;here the action happened/4 >5?)=:

    +4 5G ! application,4 == ! routing-4 >> ! lin@ layer/4 6.A ! outgoing pac@et ueue (bet;een lin@ and

    mac layer04 5C ! mac14 *? ! physical

    .arch %0, /3%407 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    38/44

    04 ags:14 ")A7O: the seuence number o# the pac@et24 ?*): the pac@et type

    +4 cbr !! CB= data stream pac@et,4 D"= !! D"= routing pac@et (control pac@et

    generated by routing-4 =" !! =" pac@et generated by 5C EF,4++/4 5=* !! lin@ layer 5=*(5ddress =esolution

    *rotocol pac@et

    E4 "6): the si'e o# pac@etH4 8a b c d:

    +4 a !! the pac@et duration in mac layer header,4 b !! the mac address o# destination-4 c !! the mac address o# source/4 d !! the mac type o# the pac@et body

    .arch %0, /3%40? "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    39/44

    +F4ags:++48444444: 8

    +4 source node ip : port%number

    ,4 destination node ip (!+ means

    broadcast : port%number

    -4 ip header ttl

    /4 ip o# neIt hop (F means node F orbroadcast

    .arch %0, /3%40@ "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    40/44

    Eg& 0

    Node Time Position

     Node0 0 05 295

     Node1 0 05 05

     Node2 0 150 150

     Node3 0 295 150

     Node2 40 150 05

     Node2 80 150 295

     Node2 120 150 150

    .arch %0, /3%423 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    41/44

    A#$ script for ThroughputCa!cu!ation

    JLusrLbinLa#$ 8f  E'"F Jprint GThroughput ca!cu!ationG data:3 H   F

    if ; %::GrG MM 0::G0G MM 7::GtcpG MM 2::G.ACG= F data N: ? print /,dataO?&3L/L%333333 H H

      E"DF Jprint GComp!etedG H

    .arch %0, /3%42% "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    42/44

    Xgraph

    .arch %0, /3%42/ "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    43/44

    Conc!usion

    Discussed Trace (!e formats for #ired and#ire!ess net#or$s

    Discussed AWK (!es and Xgraph

    enerated graph for throughput ca!cu!ationfor #ired net#or$s

     TCB script for #ire!ess net#or$s

    enerated graph for throughput ca!cu!ation

    for #ired net#or$s

    .arch %0, /3%420 "S/ Wor$shop

  • 8/19/2019 NS2 presentation-AWK+Wireless

    44/44