TELKOM NIKA , Vol.11, No .1, Janua ry 2013, pp. 103 ~11 4   ISSN: 2302-4 046           103     Re cei v ed Se ptem ber 28, 2012; Revi se d No vem ber  22, 2012; Accepted Novem ber 29, 20 12   Hardwa re-in-the-loop and Parallel Simulation  Architecture for Wireless Sensor Network      Shihong Du an*, Yadong  Wan, Peng  Meng, Qin Wang   Schoo l of Com puter & Comm unic a tion E ngi neer ing   No 30  Xu e y u a n  Roa d , Hai d ia n District, Beiji ng, 137 01 32 31 76/   *corres pon di ng  author, e-mai l : duans h@ust b .edu.cn       A b st r a ct   Discrete  event -base d  si mu lat i on  is co mmo n ly us ed to  e v alu a te res ear ch on  W i rel e s s  Senso r   Netw orks (W SNs). How e ver, highly acc u ra te simu latio n  mo de ls are re quir ed in rec e nt advanc es o n   w i reless co mmu n ic ation  tec hno logy, w h ic h resu lts i n  a  steep  incr ea se in  si mu lati on c o mpl e xity  an d   runti m e. T h e c ontrib u tions  of  this p a p e r for t he  are tw ofol d, on e is  to  pres ent a   g ener al  l a yer structur e f o r   hardw are- in-th e -lo op e m ulati on a nd W S N s i mulati on  e m b edd ed w i th i m ple m entatio n o f  mod e ls, suc h  as   ener gy mod e and l i nk  mo de,  to introd uce th e distrib u t ed  n odes i n to the s i mulati on fra m ew ork; the oth e r is   to buil d  a p a ra llel i z e d s i mul a tion b a se d on  mu lti-pr oc esso r computers a s  the  de-facto defau lt  hardw a r e   platfor m  a nd  p o w e rful priv ate  computi ng cl u s ters to mi rr or  the rea l  W S N  mor e  cl osely.  T he w o rk in t h is  pap er is rea l i z e d  an d use d  to simu late i ndustri a l W S N s  for describi ng an d verifyi ng the d e tail  an d   meth od olo g y o f  W S Ns.     Key w ords : E v ent-ba s ed  si m u lation, hardwa r e - in-th e -l oop em ulatio n, paralleli zati on, energy  m odel, link model      Copyrig h ©  2013  Univer sitas Ahmad  Dahlan. All rights res e rv ed.       1. Introduc tion  The mo del s in sim u latio n  of wi rele ss sen s o r  net works b e co me mo re  co mplex to   accurately describ e wirel e ss cha nnel  cha r a c teri stics, node s’ op eration a nd the pro pertie s  of  transmissio techn o logie s ,  whi c h typi cally lead  to   a high  comp utational lo a d  an d exten s ive   simulation runtimes. Also, the pr actical wirel e ss sensor  net work  of  large  scalbilit y includes m o re  than 100 0 no des, a s  obje c ts in simulatio n , to consum e con s id era b l e  memory an d CPU time. So  redu cin g  ru ntimes with b u il ding inten s iv e node mo del  and enviorm ent model in  simulatio n  is the   key issue of this pa per.   Curre n tly, wireless  sen s o r   netwo rk  sim u lation tool s a r e divide d int o  proto c ol  si mulator   and p r og ram  cod e  sim u lat o r. The fo rme r  is rep r e s ent ed by OM Net ++, OP NET a nd NS -2, whi c norm a lly defines the p r ot ocol  stack in  a node  an d  emulates th e data tran smissi on in th e   netwo rk. T h e  latter is  rep r ese n ted by T O SSIM,  which de scribe operation s  of  singl e nod in   high-preci s io n to accurate ly imitate applicatio n beh aviors of no d e s. The featu r es of fre que ntly  use d  si mulati on tool s a r e l i sted in t able  1. Co m p a r at ively spea kin g , OMNet++, whi c h i s  o p e n - sou r ce suit for  larger-scale   net wo rk simulation, sup port s  sim u lating network p r oto c ol  and  debu gging  code. So  sim u lation tool in this p ape r are  develo p ed ba se d on  OMNet++ a nd  extended  with model s and  layed archite c ture of n ode  and net work.       Table 1. The  Comp aration   of Simulation Tools  T ools Accur a cy   of  net w o rk   Accur a cy  of  node   Simulation  scale   Channel  model  Energ y   model  Obj e c t - oriented   Application   OMNet+ + [1 ]   High  Lo Larger   Simple  Simple   Y e s   Protocol and  debugging   OP Net [2 ]  High  Lo Larger   Simple  Simple  Y e s   Protocol  NS2 [3]  High  Lo Large   Simple  Functional  Y e s   Protocol  SENSE [4]  High  Lo Large   Non   Functional  Y e s   Protocol  TO SSIM [5 ]  Lo High  Large   Non    Functional  No  Debugging       Evaluation Warning : The document was created with Spire.PDF for Python.
                          ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 1, Janua ry 2013 :  103 – 1 1 4   104 We mak e  the following four c ont ributions  in this  paper:  1) We p r o p o s e a set of gene ric  simu lation ar chite c ture to defi ne nod es an d WSN. Lay ed  stru cture i s   reali z ed   wi th indep end ent  compo n ents  coo p e r ated with  e a ch  othe r b y   messagi ng a nd sh arin g da ta in bulletin board.  2) Lin k  relia bility model from indu stri a l  env iorment  and energy model are i n tegre a ted in to  s i mulation framework  to verify the effic i ency of WSN t e ch nolo g ies  more  cre d ible ly.  3) A mappin g  sch eme is  a pplied to buil d  up hardwar e-in -the-l oop  emulation, in  whi c h re al no des  sen d  op erati ng pa ram e ters to  simulatio n  platform  via data  colle ction network  and  wo rk  a s   virtual com p o nents in  simul a tion.   4) A parallel  architectu re  deployed in  multi-co re comp uter with  cent rali zed   sch eduli ng is  prop osed to simulate larger WSNs with l a yer topolo g y and more than 100 0 nod e s Also, we u s e   the said  platform to  si mula te a typical in dustri a l a ppli c ation  compli ant with   WIA-PA standard.  Our ev aluation sh ows the  correctness  and availability  of si mulation platform,  and  p a rallel simulatio n   a nd  ha rd wa re -in-th e-lo op emualtion   im prove perfo rmance with less  runni ng time  and large r  scale WSNs  ov er traditio nal  scheme.   The rem a ind e r of this pap er is st ru ctured as follo ws. Section 2 gives a introd u c tion to   our  simul a tio n  fram e work a s   solutio n  of less  ca p a city and  mo re  runni ng ti me of tra d itional  simulatio n  te chni que and  detaile desi gn a n d  re alization of  archit ecture, mo del s, ha rd wa re -i n- the-loo p  emu a ltion sy stem  and pa rall el simulati o n  sy stem. Sectio n 3 analy z e s  synchro n ization   scheme  in te rms  of  the  gran ula r ity of the pa ralleli sm a nd  simu lation time, verify the mo del   accuracy a n d  evaluate s  the e f f e ct iv ene ss  by  a n  sim u lat i on   instan ce of  indu strial WSN  appli c ation. F i nally, we co n c lud e  in Secti on 4.      2. Rese arch  Metho d   This sectio n introdu ce s th e fundame n tals of our  si mulation fra m ewo r k PIWSNSim and   its unde rlyin g  model re alizatio n, function co mpo nent mappi n g  tactics an d parall e lization  scheme. PIWSNSim en able s  a par a llel execution  of network simulatio n  model s to red u ce   runni ng time  by means of  three p r op erti es: 1) It  intro duces a laye d stru cture to easily de scri be   node, net work and e n viorment. 2) It de ne s a mappin g  sche me from re a l  node to vitual  comp one nt in  simulatio n  to  reali z e a h a rdwa re -in-th e-l oop em ualtio n , even co de  debu gging. 3 )  It  employs a p a ralleli zatio n  scheme to e x ecute  ind e p ende nt simul a tion events  simultan eou sl y,  control by ce ntralized sch edule r . PIWSNSim enabl e s  a credibl e simulation by building u p  more   accurate link  realibility mod e ls an d ene rg y models of n ode an d network.     2.1. Time-v ar y i ng Link Reliabilit y  Mod e l in PIWSNSim   Many in dust r i a l WS Ns d e p loyment i s   unde rway no wad a ys to  al low th e e ngi neers to  reliably  acqui re a nd  co ntro l the r eal -time  data  of WS Ns in  the fa ct ory at any time  anywh ere.  Th noise and i n terferen ce s are  signifi cant due to   the wid e  op erating te mp eratu r e s , strong  vibration s , airborn e  conta m inants, ex cessive ele c tromagn etic n o i se  cau s e d  b y  large m o tors etc.  Therefore, it  is im porta nt for a  si mulati on fra m ewo r k to  playba ck  ch ara c teri stics of  comm uni cati on ch ann el in orde r to verify the te chn o logy and o p t imize the de sign of ind u st rial  WSNs. IEEE  802.15.4 based WSNs are designed to  support com m unication over short ranges  with low data rate and redu ced  energy consumpt ion. So  the IEEE 802.15. 4 standard  has  become a  re cog n ized ind u stry sta nda rd and  well a c cepted by i ndu strial u s e r s. [6] mea s u r ed   channel characteri stics  of sixt een IEEE802.15.4  radi o ch annel s in typical i ndustrial environm ent.  It is found tha t  chann el reli ability is possibly and dr a m atically different with ea ch  other an d no ne   of the  channels can  al ways pr ovide good  reli ability required  by i ndustry appli c ation.  Furthe rmo r e,  reliability of each  cha nnel  varies  with time and spa c e.  Defini tion 1 .  PDS, Packet Drop Seq u ence, is the log of the succe ss o r  failure in one   time-sl o t com m unication  b a se d on  ACK  re ceived  or   not, sh own a s  Eq. 1,  wh erein i d enote s   the   ith transmi ssion. PDI, Packet dro p   interval, is the time gap betwee n  two adja c e n t lost packet s  to  define the PDS distributio n.      (1)     0 () 1 recei ved A C K PDS i ot h e r s Evaluation Warning : The document was created with Spire.PDF for Python.
TEL K   H a A CK  j+N- 1 and  N perio se ct i o PDI i Figu r     ( a sho w large trans K OM NIKA    a rdware- i n- t h Defini tio identified b y 1 , sh own  as  N umACK  is  r     From te s ds of (ti,t j ]   w o n R1 ~R25  w s defin e d  in  r e 1(a ) . Also    a ) u a nd  σ  v a PIWSNS w with a n  i n ly implemen t     MiXim fr a mission. Th e N PD R h e-lo op an P n 2.   PDR,  P y  the send er  Eq. 2, wher e r e c eived A C K s t-be d mea s w ith diffe re nt  w ith val u e [1 Eq. 3, whe r the PDI di st r a lue from m e Figure  1 im as a sim u n dep ende nt  s t ed in “pu r e”  Figure 2 a mework pr o e  Analogu e M N um Packet NumP a c I S P arallel Sim u P acket Drop  in the log wi n e in Number p K  numb e rs. s urem ent,  P p r op er ty p a -4%], [5-8% ] r e u  an σ  h a r ibutio n cu rv e e asu r em en t   1 . Time-vary i ( e xpress e d u lation fram e s truc ture na OMNe T + + ;   . Time-varyi n o v i de s ch an n M odel s are r e 1 Num A CK c ket S SN: 2302-4 0 u lation Archi t Ratio is  th e n do w  o f  T  in p acket is the  P DI follows  ram e ter s  b a ] , … , [97-1 0 a ve differen t e  is shown  a (b)  P D   i n g  mo del in  d  in  PDR, P D     e work  for  W S med a s  EIF but also  su c   n g ink  mode     n el mo del to  e spon sibl e f o 1 00% 0 46 t ecture for  W e  indicato r o f   clu d ing N tr a total sendin g sa me d i st ri b sed  on P D R 0 0%], and p r t  value in di f a s Figu re 1( b D I probabilit y indu stri al a p D I, and PDS) S Ns buil d s t h s h ow n  as   F c cessfully in c l of EIF in PI filter and p r o r sim u latin g W i r el ess Sen s f los t  packet s a nsmi ssion  n g  numbe r  o f   b utio n of  lo g R  value.  PD R obability de n f ferent PDR  b ).   y  density  dis t p pli c ation   h e sai d  time- v F igure 2. EI F c orpo rate d in   WSNSim   r oce s s si gn a g  the  attenu a   s or …  (Shih o s  numb ers  w n umbe red fr o f WSN  in T  p g normal i n   R  i s  divided i n n sit y  dist rib u t s e ct ion s  sh o t ribution in  R v arying link  F  can be n o to the MiXi M a l in phy si ca l a tio n  of a re c o ng D)  105 w ithout  o m j to  p erio d,  (2)   som e   n to 25   t io n of  o wn in   (3)     R 1-R7   m od el  o t only  M [7] .   l  layer  c eiv ed  Evaluation Warning : The document was created with Spire.PDF for Python.
                          ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 1, Janua ry 2013 :  103 – 1 1 4   106 sign al, su ch  as  shad owi n g, fading an d  path loss . T he De cid e rs  are respon si ble for  classif y in g   the sign al as noise o r  si g nal, and calculating bi t error of the re ceived messa ges. Reliabilit y of  cha nnel  in  80 2.15.4 b a sed  indu strial   WSNs varie s   wi th time d ue t o  all  kin d s of  factors,  su ch  as  multi-path  int e rferen ce,  wi rele ss  radio  i n terferen ce a nd so on.   Ti me-varyin g  chara c te risti c  o f   cha nnel  ca n  be exp r e s sed a s  o scill a t ions in  sh ort perio d an d  mutation  when  some  e v en happ en s in i ndu strial field s . By fit test usin g dfittool  in Matlab, o s cillation i n  small win d o w   and   interval b e tween t w eve n ts all  follo w the lo g-lo gi stic dist ributi on with  diffe rent paramet ers;  Proba bility density dist rib u tion of affected cha nnel  numbe rs and  affected con t inuou s freq u ency  cha nnel nu m ber a r e all ke ep to the log norm a l distri b u tion with different pa ram e ter values. EIF is  respon sibl e for sim u lating  the sign al loss in ty pical m e tallurgy p r o c ess indu strial  appli c ation s .   EIF provide s   a se parate si mple mo dule  nam ed  as In dustri a lChan nelControl to  descri b e   the loss rate  of 16 freq ue ncy chan nels. Indus trial C h annel Cont rol  posse sse s  th e scala b le a nd  extensibl e  mech ani sm.   1)  The  op erat ion p a ramete rs can  be  con f igur ed. The  para m eters a r e provid ed in  the xml  file, and the   xml file nam e is spe c ified  in the  sim u l a tion  configu r ation. So  u s ers a r easy  to   adju s t para m eters a c co rdi ng to cha nnel  characte ri stic in diverse p r acti cal ap plications.    2) T h e  mod e l can  be  re placeable.  Currently,  test  from  thre typical in du stry field s   introdu ce s th e idust r ialCha nnel Control which  will be e x pande d, imp r oved o r  sub s tituted for mo re   indu stry environm ent. Industrial C h ann elCo ntrol  in  essen c e i s  a  c++cl a ss; other mo del s ca n   derive from it.  Industrial lin k model n a m e  is han ded o v er  to the ph ysical laye r,   so it is easy  for   physi cal layer can make decisi on which link model it calls.     2.2. La y e d A r chitec tur e  o f  PIWSNSim  PIWSNSim is desig ned to  descri be el e m ents  in  WS N, inclu d ing  n ode s, enviorment, and  manag eme n t units. Layed  simulation a r chite c tu re is employed to  simulate  WSN in detail  and  reality by cle a rly definin element s in  WSN  with   mo dular mode. Shown as Fig u re  3,  PIWS NSim  based o n  O MMet++ platf o rm e m pha si ze s the im po rtance of e n vironm ental m odelin g and   node  modelin g. Fo ur laye stru cture  com b ine s  n ode s i n  re sou r ce laye with  wirel e ss  medium  defin ed   in media lay e r un der th e  regul atory u n its in man a ger laye r to  simulate th WSN a ppli c a t io n   meticulo usly,  and the n e twork o p e r ation and  pe rf o r man c anal ysis a r e exhi bited to user by  friendly G U I l a yer. PIWSNSim use s   discrete   event h andlin g me ch anism  provid ed by OM Net ++,   manag es eve n t queue p u shed by com p onent s of WS N and di strib u tes event s to CPU  kernel   PIWSNSim i n  this p ape is re alized a s   a comp osit model defi ned  in OMNet++ and  calle d by Sim kernel. Th e comp one nts in lay ed st ructu r e a r e i ndep ent and  can be e a sily  repla c e d  an d  updated to  help researchers e s tabli s h WSN  simul a tion for  spe c ific a pplications,   and a nalyze  techn o logy a nd alg o rithm  for their con c ern. Th e lay ed a r chitectu re em ployed  in  PIWSNSim a r e na rrate d a s  follows.   1)  Re sou r ce l a yer in clu d e s  all n ode s i n  t he n e two r k.  Nod e s are d e f ined a s   hiera r chi c al  st ru ct ure  to supp ort de scription of isom orphi sm a nd heteroge n eou s nod es.   2) Me dia lay e r in clu des  modelin g wi reless tr an smi ssi on cha nne and sam p lin ch aracte rist ics.  Link reli ability model  de scri bed i n   se ctio n 2.1 i s   reali z ed a s   wirele ss lin k m odel  i n  medi a laye to  accu rately analyze WSN  tech nology.S ensi ng  m odel  with  sam p lin g envio rment  model  are  use d  to simul a te sen s in g p r ocess an d chara c te risti c s of system on  test.    3) Ma nage m ent layer ta ke s re sp on sibilit y of setting th e network pro pertie s  an d b u ilding  WSN to   sup port self-formation an self-maint enan ce  of  WSN, in clu d i ng ma nag e m ent unit s   of  topology, syn c hroni zation,  con n e c ti on, secu rity sche me, informati on logg er to  make it ea sie r   to do re sea r ch on relate d tech nolo g ies  of improving  WSN p e rfo r m ance.   4)  GUI l a yer provides u s ers  with frie n d ly gr aphi cal  interfa c e  an d repla c e  or  extend  wind o w interface p r o v ided by O M Net++.   Net w ork  co nfigu r ation, o n line  or  offline a nalysi s  an d   forecastin g o f  simulation  data are re al ized in  GUI l a yer. GUI a p p licatio n ca n  be not only  calle d by sim  kernel, but a l so can run a l one to  re ad/ write  configu r ation file and  sele ct data   from datab ase to give performa n ce enh ancement rep o rt.   Nod e s in PIWSNSim plat form sh ould  have sa m e  functio n  with real no de to sampl e comp ute and  commu nicati on. So simul a tion node ar e supp osed  to have a clear fram ework to     sup port chan ge or control of the network topolo g y and desgin algo rithm. A stack structu r e fo r a   node i s  pro p o se d in this  pape r sh own  in Figure 4 ( a) . Nod e  wit h  stack st ructure co nsi s ts of  a   numbe of dif f erent fu nctio n  sta c ks that  are  de ri ved from the same template s t ac k .   Func tions of  comm uni cati ng, sam p ling,  energy man aging a nd p o sitioni ng are  respe c tively implemente d  in   Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046       Hardware-in - t he-lo op an d Parallel Sim u lation Architecture for Wi rel e ss Sensor  … (Shiho ng  D)  107 spe c ific  stack. The highe st  level of each stack i s  a share d  ap plica t ion layer. Stack structu r e  in  this pa pe r b r i ngs th e b ene fits of the n e twork  pr oto c ol  sta ck i n to d e scribi ng  rela ted key ta sks,  su ch a s  co de  reuse, stand ardi zation e n han cment an d interchan ge able protocol desi gn.           Figure 3.  The Layed archi t ecture  of PIWSNSim                   (a) Ba se tem p late sta ck               (b) Thre e-tier-a rchitecture of virtual node      Figure 4. Virtual nod e defi ned in PIWS NSim     Evaluation Warning : The document was created with Spire.PDF for Python.
                          ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 1, Janua ry 2013 :  103 – 1 1 4   108   The virtual n ode in PIWSNSim is a co mposit com pone nt class  written in c++ code to  s i mu la te   w o rk  pr oc es s   o f  r e a l   s e ns or  no d e s  w i th th e  embed ded  software. Al so  the virtual n ode   is a  compl e x module i n   OMNet + + environment. In  order to facilitate the im plementation of  different  sim u lation  sen a ri o and  switch  betwe en  different fu nctio n s, the vi rtua l node  ad opt s a  three - tier-architecture a r chitecture pa rt itioned  by h a rd wa re reso uce s  a nd  so ftware fun c ti on,  sho w n in Fig u re 4 ( b), in clu d ing layer of functio n , man ageme n t and  resou r ce.   Re sou r ce lay e r i s  respon si ble for esta bli s hin g  mo del s of nod e ha rd ware resou r ces a nd  descri b ing th e state ch an ge of hard w are res ource s and en erg y  consumptio n. The com m on  hard w a r e  co mpone nts include  a p o wer su pply m o d u le  whi c h i s   norm a lly a  b a ttery mod u l e , a  stora ge u n it, a CPU, seve ral sen s ing in terface s  a nd  several RF  module s . Th e battery mo dule  provide s   dischargi ng m o d e l of  some  ba ttery and  re cord s the  cha nge  of the  wo rkin state of  the  battery by p o we ring to  o t her resource  membe r s.  RF mo dule i m pleme n ts  si gnal tra n scei ver  function. T r a n smi ssi on  sig nal attenu ate s  in a c co rdan ce  with the ti me-varyin g  m odel d e fined  by  radio  ch anne l and be  sen t  to the RF module  of  target node via  a wirel e ss chann el. Sensing   interface  sen d  sa mple  m e ssag es to  sensi ng p h ysi c al  cha nnel.  It simulate s the colle ction  of  physi cal information ba se d on the model defined  b y  sensin g ph ysical  chan n e l and gen erates  the cha r a c teri stical  sampl e  data.   Manag eme n t layer take s re spo n si bil i ty to coord i nate the work  of the variou comp one nts i n  a virtual no de for the sp ecified a ppli c ation tasks.  Manag eme n t module s  re al ized   in PIWSNSi m  incl ude energy man ageme n t, mobile ma nag ement, data  mana geme n t an d   colla boration  mana geme n t. Collab o ra tion mana ge ment provide s  a b u lletin  board to  whi c h   variou s co mp onent s in no de co uld re gi ster me ss ag e type respo nded by theirsleve s. Speci f ic  messag e will  be issu ed b y  source co mpone nt to bulltin board, and then be  transfe re d to the   comp one nts that sub s cribe the  me ssag e, fi nally  the  comp o nents exe c ut e the  re spo n se   operation. Bu lletin board m odule p r ovide s  a unified in t e rface for different tasks to  use re so urce s.  Energy ma na gement u n it monitor  and a nalyze e n e r g y  to suppo rt the sim u lation  of energy-a ware   strategy. M o bility manag e m ent defin es a large  num ber  of mobil e  model, virutal nod e movi ng   according to  spe c ified m o bility model regula r ly  and  notify conne ction mana ge ment modul to re- establi s h the  netwo rk  co nn ectivity and update the  top o logy ba sed  on the cove rage attrib ute of  the node ra dio frequ en cy module. Data manag e m ent establi s he s data st orag e and f u sion   model, provid ing mana gem ent strate gi es for related a pplication s .   Nod e  fun c tio n  is  re spo n si ble to d e fine  node  ope ratio n  and  sim u lat e  wo rkflow  of physi cal   node s. The  task  of vitual node  co nsi s ts of tr an smissi on, sen s e a nd  com putation. Wh en      transmitting data, the applicatio n layer will send the data to r outing layer,  MAC layer and  physi cal laye r, and finally n o tify the RF  module to   co mplete the  si gnal tra n smission. Sign al from  radio  ch ann el  will be  re cei v ed by the RF modul e of the no de s in t he covera ge  and u p strea m ed  to the a ppli c ation laye seque ntially. Whe n   sam p ling d a ta, ap pl ication  layer  will n o tify se nso r   driver, then t o  sen s in g int e rface to a c quire  phy si ca l information.  At last, sa mpling d a ta are  colle cted a n d  issued to  the appli c ati on layer.  Be cau s com p utation task  is to do vari ous   operation s  of data, so co mputation mo del is de sc rib ed as  CPU  state tran sition  diagram u s ed  in   data mana ge ment and en e r gy model.    The  ba se  cl as s of  t e mp lat e  st a c k i s  st r a tified m u lti function layer. Each layer,  indep ende nt from oth e r lay e rs,  contai ns  enou gh ma ni pulation ta sks and coo r dina tes thro ugh th approp riate in terface. L e vels of the stack are define d  a s  follows:   1) Inte rfa c Layer is resp onsi b le fo communi catio n  with  the  ap prop riate  ha rdwa re  an d m a ke   compl e xity of implementin g the hardwa r e fun c ti on s invisible to up per mo dule.  For exam ple,  in comm uni caton tasks of  the node, inte rface laye r in deed i s  physi cal layer.   2) The mi ddl e layer provides lo w-level  function of e rro r che cki ng,  queue  sche duling a nd et c to   wo k a s  rel a of data  flow a nd  cont rol flo w . Th e MA C l a yer i n   comm unication ta sk i s   a typical   middle laye r.  3) Mana gem ent layer pro v ides high -le v el func tion of event detection, netwo rk form ation and   self-m aintain ence to wo rk as the task  contro le r.  Routing laye r in comm uni ca tion task i s  a   typical mana gement laye r.  4) Shared ap plicatio n layer coordinate s   the coll abo rati on between d i fferent sta c ks.    The three lo wer layers  of the sta c structu r re sp e c tively wo rks as l ogi cal in terface,   pro c e ssi ng u n it and co ntro lling unit. Architecture wi th  shared ap pli c ation laye r take s into a c count  the cha r a c teri stics of the m odern WS N communi catio n  proto c ol an d gene ral pa rallellizaito n.   Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046       Hardware-in - t he-lo op an d Parallel Sim u lation Architecture for Wi rel e ss Sensor  … (Shiho ng  D)  109 2.3. Design  of Mapping  Scheme Be tw e e n   Real Node With Vir t ual compon ent  In ord e r to re duce runni ng  time of a  lar ge scale WS N simulatio n  and also  de b ug  the  embed ded  co de in se nsor  node s, ha rdware -in-th e-l o o p  emulation  p l atform is ext ende d from t h e   la ye r   a r c h itectu r e   p r op os ed  in   s e c t io n 2.2  b y  us in g a ma pp in g sc he me   b e t we e n  r e a l  no d e  w i th   virtual com p o nent in PIWSNSim. The  mappin g  sch e me integ r at es real no de s into sim u la tion   platform  as  embed ded   compon ents o f  virtual n ode s.  Runni ng  p a ram e ters  of re al n ode are   transmitted to PIWSNSim ; relative  enviorment  mo dels defin ed i n  PIWSNSim  provide phy sica appli c ation  e n viorme nt si mlation, tran sfer  data fro m  so me real  node  to ot her  nod es,  and  emulate p r a c t i cal  WSN.  Ru nning i n form a t ion from   real  node s to PI WSNSim  su p ports de buggi ng   cod e  easily. Real no de s are u s ed in  hard w a r e - in-t he-lo op emu a ltion to cre d ibly verify the   effectivene ss of some o p timization t e ch nolo g y,  provide reliabl e data ba sis for the act ual  deployme nt of the network,  and form di stributed  simul a tion to redu ce runni ng tim e Shown i n  Fig u re 5, ma ppi ng nod es a r e  deployed in  resou c e laye r of PIWSNSim with  two tier a r respon sibl e for tra c king t he a c t ual op eration  of the se nsor n o des  and  passin g   runni ng i n formation to  wi rele ss lin model  und er the  som e   manag eme n t strategy to   form   clu s terin g   wireless  se nsor network  whi c h t r an smits  data p a kca g e  from  some  se nde r n o d e  to  other re ceive r  n ode s. Sen s or n ode se nd  run n ing  st ate to m appi ng n ode  via  wirel e ss met hod,   su ch as usi n net work protocol   sta c k to  com m uni cate with  sim u lation virtu a l  nod e, or wi red   method, such  as the se rial  interface or  USB in terface.  Mappin g  nod e repla c e the  some fun c tio n   of virtual no de an d b u ild up th e m appin g  bet ween real no des and   virtual  no de s. Multi  comm uni cati ons mo de s use d  betwe e n  physi ca l n ode s and virtual node s in  PIWSNSim and   multi-core  an d multi-threa d  mechani sm  provide d  by PIWSNSim platform sup ports l a rg e-scale   netwo rk  simul a tion with mo re than 10 00  node s.           Figure 5. Mapping  schem e and dat a d e f ition in PIWSNSim       Real  nod es  sen d  net wo rk relate d dat a  to map p ing  node  with t w o tier  and  work a s  a  comp one nt in PIWSNSim  by su ch m a pping  schem e to re pla c task l a yer  an d re so urce la yer  defined in  si mulation no d e s. The m a n ageme n t layer are  ke pt in virtual node t o  simul a te so me  monitori ng  or co ope ration  strategy. Da ta str eam  be tween   real  node and  virtual n ode are   divided into two cl asse s. One is n e two r k related  d a ta sen d  amon g real no de s, and the othe r i s   runni ng state  data for code  debu gging. T he network  re lated data is  a quintupl e of (node ID, )  The inte rfaces of diffe rent layers,  node s a nd  model s a r e  defined  uni fied. The  comp one nts  in different l a yers  ca n b e  ea s ily assembled  and  disma n tled  in the syste m Simulation st eps to imple m ent hard-in -the-lo o p  emul ation are d e scibe d  as follo ws:   Evaluation Warning : The document was created with Spire.PDF for Python.
                          ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 1, Janua ry 2013 :  103 – 1 1 4   110 1) Buidi ng a  new  co mpon ent of map p i ng layer in m appin g  no de  to repl ace  th e functio n  la yer  and re so urce  layer define d  in virtual node  sh o w n  as Figure 5 .  The interfa c e s  between    mappin g  laye r and m anag ement layer  or wi rele ss chann el are  u n ified to use the simul a tio n   model s ea sily.  2) Ma ppin g  l a yer in m app ing no de ta ke re sp onsi b ili ty for con n e c ting re al no d e s via  wirele ss  or   wire  mode, a nd catchi ng the re al no de  runni ng  statu s , trackin g /de buggi ng no de s emb edd ed   function s to   map  real  no d e  to th e virtu a l no de. Al so  sim u lation  m odel s em ploy ed in  ma ppin g   node s integ r a t e real nod e into PIWSNSi m  virtual network.     2.4. Paralleli z a tion E v ent Scheme on Multicore  Computer  Multi-processor comp uters [8 ]   con s titute t he de -fa c to d e fault ha rd wa re pl atform e v en for  desktop  syst ems to p r o v ide che a p  yet powe r fu l “private  comp uting  cl usters”. So the  parall e lization  of discrete e v ent simulati ons  signi can t ly gained im portan c and  can b e  put i n to  earth to redu ce runni ng time of larg e-scale WS simulatio n . This pa pe r prese n ts a  sim p le   dynamic cent ralized p a rall el sche dulin method to   su pport th e sim u lation of la rg e-scal WSN  by  sched uling i n depe ndent  e v ent pro d u c e d  in  simulati o n  progress.  Queu e of tim e -sta mpe d  e v en with time module s  is crea ted and mai n tained dy na mically by rel a ted com pon ents. A paral lel  event sch ed uler propo se d in this paper takes re pon sibility to manage ev ent queue a nd  dis t ribute event to s o me core of c o mputer.  Parallel  simul a tion in PIWSNSim in clud es m odelin executio n tim e  of ea ch  event, and   dynamical ce ntralized eve n t sch edul i n g  sch eme. Th e step s of pa rallel  simulati on is  sho w as  follows 1) Emb edd e d  software of  WSN  nod es are  de si gn e d  and  develo ped a c co rdin g to ap plication  requi rem ents of  WSN.   2) Event execution time m odelin g meth od is em pl oy ed to define  static minim u m time of event,  and the  dyna mic  run - time  corre c tion. K e y value of t he time m o d e l are record ed in th e xml   data files.   3) Simul a tion  mode  is co nfirmed. If  si mulation i s   need ed, virtu a l no de  with  three  tiers i s   desi gne d; if emulation is n eede d, mappi ng nod e with  two tier is buil t  up by mapping schem e.    4) Simul a tion  WSN is e s tablished foll o w ing  the a p p licatio n ne e d s, in clu d ing  to defin e th e   netwo rk top o l ogy, the chan nel model, se nso r  mod e l a nd so o n 5) Event  schedul er  use  the the  dy namic  centra lized  pa rallel  event  sche duling  metho d  to  simulate the  operatio n of large - scal e WSN  a nd a nalyze p e rfo r mance. Event sche dulin g   method in thi s  pap er i s  pa rallel exe c uti on strategy  to initiatively issue event to  variou s co re   and   optimi z e d  sch edule,  which  is propo sed  for  co mp uter  of multi-core processo with sh are d   memory.   The eve n t sche dule r  i s   core u n it to  achieve  ce ntralized m a nagem ent, d y namic  optimizatio n. Event in simu lation su cce s sively  be put  into pendi ng  executio n event queu e; each  CPU  core ha s a worke r  threa d  an d m a intain s a  st orag e unit ho lding event p r ocessin g  tasks.   Memory unit of  executing event  of  t a sk  is set   a spi n lo ck   t o   p r ov ide  saf e  sh arin g serv i c i n   mu lt i- core p r ocessor sy stem. F unctio n  co mp onent s execu t e task a nd  manag eme n t, prod uce time- stampe d events  a nd pu sh  event  to  pendi ng eve n t que ue,  which  is p r ote c ted  with  m u te sema pho re o r  co nditional  variable s . Fig u re 6 d e scri b e s the sch e d u lling process co ntrole d b y   centralized  sche dule r .   Th e solid line is event strea m , and  the dash ed line is the synchro nou data stream.   Key elements in paralleli za tion are defin ed with  sets, variable s  an d  function s. E={e| e is  event prod uced in simul a tion model s} F={ e |e is so me pendi ng  event}, D={e|  e is issued e v ent  to CPU core  by sche dule r } ,  W i ={t | t is worker thre ad i n  ith  CPU  co re}, an d F E. Each  event h a two prope rty value {T start , T end }, wherein  T start  is  initial  event executi on time and  T end  is event end  t i me.  Twin is  s sy nch r o n o u s wi ndo w of  cur r ent even t. Task = NULL mean s m e meo r y unit of  executin g event is empty. Functi on of  waitFo rOn e T h rea d  is defi ned to que ry if there is idle   thread, if not  the executio n is blo c ked  until som e  th read i s  idl e  whi c h is  processed  as  ret u rn   value. The scheduli ng algo rithm is de sig ned a s  follows.  1) Du rin g  initializatio n, function comp one nts pu sh stati c  events into  F, and T wi n =   2) Event sch edule r  extract the first ev ent in F as curre n t event as. Then T win  is updated  by  comp ari ng T st art  of E current  and T wi n . If T sta r t T wi n can be  exe c ute d  parall e l with E current , else  will be wait  until the value of T wi n  is chan ged. CheckPa r alli za tion function  judges the  simultan eity of event.  Evaluation Warning : The document was created with Spire.PDF for Python.
TELKOM NIKA   ISSN:  2302-4 046       Hardware-in - t he-lo op an d Parallel Sim u lation Architecture for Wi rel e ss Sensor  … (Shiho ng  D)  111     Figure 6. Sch edule r  processing in PIWS NSim       checkParallization(){  do{   e=m i n{T starte |e’ F}   if (T starte T wi n )        retur n  (e )       else   waitFo rSom eThre ad(w| Tw in .job=NULL )   T wi n = m in{Ten d(e' )|e' D}   }whil e (true)  3) S c he dule r   queri e s the  st atus  of worke r  th read  to fin d  the  availabl e on e, move s E current  to s e of   D, di stribute s  E current  to availabe  worker thre ad , and finall y  cha nge t he value  of   T wi n =min{T end (e)|e ∈。 D}   4)  Worker thread  checks the loca l ev ent status, that means t he  status of  memory uni t  o f   executin g ev ent of ta sk. If task if free, t he eve n t w ill  b e  pr oc es se d; e l s e  ta sk is  s p in lo ck ed  to   synchro n ize threa d s.   5) Wo rker thread executes ev ent proce ss p r og ram t o  gene rate n e w events m a rked with time   stamp a n d  pushed in to F. Once  the wo rk e r  thre ad is finished, t he value o f   T wi n =min{T end (e)|e F}.   Centralized sche duling architecture  with   m anag emen t of dynamic  events contro led by  event sche du ler can b a lan c e lo ad s effe ctively.  In WSN sim u latio n s, mobility  of node s, time- varying characteri stics of  chan nel can  bring u npre d ica b le chag en of wo rk l oad. Ce ntrali zed   manag eme n t scheme  will  be well  ada pted to su dde n   alteration du ring runin g   wi thout  addition al  balan ce  strat egie s .Sche d u l er takes  re spon sibility to query eve n t queu e in se q uen ce, and fi nd   out the cu rre nt event, and distrib u te ev e n t after che cking the paralli zation.       3. Results a nd Analy s is  This  se ction  pre s ent s eval uation of co rrectn e s s the link reliabiility model, effecti v ess of   parall e lization  sche me, a n d  at la st  use s  PIWS NSim  platform to  s i mulate  a practical industrail  WSN  with 40 0 node s to an alyze the extensi b ilty  of our simul a tion a nd emulatio n frame w ork.     3.1. Link Reliabilit y  Model (EIF) Anal y s is  Two  simulati ons a r e d e si g ned to test th e co rre ctne ss and validity of EIF. First one is to  prod uce PDS  acco rdin g to  model  ba se d on  offline t e st  sampl e in ou r lab  by  usin g EIF a n d   OMNet + +. M ean while  a p r actical te st is  execut e d  bet wee n  two  no des whi c h  re corded  their  own  Evaluation Warning : The document was created with Spire.PDF for Python.
                          ISSN: 23 02-4 046   TELKOM NIKA  Vol. 11, No . 1, Janua ry 2013 :  103 – 1 1 4   112 PDS and  ano ther  simulatio n  ba se o n  T w o-Ray Groun d ch ann el Mo del with  erro r ratio of 1 0 is  impleme n ted  by using  NS2 .   The analy s is shown  in F i gure  7 prove s  the lin k reli ability mode i n   PIWSNSim is more correc t.            Figure 7.  Correctn ess resu lt of link reliab ility model co mpared with  NS2 and p r a c tical test       Secon d  sim u l a tion is to te st validity and scal ability of EIF by implementing the  spe c ific  hoppi ng  sche me. Ch annel  redu nda ncy  is on e of the  techni que s t o  increa se t h e relia bility and  determi nism  of data comm unication be cause none of   the chan nel s can p r ovide a  good relia bili ty  requi re d by in dustry  appli c ation. Slotted  hoppi ng a nd  slo w  ho ppin g  are  always u s ed i n  ind u st rial  appli c ation. I n  slotted  ho pping,  cha n n e l-ho ppin g  timeslot s o ccupy equ al d u ration s. Ta king  accou n t of link  cha r a c teri stics to incre a se  the  relia bility, some  adaptive fre q uen cy hoppi ng  method s h a ve be en  pro p o s ed  to  satisfy  the hig h   relia bility requi re ments. T hat i s  u s in g the  st able   and reliable  cha nnel  with out hoppi ng  until the ch a nnel go es to  bad, and th en ch oo se a  new  cha nnel  with  high  relia bili ty to rea c a high  reli ab le network  communi catio n . This ki nd  of  hoppi ng is  cal l ed ada ptive frequ en cy hop ping [9]     Table 2.  Reli ability of AFH and time-slot  hoppin g  in si ngle cl uste r start WSN  Nodes  3 4 5 6  AFH  ( % )   98.1  96.9  94.5 98.0 95.4  100  94.5  96  Time-slot  hoppin g (%)   80  81  79 80 80 80  81  80      EIF provid es the  both  ho pping  st rateg y  to in cre a se the  reli abil i ty and T D M A  MAC  proto c ol to  a v oid interfe r e n ce amon node and   verify the tran smissio n  d e la y. Hoppi ng m ode   is exp r e s sed  as a  configu r ed  pa ramete r in  EIF for u s ers to  cho o s whi c h  ho p p ing  method   is  calle d by TDMA MAC [10]   module in th eir sim u latio n s.  The co nclu sio n  is that the adap tive   freque ncy h o pping m a inta ins the hi gh  reliability du e to swit chin g to the cha nnel with hi g h   reliability com m unication shown in Tabl e 2.     3.2. Time effectiv eness of parallel sch eme in PIWSNSim  An instan ce  simulation i s  impleme n ted to  verify the time effectivene ss  of parallel  scheme i n tro duced in Se ction 2.4. The  simulatio n  pl aygrou nd i s   1000m *100 0,  and the r e o ne  sin k  no de lo cated in  coo r di nates  of (0,0 ), other n ode s  are  ran doml y  place d  on  some lo cation  in  the playg r ou n d . No de con s ults with  nei ghbo rs in  a ccorda n ce  with  the lo cation  to self-o rga n ized   into clu s ters with less than  64 membe r  node s.    Nodes are equipmented  with network  prot ocol  com p liant with IEEE 802.15.4  standrad  to uploa d dat a re gula r ly. Clu s ter  hea d s  a r sele ct e d  acco rdi ng t o  the di stan ce from  sin k  n ode  and  nod e ID.  Topolo g y of a  clu s ter is sta r  st ru ct ure,  a nd T D MA m e cha n sim  is e m ployed to  send   Evaluation Warning : The document was created with Spire.PDF for Python.