NS2网络模拟(精)
- 格式:doc
- 大小:251.50 KB
- 文档页数:19
The application of wireless Ad-hoc network[Hospital mobile server]Lin QiuDepartment of Mathematics&Computing2009University of South QueenslandQueensland,AustraliaSupervised by Dr.ZhongWei,Zhangdan_n2003@ABSTRACTWireless ad-hoc networks have attracted many applicationsin part decade due to its feature of being wireless and with-outfixed nodes as router or gateway.This type of network has an important potential of being token in the healthcareor hospitals,where the physical connectivities is hard,or not economical.In this paper,we simulate a wireless ad-hoc network by using NS2,inspect its performance under manydifferent settings and models.General TermsWireless ad-hoc networkKeywordsInstantaneous throughput,Average throughput,Congestion win-dow size1.INTRODUCTIONA wireless ad-hoc network is actually decentralized wire-less network in which each node may transfer data for other nodes.Thisflexibility provide users with a potential to re-placing traditional networks anywhere,the physical connec-tivity is a concern.We also,however,realized that the TCP performance on wireless ad-hoc network has some sever lim-itions.2.BLUE POINTDesigning a blue point for whole hospital mobile server with wireless Ad-hoc network by NS2.Copyright c USQ2009.The design for NS2show as below:•Simulation Time:50sec•Topology:400m x400m•Mobility of nodes is defined as following:–Node A:(1,1–Node B:(1,399–Node C:(399,1–Node D:(200,200–Node E:(399,399–At time0,node A and C start moving towards the initial position of node E and B respectivelyat speed of30milesecond.–At time0,node E and B start moving towards the initial position of node A and C respectivelyat speed of30milesecond.–Once they reach the targeted location,reverse the direction and return to the original position atthe same speed.•There are two TCP connections:–Connection1:From A to E–Connection2:From C to B–Both start2seconds after the simulation starts.–Both congestion window size:50packets,packet.size:1000bytes,the minimum timeout period:0.2second.–Both traffic sources are FTP sources.•Scenarios:–llType:LL–IFQ Len:50–IFQ Type:QueueDropTailPriQueue–Antenna:Antenna/OmniAntenna–Propagation model:PropagationTwoRayGround–Physical layer:PhyWirelessPhy–Channel:ChannelWirelessChannel–Mac layer protocol:802.11–Network Routing Protocol:AODV–TCP protocol:TCP Reno•Other design:–Set Link layer type∗LL set mindelay50us∗LL set delay25us∗LL set bandwidth0–Set interface queue type∗QueueDropTailPriQueueset Prefer Routing protocols1–Unity gain,omni-directional antennas set up the antennas to be centered in the node and1.5me-ters above it∗AntennaOmniAntenna set X0∗AntennaOmniAntenna set Y0∗AntennaOmniAntenna set Z 1.5∗AntennaOmniAntenna set Gt 1.0∗AntennaOmniAntenna set Gr 1.0–Set network interface type Initialize the Shared-Media interface with parameters to make it worklike the914MHz Luccent WaveLAN DSSS radiointerface∗PhyWirelessPhy set CPThresh10.0∗PhyWirelessPhy set CSThresh 1.559e-11∗PhyWirelessPhy set RXThresh 3.652e-10∗PhyWirelessPhy set Rb2*1e6∗PhyWirelessPhy set Pt0.2818∗PhyWirelessPhy set freq914e+6∗PhyWirelessPhy set L 1.0•Collect the data from network topology by Perl –Average throughput data–Instantaneous throughput data–Congestion window size data•When t he thousands of data gained,plotting a few in-tuitionistic2D graphs with Gnuplot and Xgraph show its variability.–Instantaneous throughput graph–Congestion window size graph•Results presentation(units should be specified e.g.bytes/sec,bit/sec,etc–Explain the TCP performance changes over time.–Compare the TCP performance of the two WORK SIMULATIONAssume there are many hospital departments,mobile de-vice of staffs by a wide variety of healthcare professionals, with some crossover between departments,such as accident and emergency(A&Ewhere are likely to take in patientatfirst.Main diagnostic department in which building,Pa-tients,doctors and nurses are assessed and seen from the dif-ferent departments.Other department,like Elderly services department or General surgery department where has ex-pert doctors.Each department configure own wireless de-vice that directly communicate with the central diagnos-tic department in case of responding a emergency.To help achievement of wireless network c onfiguration,NS2software make a mirror for its configuration running.3.1Layer configurationThose basic parameters for simulation provide the simple information for different layers.set val(chanChannel/WirelessChannel;#channel typeset val(propPropagation/TwoRayGround;#radio-propagation model set val(netifPhy/WirelessPhy;#network interface typeset val(macMac/80211;#MAC typeset val(ifqQueue/DropTail/PriQueue;#interface queue typeset val(llLL;#link layer typeset val(antAntenna/OmniAntenna;#antenna modelset val(ifqlen50;#max packet in ifqset val(nn5;#number of mobile nodesset val(rpAODV;#routing protocolset val(x400;#X dimension of topographyset val(y400;#Y dimension of topographyset val(stop50;#time of simulation end3.2Nodes configurationHere is a nod es configuration shown blow[?],$ns node-config-adhocRouting$val(rp-llType$val(ll-macType$val(mac-ifqType$val(ifq-ifqLen$val(ifqlen-antType$val(ant-propType$val(prop-phyType$val(netif-channelType$val(chan-topoInstance$topo-agentTrace ON-routerTrace ON-macTrace ON-movementTrace OFF3.3Antennas,Network interfaceThose configurations of Antennas and Network interface configure like the requirement given,which has been shown above.3.4Network Topology#Create the number of nodesset node(A[$ns node]set node (B[$ns node]set node (C[$ns node]set node (D[$ns node]set node (E[$nsnode]Figure 1:Wireless Ad-hoc network topology Start doing project work,network model is shown in Fig-ure 1,which is a wireless ad hoc network consisting of 5nodes(A,B,C,D,E represent as 0,1,2,3,4.The nodes D which is a special node known as an router which is an access point manages communication among other nodes(A,B,D,E,and all other nodes can be considered as clients.$node (A setX 1.0$node (A setY 1.0$node (A setZ 0.0$node (B setX 1.0$node (B setY 399.0$node (B setZ 0.0$node (C setX 399.0$node(C setY 1.0$node (C setZ 0.0$node (D setX 200.0$node (D setY 200.0$node (D setZ0.0$node (E setX 399.0$node (E setY 399.0$node (E setZ 0.03.5TCP connectionThere are two TCP configur ations with 5nodes using Newreno TCPalgorithm.Newreno algorithm that is a ver-sion of Reno for deal with congestion on the network.When the packet is lost,using ”fast retransmit”and ”fast recov-ery”mechanism controls the congestion window.[?][?]NewReno algrithom processing approaches:•Step1:Resend the ACK packet for three timesIf the third ACK had received and fast recovery does not access process,to check the accumulative value whether it is greater than recover variable.If it is,then going to next step 2,or it is not,then going to next step 3.•Step2:Transfer fast retransmitSetup slow start threshold as max(FlighSize /2,2*SMSSFlighSize represents the data sent but it does not ar-rive at the destination yet.So the max serial number save into the recover variable and send out then going to step 4.•Step3:Do not transfer fast retransmitDo not access doing fast retransmit and fast recovery and do not change ssthresh.Going to step 6.•Step4:Fast retransmitRetransmit the packet that had been lost and setup the congestion window size as ssthresh+3*SMSS.•Step5:Fast recoveryDuring the fast recovery,to increase the congestion window size when every ACK packet resend have re-ceived.•Step6:Fast recovery continueContinue send a data segment if the congestion window size and receiver allow.•Step7:CheckoutWhen a new ACK packet had received,then doing checkout that has two conditions:1.Fully checkoutCheck every data from ACK including recover serial number and data information,and setup the CWND as min(ssthresh,FlighSize+SMSS.2.Part checkout Generate a part of ACK when the ACK does not full checkout,and retransmit first segment that has not been checkout.According to new ACK,to decrease CWND.•Step8:Retransmit timeoutwhen the packet retransmit timeout,to save the biggest serial number to recover variable then stop fast recov-ery.set tcp [new Agent/TCP/Newreno]$tcp set class 1$tcp set window 50$tcp set packetSize 1000Agent/TCPSink/DelAck set interval 200ms set sink [newAgent/TCPSink/DelAck]$ns attach-agent $node (E$sink $ns connect $tcp $sinkset ftp [new Application/FTP]$ftp attach-agent $tcp $ns at 2.0”$ftp start”set tcp2[new Agent/TCP/Newreno]$tcp2set class 2$tcp2set window 50$tcp2set packetSize 1000Agent/TCPSink/DelAck set interval 200ms set sink2[newAgent/TCPSink/DelAck]$ns attach-agent $node (C$tcp2$ns attach-agent $node(B$sink2$ns connect $tcp2$sink2set ftp2[new Application/FTP]$ftp2attach-agent $tcp2$ns at 2.0”$ftp2start”The design of TCP agent between node A to node E and Node C to Node B of which the packets in the black round signal have limited as 1000bytes,and their minimum time-out period also is set to 0.2second.The congestion window’s size setup 50packets[?].3.6Nodes’Movement5nodes are with initial positions at time 0.After that,the node A,B,C,E are moving to node D slowly and syn-chronously with 30milesecond.$ns at 0.0”$node (Asetdest 200.0200.030.0”$ns at 0.0”$node (Csetdest200.0200.030.0”$ns at 0.0”$node (Bsetdest 200.0200.030.0”$ns at 0.0”$node (Esetdest 200.0200.030.0”When the distance between adjacent client nodes is 199mile,the reverse time between client node and core node we can known as 199.0∗sqrt (2/30.0.$ns at [expr 199.0*sqrt(2/30.0]”$node (Asetdest 1.01.030.0”$ns at [expr 199.0*sqrt(2/30.0]”$node (Csetdest 399.01.030.0”$ns a t [expr 199.0*sqrt(2/30.0]”$node (Bsetdest 1.0399.030.0”$ns at [expr 199.0*sqrt(2/30.0]”$node (Esetdest 399.0399.030.0”The Figure 2show that all nodes converge at (200,200around 9.4seconds and return back at the sametime.Figure 2:Nodes flock together4.DATA ANALYSIS 4.1Congestion Window SizeXgraph is used to plot the graph for result analysis that is provded by network simulator.It allows to create postscript,Tgif files and others,by clicking on the botton of the NAM as “Hdcpy”.In this project,Xgraph commands process a con-gestion window size(CWND.The procedure called plotWin-dow is added in the TCL file that generate an outputfile.Figure 3:Congestion Window SizeIn this procedure,we also set up the instantaneous size of the window of TCP with the tim e intervals of 0.1second,and generate another file is ”win.tr”.We can monitor a plot of congestion window using the data from this file.Using TCP/Reno connection is the modern version take the FTP traffic.When the packet is lost,TCP connection is going to nex t step that is adopting ”fastrecovery”strategy control the congestion window.In other word,to setup size into the half of congestion window,then to increase the size of 1/congestion window.According to this theory,FTP traffic set up in this project will increase gradually during 20seconds when CWND start happen at 2second.However,at 19.41second,CWND goes down directly to 1and continue keep this value constantly because two FTP traffic stopped at 19.5second.In addition,each TCP also maintain a window called the Congestion Window or cwnd have defined size as ing congestion window (cwndadjust the transmis-sion rate in order to fix up the TCP network congestion.The congestion window either increases or decreases that depend on ACKs (acknowledgementsbeca use it reflects the status of link’s buffer queues.This chart shows the value of con-gestion window based on observed packets (duplicate ACKsand plots the value of congestion window against time.Theslope of the congestion window indicates the rate at which data is being transmitted.In the slow start phase-cwnd increases exponentially;in congestion avoidance-cwnd in-creases linearly subject to a maximum of2*mss per round trip time.4.2Sorting trafficfileNetwork smiulator can do a lot of process on data events when it happens at the network.The one thing is to analyze the data result that is to extract relevant information from traces and to manipulate them.There are two ways you can handle these tracesfiles.An example of a line in the ouput trace iss2.0000000000AGT—0tcp40[0000]——-[0:04:0 320][00]00•Thefirstfield is a letter that can have the values r,s,f,dfor”received”,”sent”,”forwarded”and”dropped”, respectively.It can also be M for giving a location or a movement indication was shown before.•The secondfield i s the time.•The thirdfield is the node number.•The fourthfield is MAC to indicate if the packet con-cerns a MAC layer,it is AGT to indicate a transport layer(e.g.tcppacket,or RTR if it concerns the routed packet.It can also be IFQ to indicate events related to the interference priority queue(like drop of packets.•After the dahses come the global sequence number of the packet(this is not the tcp sequence number.•At the nextfield comes more information on the packet type(e.g.tcp,ack or udp.•Then comes the p acket size in bytes.•The4numbers in thefirst square barkets concern mac layer information.Thefirst hexadecimal number0 which specifies the expected time in seconds to send this data packet over the wireless channel.The second number0,stands for the MAC-id of the sending node and the tird,0,is that of the receiveing node.The last 0,is the MAC type.•The next numbers in the second square brackets con-cern the IP source and destination addresses.•The third brackets concern the tcp information:its se-quence number and acknowledgement number.There are other formats shown in the trafficfile out.tr likethis:M0.000000(1.00,1.00,0.00,(200.00,200.00,30.00 where thefirst number is the moving time,the second is the node number,then comes the origin and destination loca-tions,and last one is given the speed.[?]To purify data that we need,Perl language help in the TCLfile can automatically generate the graph,but too many command lines write into the TCLfile will cause thebuffoverloaded.To address this problem,we may write Perl into otherfiles and executed commands by manually typing when we need to research these data.Because”out.tr”file track all traffic of nodes including ACK,AGT,MAC and soon,we must sort two TCPs through-put data out.In this case,the data are received by node E(node4from transport layer belong a TCP connection, while another data are received by node B(node1transfer-ring on the network,which is second TCP connection.grep”r”./traffic/out.tr|grep”tcp”|grep ”4”|grep”AGT”>./traffic/tcp1.tr&grep”r”./traffic/out.tr|grep”tcp”|grep”1”|grep”AGT”>./traffic/tcp2.tr&4.3Average throughputAfter sorting data,it is going to calculate average through-put.A parameter as granularity where we compute how many bytes were transmitted during time interval specified.In this case,all nodes must stop at50seconds.perl./perl/AvgTp.pl./traffic/tcp1.tr50& perl./perl/AvgTp.pl./traffic/tcp2.tr50&Figure4:Average throughputFigure4shows on the TCP1connection,the total through-put is373180bytes which start at2second and end at17.7 second so the average throughput is373180/(17.7-2=23769 bytes/second.TCP2connection start running a bitlaterFigure5:Average throughputand stop earlier than TCP1connection.So the total through-put is345620and average throughput during17.6seconds is22076bytes/second.4.4Instantaneous throughputTo record two TCPs Instantaneous throughput into the files,and every0.1is a small time interval for instantaneous throughput.perl./perl/tcp1InsTp.pl./traffic/tcp1.tr0.1 &perl./perl/tcp2InsTp.pl./traffic/tcp2.tr0.1& Plotting two TCPs Instantaneous throughput.plot’./traffic/tcp1Ins.tr’t”TCP1inst”w lines 1,’./traffic/tcp2Ins.tr’t”TCP2inst”w lines2as the life of patients.Wireless Ad-hoc netowrk operate in hospital,which has a centralized supporting structure like an access point assist other wireless device in orderto keep connected with the wireless system from one place to the other.Hospital mobile server,that is the aim of being salvage. When a dying patient sent into the hospital,doctor in charge of a case and assistant medical director s can immediately know the first information of patient before doing operation and they can read the state of illness at real time. However,traditional hospital information system that built in wired network for providing basic server is adapt for some settled position like pharmacal apartment,rest apartment and so on,which wired network has more secure,more bandwidth and more reliable than wireless Ad-hoc network. Therefore, building a wireless network combine working with wired network from a traditional hospital is really necessary. Figure 6: Two TCPs Instantaneous throughput In Figure6,we present both instantaneous throughput of TCP connection during every 0.1 second.On TCP1, traffic start 3.5 second and itfluctuantes dramatically in every second.There are 5 times traffic reach 50000 bytes respectively at 5 second,9 second,14 second, 15 second and 17.5 second.However,thetraffic go trhoughput TCP2 connection which quite difference from TCP1 connection, where start traffic at 5 second,and most of traffic has instantaneous throughput with 30000 bytes or 40000 bytes, although there are traffic reach 50000 bytes for 3 times at 9 second, 15 second and 16 second.The reason of both TCP connections have large traffic around at 5 second, 9 second and 15 second is that in 5 second,both nodes of a connection reach at the range of middle node D when they are moving, after that in 9 second, all nodes accumulate together and finally all nodes are going out of range of node D in 15 second.7. ACKNOWLEDGMENTS I would like to thank Dr. ZhongWei,Zhang for his help in studying TCL and Perl language. APPENDIX A. A.1 A.2 A.3 A.3.1 A.3.2 A.3.3 A.3.4 A.3.5 A.3.6 HEADINGS IN APPENDICES Introduction Blue point Network simulation Layer configuration Nodes configuration Antennas,Network interface Netwo rk Topology TCP connection Nodes’Movement 5. LIMITATIONS After the data analyse, the design of hospital mobile server can be come true, but there are some limitations for wireless ad-hoc network. • Limitation of throughput The total throughput is limited c ause more server join in and more bandwidth consume. • Interference Interference always is a mainproblem of wireless network.Without cable contained,a signal discover to impact with another signal,especially for hospital where have many electronic devices. • Lack of security Between node and node,there are traffics go through by wireless tunnel.Thosetraffics are easier be listening and attacking,and finally it causes whole network unreliable.A.4 A.4.1 A.4.2 A.4.3 A.4.4 Data Analysis Congestion Window Size So rting traffic file Average throughput Instantaneous throughput A.5 A.6 A.7 A.8 Limitations Conclusion Acknowledgments References 6. CONCLUSION In a conclusion, we already researched some contents are given a bird’s eye view of wireless Ad-hoc network based on the Network simulator. The Network exists to help in medical care system related to the historical evolution of hospitals until the present day by providing.A wireless network is a great way to save time in working hospital,actually。