The Simulation of the Time Slot Csma/cd Protocol Based on P-persistent Exponential Backoff Algorithm

The time slot CSMA/CD protocol model based on the discrete event simulation technology is established in the article, and the object-oriented simulation technology is adopted to implement the simulation software, and the influences of the messaging probabilities on the network performance are analyzed under different loads, and the result shows that to enhance the comprehensive performance parameter of the network, the influences of the P value under different loads must be comprehensively considered.


Introduction
The network simulation is a basic measure to research the network technology, and it is the process of using the computer program to model the communication network and simulate the communication network by the running of the program.According to the requirements of the design, the network simulation could know various performances of the network under different conditions by relatively less time and charge and obtain abundant and effective data of the network research.The function of the network simulation technology is more and more important in the design and research of the modern communication network.
The simulation technology combining the discrete event drive with the object orientation is adopted to model and simulate the time slot P-persistent CSMA/CD Bus LAN based on the binary exponential backoff algorithm, and implement the simulation by the software of VC++ 6.0.According to the simulation result, the influences of the messaging probability on the network performance are analyzed in the article.

Flow chart of simulation
The event scheduling method is used in the system simulation.According to the time sequence that event happens, the events are stored in the event table, and with the advance of simulation clock, the system will find the earliest event in the event table and transfer the corresponding event processing function, so all events could be processed one by one according to the time sequence until the event table is empty, and the simulation ends.The flow chart of simulation is seen in Figure 1.

Generation of random numbers
In the simulation system, the arrival time interval of message obeys the Poisson distribution, and the messaging probability P obeys the normal distribution, and the transfer time of message obeys the Exponential distribution.And the system simulation needs to respectively generate the random numbers obeying the Poisson distribution, the normal distribution and the Exponential distribution.These random numbers could be generated by the independent and average distributed random variable source U (0, 1), and the average random variable could be obtained by the function of rand () in the VC++.

Generating the random numbers obeying the Poisson distribution
The arrival time interval of message obeys the Poisson distribution.Suppose that {Ui} is the random number averagely distributed in [0, 1], and N is the amount that message arrives in the unit time, and the method generating the Poisson random variable N includes following approaches.
(3) If p<e -a , accept N=n, or else, reject it, and add n by 1, and return to the approach (2).
Where, a denotes the average time interval that the message arrives, and {Ni} generating in the above algorithm is the time interval sequence that the message arrives.

Generating the random numbers obeying the Exponential distribution
The transfer time of message obeys the Exponential distribution.Suppose {X i } is the random number averagely distributed in [0, 1], so is the random sequence of the message transfer time distributed the Exponential distribution.Where, 1 λ denotes the average transfer time of message.When Xi=0, Yi is the maximum transfer time of message.

Generating the random numbers obeying the normal distribution
Normal distribution is a usual distribution, and the messaging probability P obeys the normal distribution.
Suppose that X1 and X2 are two independent random variables averagely distributed in [0, 1], and by (3) , two independent random variables Y1 and Y2 obeying the normal distribution N (0, 1) can be obtained.
Suppose that Y1′ is the random number of messaging probability, so Y1′ should be in [0, 1].

Simulation of P-persistent CSMA/CD strategy
A bus occupying sign is defined in this software.Before the messaging event is exerted, the bus occupying sign should be judged, and if it is empty, so transfer the processing function, or else, delay one unit until the bus is empty, and then transfer the event processing function.The processing function of messaging event should traversal the event table, and find out other same type event which is same with the messaging event, and transfer them to the chain table of messaging event.Then, respectively generate the random transfer probabilities, and transfer the events with the probability P-persistent.If several messages are transferred by the probability P, so truncate the binary exponential backoff.

Simulation of the truncation binary exponential backoff algorithm
(1) For each message, when the k'th conflict happens, set up the parameters, L=2m, m= min (k, 10).
(2) Randomly select one integer r, 0≤r< L, and suppose that the random number could be generated by the function rand ().
(3) Take r time slots back off the interval, and one time slot equals to 2τ, τ is the transfer delay from end to end.
(4) Set up the maximum retransfer times is 16, and if the times are exceeded, retransferring ends and false is reported.
This algorithm is controlled by the order from outing to entering, i.e. the conflict doesn't happens, or the message happens rarely, and it has the probability of preferentially messaging.But the messaging probability of the message that several conflicts happens will be small.

Implementation of the system simulation
By the analysis of the simulation body, the Bus LAN class, the work station class, and message class and the event class could be defined.The definitions of these classes could ensure that the software has good reusability.
To display the schedule of the simulation, this software defines a schedule control, and each message event is processed, the schedule of the schedule control will add one frame.And to dynamically control the simulation process, the software defines a work thread which specially controls the running of the simulation.That could not only quicken the speed of the simulation, but avoid the unresponsive user interface induced by the large background process work, and flexibly control the pause and execution of the simulation process by the suspending and resuming of the thread.

Software testing and simulation result
In the software testing, by the powerful software transfer environment of VC++ 6.0, all solecisms could be found.By testing various functional modules, whether it can realize the anticipated function could be tested, which could basically solve some mistakes in the simulation module functions.
In the simulation, 10 seconds is the time limit, and respectively take each station could complete 5, 10, 20, 30, 40, 50 and 60 messages as the example in one second, to denote different loads and implement the simulation test.By the test, the influences of the messaging probabilities P on the conflict times and the average waiting time could be analyzed under different loads.
The influence of the P value on the conflict time is seen in Figure 2.
From Figure 2, (1) When the value of P is certain, the conflict times will increase with the increase of the load.
(2) When the load is small, the influence of the P value on the conflict times is not obvious.
(3) When the load change to large, if the value of P is bid, the conflict times will increase largely.
The influence of the P value on the average waiting time (μs) is seen in Figure 3.
From Figure 3, (1) When the value of P is certain and the load is in certain range, the average waiting time will increase with the increase of the load.
(2) Under light load, if the value of P is small, the average waiting time will increase largely.

Conclusions
By the discrete event simulation technology and the object-oriented simulation technology, the time slot CSMA/CD protocol modeling simulation based on P-persistent exponential backoff algorithm is established in this article.The simulation result shows that the selection of P value will influence the performance of the network, and to enhance the comprehensive performance parameter of the network, the influences of P values under different loads must be comprehensively considered.And under certain load, when selecting the value of P, not only the conflict times should be less as far as possible, but the average waiting time should not exceed the range.

Figure
Figure 1.Flow Chart of Simulation