.

Friday, March 29, 2019

Simulation of the ALOHA protocol

Simulation of the aloha communications protocolAbstract-The r individually essay is a tutorial on the OMNeT++ mannequin surroundings, finished the epitome of the known aloha protocol. The simulation implements the ciao random rec everywhere protocol on the Link layer, and simulates a multitude to master of ceremonies instant broadcast. ciao is rather innocent yet convenient to demonstrate the potential of OMNeT++ in simulating radio receiver protocols. The final part evaluates the comminuted and the slotted ALOHA variations, in take to the metaphysical simulations.IntroductionOMNeT++ is a discrete event modeling (DES) environment, postgraduately-developed by Andras Varga as public mention, and is accompanied by Academic globe License, which factor that it is free for nonprofit academic exercising. The intention behind OMNeT++ was the organic evolution of an open source generic make-believe environment, not exclusively utilise to network affectations as the more known ns-2, or the commercial message Opnet. The environment offers instead, a generic and flexible platform to develop simulation trampworks sacred to complex IT systems, as radio set and sensor networks, the homeic IP and IPv6 stacks, queuing networks, opthalmic networks and various hardw ar architectures.Typical example of a framework that endures simulation comp adeptnts for IP, TCP, UDP, Ethernet and MPLS, is the INET Framework and the MiXiM, which is an aggregation of several frameworks for mobile and wireless simulations. The OMNeT++ ver. 4.0 is built on the known Eclipse CDT ver. 5.0, and uses approximately of its resources. It is offered for Windows and Linux operational systems. The core of the models is labeld in C++, in Linux uses the gcc compiler and in Windows uses the MinGW port for the gcc suite. There is a commercial version called OMNEST, with no signifi scum bagt nettleories than the open version, except the optional use of the native Visual C++ com piler for the Windows platform.The ALOHA protocol was one(a)ness of the oldest random advance protocols, invented by Norm Abramson in 1969. The off stage printing wireless network, implementing packet teddying over radio, used the pure ALOHA variation, gain initially established in Hawaii. Later Abramson interfaced the ALOHAnet with the ARPAnet, the primitive form of internet. The ALOHA puddle inspired the creation of CSMA/CD and the birth of Ethernet. Finally, the random access protocol has evolved to contemporary CSMA/CA, the MAC layer of Wi-Fi. The slotted ALOHA and the later pure ALOHA have frank implementations, eliminate for simulation. It uses only the host to server broadcast instant, alone is adequate to calculate the utmost point might and demonstrate some other inte quietusing attributes, as well.OMNeT++ DESCRIPTIONThe building of ModelsOMNeT++ is based on C++ programming and follows the prey-oriented approach with classes and class instances, the supposed objects. The simulation model consists of staffs, which communicate by message passing. The core part is the wide-eyed mental faculty, which is written in C++, and constitutes an instance of a faculty geek from the simulation class subroutine library. The next structural element in the power construction is the merge model, which is formed from simple modules or other compound models. all(prenominal) module, simple or compound, has ports to communicate with the external environment, called approachs. Gates could be bidirectional or could be restricted to input or proceeds. Modules atomic number 18 connected done their gates via connections and they communicate by exchanging messages, via these connections.The block plot in Fig. 1 depicts the internal module structure according to the declargond hierarchy, in OMNeT++. The connections are limited within the module range but the message exchange can be established across hierarchy levels. This is applicable in the cas e of modeling wireless systems and the simulation of ALOHA come ins lead make use of it. Otherwise, messages are traveling through the chain of connections. Modules have parameters, which are used to pass initialisation info during the initiation of the simulation. The compound models can pass parameters to the contained sub-modules. The final model which contains the blend of the modules is called network model, is represented as a class and each simulation run is executed on an instance of this class.The NED languageThe structure of the simulation in OMNeT++ is based on the network commentary language (NED). The NED includes declarations for the simple modules and definitions for the compound modules and the network model. The language programming is accomplished by the combine graphic editor, as shown in Fig. 2 or the text editor, as shown in Fig. 3. Both editors are producing equivalent economy, and the programmer can switch from one another without any derogation.The pro gramming modelThe typical code development includes the chase steps The programmer creates the network model, by creating the take away network_name.ned shoot, utilise the IDE. The NED file describes the network name and the topology, which are the names of the sub-modules, simples and compounds. Every sub-module should have its own module_name.ned file, which includes the parameter declarations and other meta-selective information. As mentioned, the behavior of every simple module is expressed in C++, so on that point should be two specific files, the module_name.cc and the module_name.h, for every simple module. These files are compiled during simulation execution by the supporting C++ compiler, and linked with the simulation ticker and libraries.The programmer publicly tests the behavior of the simulation model according to divers(prenominal) inputs. These could be entered manually by the user, during simulation execution, or could be include in a physical body file. Ge nerally, there is a special type of file the omnetpp.ini that contains these parameters and the rest of the building blocks, to support user interaction. The IDE includes an editor for the initialisation files, which can switch between form view, as shown in Fig. 4, and source view, as shown in Fig. 5. The two fields are equivalent.There are two fundamental methods to develop C++ code for programming the simple module behavior The co-routine based and the event processing function. In the first approach, every module executes its own threat of code, which is activated every age it receives a message from the simulation warmness. In the last approach, the simulation kernel calls the module function, having the specific message as argument. Prior to main() function execution, an initialization function declares variables and objects and before program termination, a finalization function saves the data logged during simulation, and produces histograms.OMNeT++ Architecture and Potent ialityThe interest Fig. 6 presents the internal logic structure of OMNeT++. The first block is the model component library, which the programmer develops in C++, and contains the compiled code of simple and compound modules. The simulation kernel and the class library (SIM) instantiates the modules and build the concrete simulation model. The user interface libraries (Envir and Cmdenv or Tkenv) provide the simulation environment, which defines the source of input data, the sink of simulation results and the debugging information. It controls the simulation execution, visual percept and animation.Cmdenv provides only command line and text mode input-output, and it is more appropriate for batch simulations. Tkenv is the graphical user interface (GUI) of OMNeT++. It provides automatic animation, module output windows and object inspectors. The avocation Fig. 7 depicts an active simulation output through OMNeT++/Tkenv.OMNeT++ includes very powerful tools to visualize the interaction a mong modules. A sequence chart diagram provides a way to inspect the timing of the events during simulation by extracting data from an event log file. During the finalization routine, the logged data are saved to specific result files, the vectors in network_name.vec and the scalars in network_name.sca files, respectively. For the result analysis, OMNeT++ produces the analysis file network_name.anf, which contains heap upd data in vectors and scalars plus any histograms, created during the final stage. every(prenominal) the types of data can be further processed by using pattern rules, in datasets and charts section, to produced advanced charts and graphs. In the ALOHA simulation most of the visible(prenominal) choices are used for demonstration.ciao SimulationBackground systemThe slotted ALOHA is the most simple random access protocol. The institutionalizeting station always broadcasts at the full rate R of the convey. The transmitting initiates at the beginning of the slo t, which is common for the aggregate of the post. If two or more displace transmit simultaneously, then the condition is called collision and all the stations involved, aft(prenominal) a random cartridge holder different for each, retransmit the frame until roaring delivery. The procedure is presented at the following figureThe slotted ALOHA protocol allows each station to transmitat at the impart full speed R, but requires slots to be synchronised in all the stations, something not nessesary for the unslotted or pure ALOHA. The following assumtions are made to simplify simulationThe source generates one frames of aloofness L bits. The inter-arrival epochs between frames follow exponential distribution. If R bps is the capacity of the wireless link then the slot condemnation is set equal to the contagious disease condemnation of each frame, which is tframe=LR sec.All inspissations are synchronized and transmit frames only at the beginning of a slot.If a node has a hot frame to intrust, it waits until the beginning of the next slot.If two or more frames collide, then their hosts retransmit after random time, following exponential distribution.If there is no collision, then the node transmits its next frame following exponential distribution.I define N the number of stations operating the slotted ALOHA protocol and p the probability of each station to transmit in the next slot. The probability for the same station to do not transmit in the next slot is then 1-p, and for the rest of the stations is 1-pN-1. Therefore, the probability for a station to have a successful transmittance during the next slot is to transmit and the rest of the stations to do not transmit, so it is p1-pN-1, and because there are N stations, the probability that an arbitrary node has a successful transmittal is Np1-pN-1.A slot where a single station transmits is called a successful slot. The dexterity of slotted ALOHA is defined as the long run fraction of successful slots, which isEp=Np1-pN-1 (1)To find the supreme efficiency, we prove p* that maximizes (1). ThenEp=N1-pN-1-NpN-11-pN-2=N1-pN-21-p-pN-1If Ep=0 then p*=1N . Using this mensurate, the maximum efficiency isEp*=N1N1-1NN-1=1-1NN-1=1-1NN1-1N (2)For a large number of active stations, the maximum efficiency accrues from (2) as N approaches infinitylimNEp*=limN1-1NNlimN1-1N=1e1=1e=0.368 (3)From (3), the maximum efficiency of slotted ALOHA is 0.368 or 36.8%The unslotted version or pure ALOHA protocol does not have the restriction of slot synchronizing, and the station is able to broadcast when a new frame is available. So pure ALOHA is a full-decentralized random access protocol. When a transmitting station detects a collision, after completing the transmission, it retransmits the frame with probability p. If it chooses to postpone the transmission for a single frame transmission period tframe=LR sec, then the probability is (1-p). The figure below depicts transmissions and collisions in the unslotted lineage.The maximum efficiency of pure ALOHA protocol is calculated similarly as the slotted ALOHA. The only difference here is that the rest of the stations should have not begun transmitting before and should not begin during the broadcast of the given station. The probability that the rest of the stations remain unaffixed is 1-pN-1 and the probability that they remain lazy is 1-pN-1 again. Therefore, the probability that the given station will have a successful transmission is p1-p2N-1.Again, we seek the value of p* that maximizes (4), which is the probability of successful transmission for the sum of the N stations.Ep=Np1-p2N-1 (4)Ep=N1-p2N-2-Np2N-11-p2N-3=N1-p2N-31-p-p2N-1If Ep=0 then p*=12N-1 . Using this value the maximum efficiency isEp*=N2N-11-12N-12N-1 (5)From (5), the maximum efficiency accrues as N approaches infinity, which islimNEp*=121e=12e (6)From (6) I assume that the maximum efficiency, for the pure ALOHA protocol, is 0.184 or 18.39%, the half of slotted ALOHA.another(prenominal) useful diagram is in Fig. 10. It depicts the apparent superiority of slotted ALOHA over the pure ALOHA protocol, despite the limitations that turn it to non-functional. The normalized total occupation is the aggregate traffic, which generated by the source of the station, divided by the channel capacity R and the normalized throughput ? is the average successful traffic (non-collided) divided by R. The slotted ALOHA achieves simulacrum throughput than the pure ALOHA and achieves its maximum efficiency when the generated traffic rate equals the channels capacity R. The pure ALOHA although, achieves its maximum efficiency when the generated traffic equals to R/2.Model DevelopmentNED languageThe following paragraphs describe the process of creating a functional model for the simulation of ALOHA protocol in OMNeT++. The object of simulation is to study the behavior of the ALOHA model and to confirm the theoretical values of maximum efficiency for pure and slotted ALOHA. The ALOHA random access protocol is peer based and does not use a server-client architecture. It is convenient to study the effect of collisions and random retransmissions only in the case when one host is receiving (becomes server) and the rest of the hosts are transmitting.The first step is to develop the NED code that describes the network Aloha. The following Aloha.ned file creates the Aloha network, which consist of simple modules, one called server and a number of hosts, equal to num multitudes parameter. The txRate defines the transmission rate R, of the wireless channel, and slotTime defines the type of protocol. Zero means pure ALOHA and 100ms defines the slot time length. The parameter display selects a background image, taken from the library.network Aloha parameters int num forcess // number of hosts double txRate unit(bps) // transmission rate double slotTime unit(ms)// zero means no slots (pure Aloha) display(bgi=background/terrain) submodules serve r server hostnumHosts Host txRate = txRate slotTime = slotTime The following Server.ned file describes the servers simple module. It fill ups an image for the server icon and defines a gate of input type (in), with which it is not necessary to establish a connection. It can receive a message directly from a host via directIn, something that is usual to wireless simulations.simple Server parameters display(i=device/antennatower_l) gates input in directInThe following Host.ned describes the hosts simple module. It loads a set of parameters from the omnetpp.ini file, the radioDelay, which is the propagation tick off over the radio link, pkLenBits, which is the length of the frame, and iaTime, which is the random inter-arrival time, following exponential distribution. The rest of the parameters, txRate and slotTime, are wicked in Aloha.ned, during sub-module instantiation.simple Host parameters double txRate unit(bps) // transmission rate double radioDelay unit(s)// propagation dela y of radio link vaporific int pkLenBits unit(b) // packet length in bits volatile double iaTime unit(s) // packet interarrival time double slotTime unit(s) // zero means no slots (pure Aloha) display(i=device/pc_s)ConfigurationThe most critical file is the configuration file omnetpp.ini. It stores the values of the parameters that are loaded in the NED parameter fields. When declaring on the General field that Aloha.slotTime=0, is presets globally the pure ALOHA protocol. Similarly, the Aloha.numHosts=20 defines the number of hosts to be 20, the Aloha.txRate=9.6kbps defines the R to be 9600bps. The last definitions load the parameters of Aloha model and consequently the parameters of the simple modules that Aloha model controls, which are the server and the host modules. The definitions Aloha.host*.pkLenBits=952b and Aloha.host*.radioDelay=10ms load directly the parameters pk.LenBits and radioDelay on every host submodule, respectively.Generalnetwork = Alohadebug-on-errors = truere cord-eventlog = trueAloha.numHosts = 20Aloha.slotTime = 0 no slotsAloha.txRate = 9.6KbpsAloha.host*.pkLenBits = 952b =119 bytes, so that (with +1 byte guard) slotTime is a nice round numberAloha.host*.radioDelay = 10msConfig PureAloha1 description = pure Aloha, overloaded too usual transmissions result in high collision rate and low channel utilizationAloha.host*.iaTime = exponential(2s)Config PureAloha2description = pure Aloha, optimal load secretive optimal load, channel utilization is near theoretical maximum 1/2eAloha.host*.iaTime = exponential(6s)Config PureAloha3description = pure Aloha, low traffic very low traffic results in channel being idle most of the timeAloha.host*.iaTime = exponential(30s)Config PureAlohaExperimentdescription = Experimental mutliparameter demostration retell = 2sim-time-limit = 90min**.vector-recording = sourAloha.numHosts = $numHosts=10,15,20Aloha.host*.iaTime = exponential($mean=1,2,3,4,5..9 step 2s)Config SlottedAloha1description = slotted Aloh a, overloaded slotTime = pkLen/txRate = 960/9600 = 0.1sAloha.slotTime = 100ms too frequent transmissions result in high collision rate and low channel utilizationAloha.host*.iaTime = exponential(0.5s)Config SlottedAloha2description = slotted Aloha, optimal load slotTime = pkLen/txRate = 960/9600 = 0.1sAloha.slotTime = 100ms near optimal load, channel utilization is near theoretical maximum 1/eAloha.host*.iaTime = exponential(2s)Config SlottedAloha3description = slotted Aloha, low traffic slotTime = pkLen/txRate = 960/9600 = 0.1sAloha.slotTime = 100ms very low traffic results in channel being idle most of the timeAloha.host*.iaTime = exponential(20s)A selection of the SlottedAloha2 configuration overrides the value of slotTime with Aloha.host*.slotTime=100ms, which fixes the slotted ALOHA protocol with slot time to 100ms. The Aloha.host*.iaTime=exponential(2s) sets the frame inter-arrival time on every host to follow exponential distribution, with mean time equals to 2 seconds.The Co nfig option PureAlohaExperiment exploits the OMNeTs capabilities of organizing different experiments with simple repetition declarations. The description Aloha.numHosts=$numHosts=10,15,20 declares trine (3) repetitions having 10, 1 and 20 hosts respectively.The statement Aloha.host*.iaTime=exponential($mean=1,2,3,4,5..9 step 2s) declares septenary (7) repetitions, with interarrival times equal to exponential distribution and means, 1, 2 ,3, 4, 5, 7 and 9, respectively. The repeat=2 statement doubles the number of runs, so finally the available choices will be 2x3x7=42 from 0 to 41 optional runs. The statement sim-time-limit=90min constrains the simulation time to 90 minutes.C++ model codingThe simple modules Host and Server are based on C++ programming. The germane(predicate) host.cc, host.h, server.cc and server.h, which are included entirely in the appendix section, implement the model behavior during simulation by exchanging messages directly one-another or with the simulation kernel. The following Fig. 11 is a design- level class diagram, describing the basic relationships among network module Aloha and simple modules, Host and Server. The two last, inherit from cSimpleModule simulation class library, and redefine the basic methods initialize(), handleMessage(), activity() and finish(), according to the desired function.The Aloha network model comprises of several Host objects and one Server, so it keeps an aggregation association with Host and Server classes. It passes also to them some parameter values, some declared in the omnetpp.ini file and some taken from user dialog form. The Host module keeps an one-way association with Server because every Host declares a Server object in the attribute field, in order to send a direct message (pk) later, by calling the sendDirect() function. The scheduleAt() function programs the kernel to send the Host an endTxEvent message when the transmission ends. This is represented by the self-association. Similarly, th e Server module programs the kernel to send the Server an endRxEvent, when the reception of the message sent from Host finishes, and is represented as the self-association.The module code is cited commented in the appendix. Here, I will explain the finish() function of the server module, because it creates the result reports, necessary for the exploitation of the simulation. misdirect Serverfinish() EV

No comments:

Post a Comment