Summary of the invention
In order to solve the problems of the technologies described above, the object of the invention is: a kind of optimization method based on time slot CSMA-CA back off algorithm is provided, establish the time slot CSMA-CA Markov chain Mathematical Modeling that has signal priority process and dynamic adjustments parameter function, by revising its avoidance mechanism---processed is adopted to signal priority, according to the method for channel congestion situation dynamic adjustments relevant parameter, to reduce collision and the repeating transmission of data-signal, thus reduce the energy ezpenditure of network, improve real-time and the throughput of network, obtain the performance index being better than former agreement CSMA-CA algorithm.
The technical solution adopted in the present invention is: when certain node needs to send Frame or command frame, enter time slot CSMA-CA back off algorithm, high priority signals/normal signal two kinds of ranks are adopted to distinguish the rank of data, and carry out dynamic adjustments macMinBE parameter according to channel congestion situation during last transformation task and the whether successful situation of task, flow chart after its optimization as shown in Figure 2, specifically comprises following step:
(1) initialization: for high priority signals CW
0value be set to 1, for normal signal CW
0value be set to 2, the value of keeping out of the way times N B is set to 0; The value of CW is set to CW
0, the value of BE is set to macMinBE;
(2) locate back-off period beginning boundary, wait for the beginning boundary of next backoff period;
(3) [0,2
bE-1] get random integers in interval, and postpone should the duration of a random integers back-off period time slot;
(4) perform idle-channel evaluation CCA at back-off period boundary of time slot place to detect, judge that whether present channel is idle, if busy state, then jump to step 6; If idle condition, then enter step 5;
(5) value of CW is from subtracting 1; Judge whether current C W is 0, if be 0, then represent this CSMA-CA competitive channel success and allow node to access channel, jumping to step 7; If be not 0, then jump to step 4;
(6) value of NB is set to CW from increasing 1, CW
0, BE is set to min (BE+1, macMaxBE); Judge that whether the value of NB is more than macMaxCSMABackoffs (maximum CSMA-CA keeps out of the way number of times restriction), if do not exceeded, then jumps to step 3; Maximumly keep out of the way number of times if exceeded, then represent this CSMA-CA competitive channel failure, report an error to upper strata, enter step 10;
(7) enter transmission state, Frame or command frame are sent;
(8) after data are sent, be confirmed whether to need wait acknowledge frame to reply, if needed, wait for the acknowledgement frame representing response in limited time, time-out does not receive the confirmation frame and then thinks that current data sends unsuccessfully, reports an error, enter step 10 to upper strata; If receive acknowledgement frame in limited time or do not need the situation of confirmation of receipt frame, enter step 9;
(9) judging the current data whether also had followed by needing to send, if also have data, jumping to step 7; If do not have data to need to send, enter step 10;
(10) dynamic adjustments macMinBE parameter, CSMA-CA performs end.
Above-mentioned high priority signals refers to that the frame of transmission is command frame or the Frame being no more than 18 byte numbers, and followed by the Frame also needing to send after successfully sending data; Except above-mentioned three kinds of situations, remaining Frame is all normal signal.
In original agreement, the value of macMinBE is that user sets, and above-mentioned macMinBE can carry out dynamic self-adapting adjustment according to the success or failure situation of channel congestion situation during last transformation task and task.Dynamic regulating method is as follows: the variables L of definition channel idle degree, for to detect channel when performing CCA in last time transmission task be idle number of times (NumOfFree) with last transmission task in perform the ratio of the total degree (NumOfCCA) of CCA, namely
and introduce the reference value of the channel idle upper limit (Lmax, this programme is defined as 0.7) and channel idle lower limit (Lmin, this programme is defined as 0.3); As L>=Lmax, channel ratio is more idle, and the value of setting macMinBE is from subtracting for 1 (result is not less than 0); As L≤Lmin or last transmission mission failure, illustrate that channel is busy, the value of setting macMinBE is from adding 1 (result is no more than macMaxBE); When the value of L falls between, the value of macMinBE remains unchanged.
Wherein, the initial value set by macMinBE is 3, and its dynamic adjustments scope is [1, macMaxBE], and macMaxBE's can setting range be [3,8].
The invention has the beneficial effects as follows: use this optimization method, because introduce the setting of priority, sending node is made to have important command frame and shorter Frame to send as early as possible, Frame also can disposablely be sent as early as possible, reduces the node of channel competition use and competes the time delay brought; Include the reception of acknowledgement frame in algorithm flow, judge to send success or not, make communication process more complete; Adopt dynamic conditioning macMinBE, BE initial value is arranged, according to the situation that makes fruitless efforts of channel when offered load and last transformation task, and the success or not of task carrys out Automatic adjusument: when the value of channel compared with busy macMinBE increases, can reduce the probability of data collision; When the value of channel compared with idle macMinBE reduces, shorten back off time, decrease time delay to a certain extent, reduce power consumption, improve the throughput of network.
Embodiment
Below in conjunction with accompanying drawing, the specific embodiment of the present invention is described further:
According to the technical solution adopted in the present invention step, flow chart as shown in Figure 2 (here no longer launch), and establishes a completely newly and accurately Markov chain Mathematical Modeling, introduces signal priority process and dynamic adjustments parameter function.Suppose the star topology network configuration be made up of 1 telegon and n node at, the node wherein sending high priority packets is N
1node that is individual, that send general data bag is N
2individual, and when only considering that node sends information (i.e. uplink communication) to telegon, all nodes all adopt the CSMA-CA mode access channel of band time slot, both without loss of generality, are convenient to research.One of them node of Stochastic choice, adopt three-dimensional discrete joint network model it to be carried out to the foundation of Mathematical Modeling, its one-step transition probability distributed model as shown in Figure 3.Wherein, Definition Model X (t) represents the state when moment t residing for equipment, and function expression is such as formula shown in (1).
Wherein n (t) is the NB value when moment t, and scope is [0, macMaxCSMABackoffs-1]; C (t) is the number of times performing CCA when moment t, and span is { 0,1,2}; W (t) is backoff counter, and span is [0, W
j-1], wherein W
j=2
bE (t), BE (t) is for equipment is in the BE value of moment t.Idle, Send, Fail state represent respectively equipment be in idle condition (not having packets need to send), equipment competitive channel success and enter Packet Generation state (send duration relevant with data packet length, be set to L, using time slot as linear module) and equipment competitive channel status of fail.α, β represent respectively perform first time, second time CCA time channel busy probability.The CSMA-CA algorithm basis of former agreement is optimized, sets up the Markov probability distributed model that has the CSMA-CA of signal priority process and dynamic adjustments parameter function.
If p
0represent that node produces the probability of new data packets, shown in (2), wherein, obeying Poisson distribution arrival rate during supposing each packet is λ
q, q is node type and q ∈ { 1,2}.
Fixed
For Markov chain Stationary Distribution, i.e. b
i, j, krepresent that { n (t)=i, c (t)=j, w (t)=k} probability of stability, for the node of the data-signal of transmission high priority, according to the rule of Markov chain, can obtain following formula (3) to node in state.
Simultaneous formula (2) ~ (3), and all state probability sums of node are 1, can in the hope of b
0,0,0value.
Channel idle during node execution CCA, node sends the probability γ of packet
1:
During node execution CCA, channel busy obtains probability is α:
α=1-(1-γ
1)
n-1 (6)
Simultaneous formula (4) ~ (6), iterative algorithm can be calculated γ
1with the value of α.
In like manner, for the node sending normal data signals, according to the rule of Markov chain, can in the hope of b'
0,0,0value.
Wherein q=alpha+beta-α β.
Channel idle when node performs twice CCA, the probability that node sends packet is γ
2:
During node execution first time CCA, channel busy obtains probability is α:
α=1-(1-γ
2)
n-1 (9)
During node execution second time CCA, channel busy obtains probability is β:
Simultaneous formula (7) ~ (10), iterative algorithm can be calculated γ
2, α, β value.
Owing to adopting the transmit mechanism with priority, when supposing that node sends high priority packets, send the node then back-off delay of general data bag, can not clash between these two kinds of packets in transmission, set up the Markov model of channel, as shown in Figure 4.In Fig. 4, each state transition probability of channel model is defined as follows: α
1without any the Packet Generation of high priority after expression execution first time CCA, proceed to the probability performing second time CCA; β
1represent the probability that after performing first time CCA, high priority packets successfully sends; f
1represent that after performing first time CAA, high priority packets sends failed probability; α
2without any the probability of Packet Generation after expression execution second time CCA, β
2represent the probability that after performing second time CCA, high priority packets successfully sends; β
3represent that after performing second time CCA, lower-priority data is bundled into the probability of merit transmission; f
2represent that after performing second time CCA, high priority packets sends failed probability; f
3represent that after performing second time CCA, lower-priority data bag sends failed probability; Shown in the formula that is calculated as follows (11) of above-mentioned probability.
Definition π
k, T
kbe respectively channel model state (Idle, Busy), (Idle, Idle), the probability of stability of Success1, Success2, Fail1, Fail2 and the time of staying in this state, wherein k ∈ [1,6], has following state balance equation and residence time parameter:
π
3=β
1π
1+β
2π
2,π
4=β
3π
2 (12)
T
1=T
2=1,T
3=T
5=N
1,T
4=T
6=N
2 (13)
Flow S in network is defined as node and successfully sends the time of packet and the ratio of the total time of consumption, can be obtained the network traffics formula of two kinds of different priorities nodes as shown in the formula shown in (14) and (15) by formula (12) ~ (13).
Send the meshed network flow S of high priority packets
1for:
Send the meshed network flow S of general data bag
2for:
And average access delay performance in the present invention program, successfully send the access delay formula of a packet as shown in the formula shown in (16) and (17).
Wherein L
1and L
2represent the transmission average delay of high priority packets and general data bag respectively, the duration of Slot representation unit time slot, to send the speed that packet adopts relevant with node.
Use OPNET network law to carry out emulation in performance and com-parison and analysis to the time slot CSMA-CA algorithm after time slot CSMA-CA algorithm in IEEE802.15.4a agreement and the present invention program's optimization, simulation result as shown in Figure 5 and Figure 6.
What Fig. 5 showed is that two schemes interior joint quantity is to the Different Effects of propagation delay time.When the quantity of nodes is from 5 to 35 change, visible by analysis, have employed the present invention program, transmission delay has had obvious shortening, and data promptness gets a promotion, and especially when node is less, propagation delay time shortens about 7% than original scheme.
What Fig. 6 showed is that in two schemes, business load is to the Different Effects of throughput, and throughput here refers to the average throughput in whole network.When class interval of giving out a contract for a project changes from 0.1s/packet to 1.0s/packet, visible by analysis, have employed the present invention program, when load is less, throughput performance change is little, and when load is larger, performance has had good lifting, the original scheme of its throughput ratio has improve about 33%.
More than that principle foundation of the present invention and better performance are illustrated, but the invention is not limited to described embodiment, those of ordinary skill in the art can also make all equivalents or replacement under the prerequisite without prejudice to spirit of the present invention, and these equivalent distortion or replacement are all included in the application's claim limited range.