Citation
Traffic monitoring and capacity allocation for heterogeneous wireless networks

Material Information

Title:
Traffic monitoring and capacity allocation for heterogeneous wireless networks
Creator:
Zaid, Khaled J. M
Publication Date:
Language:
English
Physical Description:
vii, 102 leaves : ; 28 cm

Subjects

Subjects / Keywords:
Local area networks (Computer networks) -- Traffic ( lcsh )
Ad hoc networks (Computer networks) ( lcsh )
Resource allocation ( lcsh )
Wireless LANs ( lcsh )
Wireless communication systems ( lcsh )
Ad hoc networks (Computer networks) ( fast )
Local area networks (Computer networks) -- Traffic ( fast )
Resource allocation ( fast )
Wireless communication systems ( fast )
Wireless LANs ( fast )
Genre:
bibliography ( marcgt )
theses ( marcgt )
non-fiction ( marcgt )

Notes

Bibliography:
Includes bibliographical references (leaves 100-102).
General Note:
Department of Electrical Engineering
Statement of Responsibility:
by Khaled J.M. Zaid.

Record Information

Source Institution:
|University of Colorado Denver
Holding Location:
|Auraria Library
Rights Management:
All applicable rights reserved by the source institution and holding location.
Resource Identifier:
747426736 ( OCLC )
ocn747426736
Classification:
LD1193.E54 2011m Z34 ( lcc )

Full Text
H
TRAFFIC MONITORING
AND CAPACITY ALLOCATION
FOR HETEROGENEOUS WIRELESS NETWORKS
by
Khaled J M Zaid
B.S.E.E., Omar Almuktar University 2003
A thesis submitted to the
University of Colorado Denver
in partial fulfillment
of the requirements for the degree of
Master of Science
Electrical Engineering
2011


This thesis for the Master of Science
Degree by
Khaled J M Zaid
has been approved
By
Titsa Papantoni, PhD
Hamid Fardi, PhD
Bialasiewicz, Jan, PhD
h(


Khaled Zaid (Master of Science, Electrical Engineering)
Traffic Monitoring And Capacity Allocation For Heterogeneous Wireless Networks
Thesis Directed by Professor Titsa Papantoni.
ABSTRACT
We consider distributed traffic monitoring for the dynamic allocation of wireless
network resources to heterogeneous traffics. The performance analysis of the
Distributed Traffic Monitoring Algorithm (DTMA) is undertaken, when deployed at a
fusion center network structure, where locally distributed nodes are connected to a
fusion center. The Distributed Traffic Monitoring Algorithm (DTMA) utilizes raw
nodal data as well as decisions conveyed to the fusion center by the distributed nodes,
to detect changes in traffic characteristics and rates and to subsequently adapt channel
capacity allocations accordingly. The DTMA induces algorithmic couplings that
accelerate the decision process, as compared to the non-distributed version of the
Traffic Monitoring Algorithm (TMA): the rate by which correct decisions are made
increases, at the expense of increased rate in erroneous decisions as well.
Approved by:
Dr. T/tsa Papantoni


ACKNOWLEDGEMENT
All praise is due to Allah for his blessing and guidance.
I would like to take this opportunity to express my deep gratitude to Dr. Titsa
Papantoni, my academic and research advisor, for her guidance and assistance
throughout this thesis. I also continue to be highly indebted to Dr. Titsa Papantoni for
her infinite patience and understanding. I would also like to thank my family and
friends who supported me to successfully finish this work.
I also pay tribute to everyone at the Electrical Engineering Department, especially
those who participated in the Friday meetings, for creating the environment that is
research- conducive and thought- provoking. Finally, I thank my thesis committee for
their reading of and the inputs to this thesis.


TABLE OF CONTENTS
Figures.........................................................................vii
Chapter
1. Introduction..................................................................1
1.1 Motivation and Discussion.....................................................1
1.2 Organization of Thesis.......................................................2
2. System Background.............................................................3
2.1 System Model.................................................................3
2.2 Basic Transmission Rules.....................................................5
2.3 Basic principles and protocols...............................................6
2.3.1 Capacity allocation and transmission under static traffic conditions.......7
2.4. The Sequential Algorithms for the High-Level Protocol.......................10
2.4.1 The sequential monitoring system for voice.................................11
2.4.2 Performance Characteristics of a Simple Algorithmic System................13
2.5 System performance issues...................................................15
2.5.1 Stability in the absence of admission delay constraints....................15
2.5.2 Stability in the presence of admission delay constraints...................19
2.5.3 The channel utilization versus traffic rejection tradeoff.................21
2.6 The Distributed Traffic Monitoring Algorithm................................24
2.6.1 Performance Characteristics of the DTMA....................................28
3. Numerical and simulation results.............................................32
v


3. 1 Numerical results...................................................32
3.1.1 Models in the numerical results.................................... 32
3.2 Simulation Results...................................................36
3.2.1 Simulation of TMA and DTMA.........................................36
3.2.1.1 Simulation of first Transmission policy for both TMA and DTMA....37
3.2.1.2 Simulation of second Transmission policy for both TMA and DTMA...40
4. Conclusion............................................................44
Appendix
A. MATLAB Program for TMA First Transmission Policy.....................45
B. MATLAB Program for DTMA 2 nodes First Transmission Policy............55
C. MATLAB Program for DTMA 4 nodes First Transmission Policy............60
D. MATLAB Program for TMA Second Transmission Policy....................65
E. MATLAB Program for DTMA 2 nodes Second Transmission Policy...........78
F. MATLAB Program for DTMA 4 nodes Second Transmission Policy...........92
G. Proof of Theorem 1...................................................94
H. Proof of Theorem 2...................................................96
I. Proof of Theorem 3...................................................98
J. Proof of Theorem 4...................................................99
References..............................................................100
VI


LIST OF FIGURES
Figure
2.1 Pictorial presentation of the capacity allocation policy. HSD: high speed data,
LSD: low speed data.
2.2 Distributed Decision Network
3.1 Rejection rate with first transmission policy
3.2 Wasted Capacity rate with first transmission policy
3.3 Average Delay with first transmission policy
3.4 Rejection rate with second transmission policy
3.5 Wasted Capacity rate with second transmission policy
3.6 Average Delay with second transmission policy
VII


1. INTRODUCTION
1.1 Motivation and Discussion
We are concerned with the problem of traffic management, among heterogeneous
multimedia sources over a common digital transmission channel. Our objective is the
satisfaction of the quality of service (QOS) requirements dictated by the
heterogeneous traffics, with the simultaneous high-level utilization of the network
resources [1]. Towards the fulfillment of this dual objective, the design and
deployment of efficient traffic management and traffic multiplexing [2] [3] [4]
techniques are necessary. In our heterogeneous wireless network, where traffic rates
are time-varying, the dynamic capacity allocation of the network resources to the
various heterogeneous traffic should be an important characteristic of any deployed
traffic management technique. To facilitate such a characteristic, we deploy a Traffic
Monitoring Algorithm (TMA), implemented by a higher level protocol, whose
decisions dictate the capacity allocations to various traffics [2], In real time
applications, the Traffic Monitoring Algorithm (TMA) may be overlying on either a
Framed CDMA (FCDMA) or a Framed Time-Domain-Based (FTDB) multiplexing
technique, deployed for the transmission of the multimedia traffic. In conjunction
with a specific transmission policy per traffic class, the TMA induces a traffic
rejection rate versus wasted capacity rate tradeoff, whose quantitative balance may be
controlled via the selection of the TMA operational parameters: a set of decision
thresholds. In this research, the TMA is extended to operate in a distributed
environment [5], The properties of the Distributed Traffic Monitoring Algorithm
problem discussed here collect the data from physically distributed locations. At each
1


location, a node processes local data together with feedback from the central
processor, called Fusion Center. Each local sensor sends its decision to the Fusion
Center. The Fusion Center collects all the decisions from all the sensors and makes
the final decision. The properties of the Distributed Traffic Monitoring Algorithm
(DTMA) are evaluated. The Traffic Monitoring Algorithm (TMA) considered in this
work was first advanced in [3] and was further expanded, analyzed and utilized in [1],
[7], [8], as a centralized monitoring mechanism operating on local external traffic
arrival data, while the Distributed Traffic Monitoring Algorithm (DTMA) first was
proposed and analyzed in [5] in the sense of rejection rate, capacity wasted and the
average delay. This thesis explore the design of dynamic capacity allocation
techniques for the transmission of heterogeneous traffics through a single common
channel, deploying the Distributed TMA and evaluate the system in the sense of
rejection rate, capacity wasted and the average delay.
1.2 Organization of Thesis
The thesis is organized as follows: Chapter 2 provides an overview of the system,
Basic Transmission Rules, The Sequential Algorithms for the High-Level Protocol,
discussion about and the Distributed Traffic Monitoring Algorithm and its
performance characteristics. Chapter 3 we will use the baseline models developed in
Chapter 2 to provide the numerical and simulation results. Chapter 4 puts forth the
conclusion and also lays directions for future work in this area.
2


2. BACKGROUND
2.1 System Model
We consider a single transmission channel whose time is divided into
identical slots, where each slot corresponds to the transmission of a single
information packet. We consider the case where the channel is shared by digitized-
voice, video, high speed data and low-speed data traffic streams, where these streams
are in the form of information packets and where all packets, both interstream and
intrastream, have identical lengths. We assume that the low-speed data traffic does
not impose any specific delay/ rejection constraints [8], Thus, in the presence of
voice, video, high speed data traffic, data traffic may yield for the benefit of voice,
video, high speed data traffic. The voice, video, high speed data traffic stream may be
generated by a number of independent voice, video, high speed data users and is
comprised of digitized messages, each of which consists of a sequence of packets.
The constraints imposed by the voice, video, high speed data traffic are as follows:
The QOS requirements and Characteristics for voice
The QOS requirements and characteristics for voice are as follows:
1- Each generated voice message imposes a finite upper bound A on the admission
delay it may tolerate; that is on the time period between the time instant it arrives
into the system and the time instant when a communication path is established for the
transmission of its head packet.
2- At the destination end, consecutive voice data packets within a single message
must maintain an interpacket distance /delay which does not exceed 2. This
3


constraint corresponds to undetected jittering. The constant B is normally equal to a
multiple of a packet length and the admission delay bound A is a multiple of B.
3- Each voice message tolerates no more than probability p of rejection, where
rejections occur if either one of the constraints in (1) and (2) are violated.
4- The arrival process of voice messages and the distribution of message lengths may
take various forms. Arrival rated may be also time-varying.
The QOS requirements and Characteristics for video
Qualitatively speaking, the QOS requirements per video message are parallel to those
for voice. Specifically, an upper bound, C, on the admission delay per message and an
upper bound, a, on the probability of rejection per message apply here as well, and so
does a bound shorter than the corresponding constant for voice messages (more rigid jittering
constraints), while rejection occurs under conditions parallel to those for voice.
Arrival processes for messages and distributions for massage lengths may again take
various forms, and arrival rates maybe time-varying.
The QOS requirements and Characteristics for High Speed Data
The QOSs for high speed data files/messages are similar to those for voice and video,
but quantitatively different. The constraints A, B and P for voice are here substituted
by £, T and Q respectively. Variations in arrival processes, distribution s in massage
lengths, and arrival rates apply here as well.
4


The QOS requirements and Characteristics for Low Speed Data Low speed
Data do not impose specific constraints on admission delays or interpacket distances
and rejection rates. It is desirable, however, that rejection rates be controlled and that
admission delays be finite [1],
2.2 Basic Transmission Rules
Without any reference to a specific low-level multiplexing protocol, at this point, we
adopt the following basic rules for the transmission of the heterogeneous traffics over
the common channel:
1- Individual packets from any traffic class are transmitted synchronously; that is, the
transmission of a packet starts at the beginning of some channel slot.
2- LSD packets are accommodated on the first come-first serve basis; that is, a data
packet is not considered for transmission at times when earlier data packet arrivals are
in storage.
3- Within a given traffic class (voice, video, or HSD), head packets of message are
accommodated on the first come-first serve basis; that is, the head packet of a
message is not considered for transmission at times when the head packets of earlier
message arrivals from the same class are in storage. In a single message, the packets
are transmitted in the order they arrive, and the instant when the transmissions of
consecutive packets begin are in distance/ delay constraint for jittering.
5


2.3 Basic principles and protocols
We adopt the scenario where the rates of the various heterogeneous traffics may be
time-varying, and the general objective is the development of effective multiplexing
techniques which satisfy the QOSs at the various traffic classes, without inducing
unnecessarily high implementation overhead. The fundamental simple idea, first
developed in [8], is as follows. If the statistics of all traffic classes are parametrically
known and remain unchanged, then a deterministic capacity allocation policy per
traffic class can be devised, which satisfies the QOSs of all traffics and
simultaneously attains high utilization of the medium/channel resources. If, instead,
the rates of the various traffics may occasionally change, then, the deployment of a
high-level protocol which monitors such changes may dictate subsequent appropriate
adaptations of the corresponding capacity allocations. Given a statistically sound and
thoroughly evaluated high-level traffic monitoring protocol, a high-performance
system for traffic monitoring/capacity allocation/ transmission multiplexing may arise
under certain traffic conditions, which, weighing all factors, outperforms both fully
dynamic (per cell) policies and fully static-peak rate-allocation policies. We note that
in flexible terms, the combination of a traffic-monitoring high-level protocol and of a
multiplexing low-level protocol is stable, if the traffic rates are maintained (the traffic
classes be accommodated) in terms of the satisfaction of the corresponding QOSs.
That is, in flexible terms, stability generally allows for partial rejections, as long as
their fractions (across different traffic classes) do not exceed those permitted by the
corresponding traffic QOSs. On the other hand, in strict terms, stability implies no
rejections and finite admission delays, without specific considerations of upper
bounds on the latter, as those imposed by the QOSs of the voice, video and high
speed data traffic classes [ 1]. To make the fundamental concepts concrete, we first
proceed with the full description of the proposed capacity allocation and multiplexing
transmission policies, under static traffic conditions.
6


2.3.1 Capacity allocation and transmission under static traffic conditions
Let us consider the scenario where the statistics of the voice, video and high speed
data traffics are parametrically known and expected to remain unchanged. Let then,
Av, Avi and A^denote the rates of these traffics, respectively, all at the cell (and not the
fiber) level, where rates are measured in cells or packets per slot. Let also ( Av,Avi,
Ah) < 1 to allow for transmission of some low speed data traffic as well. Then, a
deterministic capacity allocation policy can be deployed, for all four traffic classes,
which satisfies all traffic QOSs with simultaneous full steady-state utilization of the
channel resources. Specifically:
(1) Given the ratesAv, Avi, Ah as well as the parametric statistical descriptions of the
voice, video, and high speed data traffics, functions ),/y,(.), /^(.) can be
determined such that, if fhi-) percentages of the channel capacity are
allocated to the respective traffics, then, the three traffics can be all maintained in the
sense of their admission delay and rejection constraints being satisfied. In addition, if
fv(A) + fvi{ Avi) + fh{Ah) < 1, then, the remaining fraction of the channel capacity
can be assigned to the low speed data traffic.
7


Figure 2.1.Pictorial presentation of the capacity allocation policy. HSD: high speed
data, LSD: low speed data.
(2) Having the functions fv(Av), fvi{ and well established, consider the
interpacket delay/distance constraints, B, D, for voice and video messages,
respectively and define, Z = min { B,D, F} Then, create consecutive channel time
frames of length / measured in slot units, and assign lfv(Av), lfvi(\vi)and L fh(Ah)
slots per frame for voice, video, and high speed data, respectively; assign the
remaining slots per frame to the low speed data traffic (see Figure 2.1). The reason
for the creation of the frames is the satisfaction of the inteipacket delay/ distance
constraints of the involved traffics. This will become clear from the multiplexing
transmission policy stated in the sequel.
Given the capacity allocation policy, explained by steps (1) and (2) above, the
Specifics of the transmission policy for voice, video and high speed data traffics
remain to be stated. As to the low speed data traffic, packets are simply transmitted
on the first come-first serve basis, within the portions of each frame that are assigned
to it. We now describe the transmission policy for the voice traffic, within the frame
8


portions designated to it; the transmission policies for video and high speed data are
similar. Let {T£}k denote the time instants corresponding to the beginnings of
consecutive frame portions allocated to voice; clearly, as exhibited in Figure 2.1,
consecutive such portions lie in consecutive frames and their beginnings are in
distance l from each other. In this thesis, we use two different transmission policy
rules for the voice traffic, which it will be as follows:
First Transmission Policy Rule:
Rule 1: At each point in time, no more than lfv(Av)vo\c& messages can be in the
transmission stage; that is, partially transmitted. Rule 2: In each frame portion, only
voice messages that are waiting at its beginning may be partially transmitted
(messages either in the transmission stage or not).Possible message arrivals during a
frame portion are not considered until the beginning of the next frame. Rule 3:
Consider the time 77when the (t + 1 )th frame portion begins. At Tf, let k <
lfv(Av) voice messages be in the transmission stage, and let n additional messages be
in the queue (all not having exceeded their waiting time constraint).
(i) One packet from each of the k messages that are in the transmission stage
is first transmitted, on the first-come first-served basis regarding the
arrival instant of each message (arrival of head-packets per message).
These transmissions occupy the first k slots in the frame.
(ii) (ii) If k + n > lfv{Av) then, for j 6 {1, ,...,lfv{Av) k},the (k +j)th slot
of the frame is assigned to the transmission of the head-packet of the jth
(in the order of its arrival instant) voice message among the n messages
waiting in the queue at Ti, so that lfv(Av) k messages move to the
transmission stage.
9


(iii) If k + n < lfv (Av) then the n slots in the frame which follow its first k slots
(assigned in (i)) are assigned to the transmission of the head-packets from the n
queued (at Ti) messages, in the order as that in (ii). In this case, n new messages
move to the transmission stage.
Second Transmission Policy Rule:
The second transmission policy has the same steps as those in the first transmission
policy, expect that, after step (iii), we add after the following rules:
1- At the end of the (k + n)th slot of the frame, if p out of the (k -I- n) voice messages
are still in the transmission stage (their transmission has not been completed), then the
next min (p, lfv(Av) (k + n)} slots are assigned for the transmission of one packet
from each of the p messages (or some of them, if p > lfv(Av) (k + n) in the
same order as that with the (k + n)first slots of the frame.
2- The process in (1) is repeated until either the lfv(A.v) slots dedicated to voice traffic
are exhausted, or all the k + n messages are fully transmitted, whichever comes first.
Some of the (/V(AP) slots in the frame remain unused only if all the k + n messages
are fully transmitted before these slots are exhausted.
2.4 The Sequential Algorithms for the High-Level Protocol
The objective of the high-level protocol is to be monitoring each of the voice, video
and HSD traffic streams of cells at the concentrator's input, to identify shifts in the
corresponding rate regions, for subsequent appropriate capacity allocation per traffic
and frame. Each of the above three traffic streams is monitored independently from
the others; it thus suffices that the algorithms for the monitoring of one of the traffic
classes, say voice, be described. Let us concentrate on the voice traffic. We assume
10


that changes of the acting rate regions may occur at any point in time. Lacking any
information as to the underlying process that induces such changes, we adopt the
worst scenario where they may occur independently and equiprobably, in terms of
instants of occurrences. Our objective is the development of sequential algorithms
which continuously monitor arrivals at the cell levels, to identify shifts in rate
regions. Given that at some point in time the rate region (Ak ek, Ak + £k) has been
decided as just being starting to act, the monitoring system immediately starts
implementing sequential procedures, to detect a possible shift from the rate region
(Ak £/o Ak + £k) to either one of the remaining n 1 rate regions. In section
2.4.1, below, we describe the sequential monitoring system for voice, under certain
assumptions regarding the voice traffic arrival process.
2.4.1 The sequential monitoring system for voice
Since the sequential monitoring algorithms dictate the capacity allocations per frame,
we update their operational values only at time instantsC^ > 0, when channel
frames begin. Let us denote by {5,}; > Othe subsequence of {T,-},- > 0, such that
T0 = S0 the beginning of time when the system starts operating and is the
instant (corresponding to the beginning of some frame) when the monitoring system
decides that a shift in the acting rate region has just occurred. Let us assume that,
given any fixed rate Ak, the voice arrival process (in packets or cells) is stationary,
and let then {^(n^......,nq)} denote its ^/-dimensional distribution in frame lengths;
that is, gk(nlt...,nq)is the probability that, in a sequence of q consecutive frames,
nx cell arrivals occur in the first frame, and so on, with nq cell arrivals finally
occurring in the q th frame, given that the active rate is Akthroughout. Let us assume
that the distributions {gki^,..., nq)} are well-known for all k's (or Xk s). Then, we
propose the following sequential traffic monitoring system:
11


1. The algorithmic system implementing the high-level traffic monitoring protocol is
designed at the central rates Xlt X2, > f the corresponding rate regions(Ax
£1,X1 + S-l), (A2 £2>^2 + £2)>... (^n £n>^n + £n)-
2. Let at some the rate Ak be decided as just starting to be acting. Then,
immediately (at 5j) a set of n 1 parallel algorithms starts operating, all using a
reflective threshold at zero and a common decision threshold, r]k. They-th such
algorithm is monitoring a possible shift from the rate Xk to the rate Xj, (where Xk *Aj)
sequentially, with adaptations occurring at beginnings of frames. Let Vkj(0) denote
the operating value of the algorithm monitoring a {(Ak -> Xj)} shift at time S), when it
starts operating; let % (r)denote its operating value at its r-th adaptation step. Then,
the operating values of the algorithm are sequentially updated as follows:
14; (0) 0
Vkj(r + 1) = max
{o.Vkj(r) + log (
g;(nr + l|n1,...,nr)
5k(nr+l|ni........nr)
))
(2.1)
5; is then the first time after S* that one of the above n 1 parallel algorithms first
crosses the common decision threshold r]k. If the latter algorithm is the one which
monitors a ( Xk -> Xp) shift, then, the algorithmic system decides that the rate Xp
starts acting at 5,- + 1. At St + 1, a set of n 1 parallel algorithms, each monitoring a
shift from Xp to one of the remaining rates, becomes initialized. The latter
algorithmic system has operational characteristics as those stated above.
Remarks.
(1) The monitoring systems for the video and high speed data traffics have the same
forms as that for voice, where the same stationary assumptions are made regarding
their arrival processes.
(2) When the arrival processes of the traffics are memoryless, the conditioning in the
updating steps of the algorithms, as in (2.1), disappears. Then, no memory is required
12


in the operations of the algorithms, while their implementations also include minimal
complexities.
2.4.2 Performance Characteristics of a Simple Algorithmic System
In this section, we discuss the performance characteristics of a simple single shot -
system of parallel algorithms, each monitoring a shift from a given and fixed rate, say
/Ifcfor voice, to another such rate among n 1 in total. The presented characteristics
are direct consequences of the results in [9].Let us consider the distinct rates
Alr...., An and the corresponding arbitrary dimensionality-distributions fx, of
the arrivals, as defined in section 2.4.1. For given ratesA-L, ....,A, let the latter
distributions be well known and consider then the algorithmic system of n 1
algorithms, each monitoring a change from a fixed rate Ak to one of the remaining
rates. As stated in section 2.4.1, the {Ak Ayjalgorithm utilizes the observed per
frame number of arrivals and the distributions fk()and ) in its updating steps in
the form of log ratios (see (2.1)) and the parallel algorithms utilize a common
threshold j]k. We now' state a lemma, whose proof is a direct consequence of the
derivations and results in [9],
Lemma 1. Let the distributions fx, satisfy 0-mixing conditions as those in [9],
and consider the system of the n 1 parallel algorithms (Ak -> Ap}, p ^ k, from the
time instant when they start operating. Let the rate A, be acting throughout the total
observation time interval, and let then denote the stopping variable of
the(Afc -> Aj}, algorithm, given the decisive common threshold rjk\that is, Nkj\s the
random variable denoting the number of frames needed for the (Ak -* Ayjalgorithm to
first cross the threshold rjk, when arrivals are generated by the distribution/process
fi throughout. Then,
13


(2.2)
lim N,
Ufc-A.}
rh.
2 '
log (Vk)
KHi/fk) m/fj)
if m/fk) m/fj) < o
ifKifi/fk) K(fi/fj) < 0
Where K(fp/f) is the Kullback-Leibler number [10] of the distribution/process fp,
with respect to the process /,, subject to the existence of the latter number. As a direct
consequence of (2.2), when the rate At (At ^ Ak) acts throughout, then,
asymptotically (for rjk oo), the [Ak Aj] algorithm stops first, in the expected
stopping time sense. That is, for /^acting throughout, and A, =£ Ak
lim
Vk-
ml-
log Ofk)
Ayl^ Kifdfk)
< lim
; v xi A; xi **
Vk~
(2.3)
If Ak acts throughout, on the other hand, the expected stopping time of each {Ak Aj)
j =£ k algorithm is asymptotically (rjk -> oo) of the same order with that of the
threshold value.
Proof
For r/fc -> co, the expected stopping time of the (Afe -> Aj) algorithm is determined by
the expected value of its updating step. When f is acting throughout, the latter
expected value is / f log (y-) = K{f/fk) K(f/fj). Subject to existence of all
the Kullback-Leibler numbers and the satisfaction of the tp-mixing conditions in the
statement of the lemma, expression (2.2) is a direct result of the derivations in [9].
Remarks. From the results in the lemma, we conclude that, for {Aj -> Afc], the fastest
expected stopping time is of \og(jik) order, while the slowest is of ?/feorder; thus,
asymptotically, the fastest expected stopping time is exponentially faster than the
14


slowest. From the results in the lemma, it is also clear that the Kullback-Leibler
numbers play an important role in the performance of the algorithmic system. Finally,
given that a rate Aj =£ Ak is acting throughout, the algorithmic system of the n 1
[Ak -* Xj),j ^ k algorithms will asymptotically (rik oo) decide in favor of the
acting rate At, in the expected stopping time sense; indeed, in the latter sense, the
matching to /^algorithm,{/lfc -> Aj], will asymptotically (rjk oo) cross the
threshold r]k first. At the same time, when Ak acts throughout; that is, w'hen no shift in
rate occurs, the asymptotic expected stopping time of the overall algorithmic system
(all n 1 parallel algorithms) is of logarithmic order of the same time needed when
some rate different than Ak acts throughout; that is, when a shift in rate has actually
occurred. Therefore, in general, the algorithmic system induces powerful correct
detection and false alarm properties, at least in the asymptotic (rjk -> oo) sense.
2.5. System performance issues
We consider the case where there is always sufficient channel capacity for the
accommodation of the voice, video and high speed data traffics, even when the
highest rates of all these traffics are acting. Then, the low speed data traffic is simply
accommodated in the remaining slots per frame (see figure 2.1). Subject to the above
assumptions, the three traffic monitoring systems appear basically decoupled
regarding certain performance issues, such as stability in the absence or presence of
admission delay constraints. In the remainder of this section, we precede with the
analyses of the various system performance issues, in a systematic fashion.
15


2.5.1 Stability in the absence of admission delay constraints
Due to the sufficient capacity assumptions stated in the beginning of section 2.5,
regarding stability, the three traffic monitoring/capacity allocation systems, for voice,
video, and high speed data are decoupled. It thus suffices to study the stability
conditions for one of the three systems, first in the absence of admission delay
constraints. Addressing the arbitrary system (either one of the three), we will use
general terminology stated below.
Let Ce (rj); i = 0,1,.., (M 1), denote disjoint rate regions, respectively, centered
around the rates r(; i = 0,1,., (M 1). Let the traffic monitoring system be
designed at the latter central rates. Let r/; i = 0,1,., (M 1) denote the acting
rates, where r/ G Ce (rj); V i. Let us assume that the arrival processes, in cell/packets
per slot, are all memoryless, and let the process which generates the actual rate shifts,
from some r- to some rj be homogeneous Markov. Let r,- < r^+1; V i. Let us then
define:
£{7,} the expected length, in slots, during which the rate r( is continuously acting;
y( : The percentage of observations generated by the rate r/ in a given sample size,
y: the vector [y0, Yi, Ym-il-
the vector [r^r/, ....,^-1)
Consider the traffic monitoring system with given thresholds r\k\k = 0,1,..., (M
1), where r/k is the common threshold of the (M 1) parallel algorithms monitoring
a change from the rate rk to any one of the remaining rates r7 ; j A k Let us then
define:
E{N{r.^r }/fY- the expected value of N given that the rate vector r' appears
in the percentages form y, where N(r._,r }, denotes the stopping time of the algorithm
which monitors a r, > r; shift.
16


(2.4)
{Nmin/r'} = min{m_inE{N{ }/f}}
rp*rq Y w H1
iNmax/rl = mrp*rq{X?{E{N{rq_rp]/Y}}}
Then we propose the following theorem
Theorem 1. Let all the assumptions in section 2.5.2 hold, and let
< oo V Tj, Tj.y-
Then, for stability of the traffic monitoring/capacity allocation system in the absence
of admission delay constraints; that is, for maintaining then all traffics with finite
delays, it suffices that:
yM-lrc\irm ryind(rm,rm)
ZJ7n=oLt'vmm/' J lZjn=0
rm)E{/}] + {fC*A')E
M 1
n=[ind(rln,rm)+1]

rm)E{ln}]] <0
(2.5)
Where {N1^n/r'}, (Almx/r'} are given by (2.4) and where,
?n 1; for < rm
ind(r^,rm) = j
m; for r^ > r7
A necessary condition for stability is
ind(r}n,rvl)
(2.6)
rm)E{Z)l] <0 (2.7)
Remarks.
(a) The sufficient and necessary conditions for stability in theorem 1, relate
performance characteristics of the traffic monitoring algorithms with rates of the
arrival processes and characteristics of the process which controls the actual shifts in
rates. Both conditions basically require relative burstiness of high rates, for stability.
(b) In the case that ri+x rt = d V i and all monitoring algorithms are using identical
17


thresholds, equal to T]k, then, asymptotically; that is, for (T]k -* oo), using the
approximations (77 log (77) 77 and Nmax~ri for the conditional expected stopping
times (see section 2.5.1), the condition in (2.5) can be written as
Zn=i n(n + l)E{ln] login) <2 8)
Expression (2.8) basically states that, asymptotically, the sufficient condition for
stability requires then that the expected time periods during which the lowest rate acts
is exponentially longer than the same combined weighted periods for all the
remaining higher rates.
(c) The sufficient and necessary conditions in theorem 1 include the expected
stopping times, {N^x/r'}and [N^n/r'} in (2.4). As deduced from lemma 1 in
section 2.5.1 and the following remarks, these stopping times include Kullback-
Leibler numbers. In particular, for algorithmic thresholds (77^ } such that, t]k 00,
and directly from (2.4) and (2.2) in lemma 1, we obtain
lim f7Vrq /?} =___________________________________________> log(7?q)......- (2 9)
^->0 mm maxrp,rq{maxr,[fc(r//r£;)-k(r//rp)J} maxrj k(r[/rq)
INli/r'} (2.10)
where /c(rj/r;)denotes the Kullback-Leibler number of the arrival process with rate
r;, with respect to the arrival process with rate 77 .From expressions (2.9) and (2.10),
in conjunction with those in theorem 1, we clearly see the important role of the
Kullback-Leibler numbers in the stability conditions of the traffic
monitoring/capacity allocation system. The larger these numbers, the looser the
necessary constraints on the time periods during which high rates act.
(d) For Poisson (in packets per slot) arrival processes, we easily find the following
expressions:
18


(2.11)
In ()]
Kn/rq) = rq[l
'H * ;(rm) = rmmaxr;{[l-i + i|n(i)]j
(fl + In
tL rm rm \rmJ r
M-i +^i,n

(2.12)
2.5.2 Stability in the presence of admission delay constraints
In section 2.5.1, we studied the stability conditions in the absence of admission delay
constraints. As discussed in section 2.2.1, however, the QOSs of the voice, video, and
high speed data traffics require that a given admission delay per message not be
exceeded with a given probability. This requirement induces stability constraints that
are tighter than those in theorem 1 of section 2.5.1. In this section, we study stability
in the presence of admission delay constraints, subject to the assumption of sufficient
capacity availability, as stated in the beginning of section 2. 5; it thus suffices to study
such stability for the arbitrary system. We use the same notation as in section 2.5.2
and we define, in addition:
/(r;) the function determining the capacity allocation per frame, for traffic rate
r; (see figure 1);
Pr'(/(r/)) lhe probability that at most f(jj) packets per slot are generated, given that
the rate r- is acting.
Then we propose the following theorem
Theorem 2. Let all the assumptions in theorem 1 hold. In addition, let it be required
that a given upper bound on the admission delay per traffic message not be exceeded
with probability at least 1 5. Then, a sufficient condition for the satisfaction of this
constraint is
19


Ml
I
7 = 0
ri,s(rj'>
{Nmin/r'} Yj
( = 0
Where
M1
+ (Nl,/?) £ £{!,}[(!--pr;/fc)]
I=ri's(r/) + 1
< 0 (2.13)
A necessary condition for the satisfaction of the constraint is
M-1
X
i=n
ris(r y)

f/r'} ^ £{/,}[(!- 5) -pr;f(rj)]
i=0

< 0 (2.15)
where £{/;}, {N^ax/r'} and {N^iax/r'} are as in theorem 1.
Remarks.
(a) We point the attention of the reader to the fact that the specific upper bound on the
admission delays does not appear in the conditions of theorem 2. The reasons should
be clear from the arguments in [ 11 ].
(b) When the stability of voice versus video versus high speed data is studied, the
function/(ry) in (2.13)(2.15) is substituted respectively by /y(ry). /y;(ry)and /h(r;-)
(see figure 1).
20


(c) The sufficient and necessary conditions in theorem 2 have similar forms with the
sufficient and necessary conditions for stability in theorem 1, only that the former are
stronger. Qualitatively speaking, the remarks after theorem 1 hold here as well. High
acting rates must be relatively bursty and the role of the Kullback-Leibler numbers is
crucial with effects as those stated for theorem 1.
2.5.3 The channel utilization versus traffic rejection tradeoff
The traffic monitoring/capacity allocation system inevitably induces some waste of
channel capacity. Such waste occurs when at least one of the three traffics is allocated
more capacity than needed; that is, when, for at least one of the three traffics, the
acting rate is lower than that decided by the traffic monitoring system. The
probability of capacity waste events is strictly positive, and specifies the fraction of
capacity wasted; one minus the latter fraction is defined as the Channel Utilization
Factor (U). Subject to the assumption of sufficient capacity, as stated in the beginning
of section 2.5, and using the notation of section 2.3 (see figure 1), we easily find
where fh() are the capacity allocation functions for the voice, video,
and high speed data traffics, where rates with primes denote acting rates while the
absence of primes denotes rates decided by the traffic monitoring systems, and where
p(A',X) denotes the probability that A' is acting and A is deduced by the monitoring
system. Let us now consider the rate regions defined in section 2.3.2, and consider
the case where the central rates in each region may be acting. In addition, let us
i -u= \UAV) ua'v)]p(K.K)
+ lxh>x'h\fnUh)- fhWWM
(2.16)
21


consider the algorithmic quantities in (2.4), as well as the pertinent assumptions and
derivations in theorems 1 and 2. Then, we can easily derive the following bound of
the expression in (2.16):
n-1 n
j=li=j+l k
m-1 m
+ Z Z ~ [Z( j=l i=j+1 k
P-1 P
Z Z [Zm,n/i)]_1 >1 u (2-m
;=1i=j+l k
where for {£);{/,}, {{Zy},{}, being the expected lengths during which the rates
; for voice, ; for video, and [,ik ; for high speed data are respectively acting,
Yv,j = EvMl'Zk Evik)]^ and similarly, for y^-yand yKj. Also, {N^maJX],
{A/^(71/I}are the quantities in (2.4) for the voice traffic monitoring algorithmic
system, and the corresponding quantities with the subscripts vt and h, instead of v,
apply to video and high speed data, respectively. In the expression in (2.17), if min
and max are interchanged (whenever appearing), then, a lower bound on (1 U) is
obtained, instead. Taking a different viewpoint than those in sections 2.5.1 and 2.5.2,
let us now consider an instantaneous measure of Traffic Rejection Rate r. In
particular, let us define r as the fraction of traffics rejected due to instantaneous
insufficient capacity allocations. Then, parallel to the rationale for the derivation of
(2.16), we find
= ^ [fv(K)-fvav)MKM



22


(2.18)
^'h>^h
Where the notation in (2.18) is as that in (2.16). As with (2.16), we can find lower
and upper bounds of (2.18). Below, we express the upper bound, where the notation is
the same as that in (2.17):
^max I max mnx
rv + rvi + rh
;where
(2.19)
^ 771 ax __
rv ~~
n~ 1 n
j=1i=j+1
k
/*})
-1
m-l m
j=1 i=y+l fc
P-1 p
rm = £ £ - fh{n,)]ykU{N"maji} [^KLyTir1 (2.20)
j 1 i=j+1 k
It is not hard to see that the Traffic Rejection Rate, and the Channel Utilization
factor U, are involved in a tradeoff. Indeed, the higher the Capacity Waste Ratel U,
the lower the Traffic Rejection Rate, r, and vice versa. In fact, a convex constraint
optimization problem arises, if the minimization of 1 U is sought, with respect to
the selection of the thresholds in the traffic monitoring systems, subject to r being
bounded from above by a given constant. Given all traffic characteristics, this
approach was taken in [8] for the selection of non-asymptotically large thresholds, in
a traffic monitoring system for voice only, and for the simple case where voice rates
alternate between two regions. In this research, we will take a similar approach.
Specifically, given all traffic characteristics, we will select upper bounds on each of
23


the voice/video/high speed data rejection rates; rmax/rax/rax in (2.20). Then,
we will seek those thresholds of the traffic monitoring algorithmic systems which
minimize the upper bound of the Capacity Waste Rate in (2.17).
Remarks. The rejection rates defined in this section represent a weaker measure than
that in theorem 2. However, sufficiently tight upper bounds on the rejection rates
rax, rax, rax in (2.20) can be determined, to guarantee the satisfaction of any
given 8 values in theorem 2; that is, to guarantee message admissions with given
probabilities, in the presence of admission delay constraints.
2.6 The Distributed Traffic Monitoring Algorithm
In hypothesis testing, such techniques induce decentralized decision making at the
network-level. Specifically, upon collecting the date, networks transmit their
decisions to a central processor, called the fusion center, instead of the whole string of
observations. The central processor then declares the final decision based on the local
decisions, and its own observations. The resulting distributed Traffic monitoring
systems provide reliability and savings in communication costs. The advantages of
distributed Traffic monitoring are achieved at the expense of suboptimal
performance, due to information loss in local decision making [12]. Let us consider
frame structures for the allocation of channel resources to different traffic classes (see
figure 2.1). The objective of a traffic monitoring algorithm, such as the TMA, is to
adjust the boundaries of the allocations per frame according to the demands of the
detected corresponding traffic. Let us consider the TMA as applied to a single traffic
class, and let then the statistics of the traffic be described by one of two possible
parametrically known processes, /i0 and ji1. The objective of the TMA is then to
monitor the active process, where the latter may be alternating between the above two
processes. Let Qj{ii 1( ...,nqy, j = 0,1 denote the joint distribution of packet arrivals in
24


q consecutive frames, as generated by the process g.j ,j = 0,1 where rq is the
numbers of arrivals in the ith frame. As described in 2.4.1 [3] [1] [7], the centralized
TMA, which operates solely on the local traffic data consists in this case of two single
alternating monitoring algorithms {gx-j -* threshold associated with the monitoring of the g1_j gj shift. Let the sequence
{S|}i>o be the points (corresponding to beginnings of frames) where shift decisions
are made by the algorithm, and let at some 5, the distribution j = 0,1 be
decided by the centralized TMA as just starting to act. Then, immediately, the single
algorithm {g^-j gj,Vi-j) starts operating. Let denote the operating
value of this algorithm at its r th algorithmic adaptation. Then, the operating
values of the centralized TMA are sequentially updated as we described in section
2.4.1 and the equation
^i-;,y(0) = 0
l/1_;j(r + 1) = max
{o,Vkj(r) + log (
9j{nr+1\n1,...,nr)
9k(nr+l\nl.....nr)
)}
(2.21)
At Si+1 ,when the threshold is first crossed by the algorithm, it is decided that
the distribution gj(m) has started acting, and the (gj -> gi-j.rjj] algorithm that
monitors a gj g1_j shift is simultaneously activated. We note that during time
periods when the {g-i-j gj.gi-j) algorithm operates, the TMA basically assumes
that the active process is gx_y. The log ratio in (2.21) is the updating step of the
centralized TMA. Let us now consider the case of distributed decision network
depicted in Fig. 2.2 whose function is binary hypothesis testing, and let the function
i = 0,1 nqt = n1( ...,nq be the joint distribution of packet arrivals in q
consecutive frames at the ith node, where i = 1,..., N. The output produced by each
network at q frame is a decision regarding the acting hypothesis and is a binary
25


number. For node network i, this binary number is denoted iq 1_y and it defines as
follows:
r 1; if the ith node decides that
the process p1_j is active
0; if the ith node decides that
k the process pj is active
(2.22)
It is assuming that the same process is acting throughout the collection of all data.
The fusion center receives at frame q the binary numbers u1(q),... ,uN(q) from N
other networks; it produces as output (at frame q) the binary number rq(q). At frame
q, the fusion center performs as function on its inputs, u1(q),...,uN(q), to produce its
output.
We then propose a Distributed TMA (DTMA) whose only difference from the
centralized TMA lies in the updating step. Indeed, we propose that the log ratio in
(2.1) be substituted by the updating step,
N
^ WiU^j + log
i = 1

(2.23)
26


Figure 2.2 Distributed Decision Network
Where {w/j} are constants whose objective is to weigh the contribution of the various
TMAs according to their respective performance characteristics. Let at and /?* denote
traffic rejection rate, in percentage of messages rejected, and the wasted capacity rate,
in percentage of channel capacity wasted, as induced by the TMA employed by the
ith neighboring node.
W( = log
(1 -/?,)(! -,)
Piai
;i =
(2.24)
The expressions in (2.23) and (2.24) are precisely derived when the data processes at
the neighboring nodes are memoryless and mutually independent, while the only
27


information sent by the ith node to the DTMA- computing node is the binary number
Uij per frame.
We note that the weights {Wj} in (2.24) are positive if and only if the sum of the
traffic rejection and the wasted capacity rates is less than one. We also note from
(2.23) that the decisions of a neighboring TMA contribute then positively to the
acceleration of a g1_j -> gj shift decision (by increasing the size of the updating
step), when these decisions point to the process as being active.
Remarks: The capacity allocation policy/multiplexing technique/TMA combination
proposed and studied in section 2.3.1, as well as the distributed extension introduced
in this paper, induce a tradeoff is controlled by the value of the decision thresholds
{ qm} used by the TMAs. In [1], [3], [6], and [7] these thresholds have been selected
statically, with only indirect connection to the induced traffic rejection and capacity
waste rates.
2.6.1 Performance Characteristics of the DTMA
Let N^j j; j 0,1 denote the extended stopping variable induced by the DTMA
algorithm with updating step number as in (2.23). Let also Ii-jj denote the Kullback-
leibler number of the process /r; with respect to the process^a_;-;. Let ;(i); j =
0,1 denote the extended stopping variable induced by the TMA deployed by the ith
neighboring node and let us define:
Pi.k/j
E{NkA-kil)/gj}
E{NkA-kii)/gj} + E{N1_k/l)/gJ}
; k = 0,1; j = 0,1
(2.25)
Then, the following theorem can be expressed
28


Theorem 3
Let the processes {/r;; j = 0,1} be stationary, ergodic, mutually independent and
satisfying the general mixing conditions (A) and (B) in reference [7]. Then, the
asymptotic performance of the DTMA is as follows:

YJi=\wiPi,j/i-j + h-j,j
, asri^ -> oo (2.26)
|Ml-;
i=1
-1
^ wiPi.j/l-j (/Mif ^ wiPi,j/l-j > Ij.i-
i=1
N
; til
^ 2
if ^ WiPij/^j > \j x_j
i=i
(2.27)
At the same time, the performance of the TMA in (2.1) is as shown below
Bfi
,asr-> oo
, as- r|i-y -* 00
(2.28)
(2.29)
The results in the theorem exhibit clearly the interactive relationship between the
DTMA and the TMAs deployed by the neighboring nodes.
Comparing expressions (2.26) and (2.27) with expressions (2.28) and (2.29) we
observe that the DTMA is clearly superior to the TMA, when the constants {wt} that
reflect the contributions of neighboring nodes and the parameters {Pij/i-j} that
represent the performance of the neighboring TMAs are such that their sum
29


XfLi WiPij/x-j is smaller than the minimum between two Kullback-Leibler numbers
/0i and 701. Then, as compared to the TMA, the DTMA decreases the asymptotic
expected stopping times for correct decision by factors of
asymptotic expected times for erroneous decisions. We will conclude this section
with an asymptotic result for the case where the DTMA computing node acts as a
fusion center for neighboring nodes whose data processes are mutually independent
and identically distributed and whose TMAs are identical. Then, the DTMA-
computing node does not collect local data and the DTMA updating step in (2.23)
takes the following form after normalization:
;where for a and /? representing the traffic rejection rate and the wasted capacity
rate per neighboring node, respectively, w = log [(1 a)(l P)/a(3].
Theorem 4:
Let the processes (p; ,j = 0,1} be as in theorem 1. Let us then consider the DTMA
with updating step as in(2.30). Let the N neighboring nodes be independent and
identical, resulting in identically distributed and independent variablesju, y} Let then
Pj/j = Pi.l/J > V 1 and Pj/1-i = Pi.j/1-j V 1 where Pi.i/J and Pi.j/1-j are as in
theorem 1. Then, we have
[2?UiV;PMyo + Au] 1 li=iWiPi§o/o and [^=1Wipiiin +
h,o] 1 Xf=i wiPi,i/i > respectively, while it maintains the exponentially longer
N
(2.30)
i = l
, as co (2.31)
, as r|1_7 oo (2.32)
30


1; for finite
(2.33)
p(Ni-jj = cei7(() I M -*jv-
7
Til-/
P(Nt_j j = ceil{--------) | Hij) ^/v-^oo 1; for finite rj1_;- (2.34)
i 7
Remarks: From the results in theorem 2, we observe that when the DTMA-
computing node acts as a fusion center to the decisions performed by independent and
identical neighboring parameters represent respectively the probabilities of correct
versus incorrect decisions finite and N oo the ratio Pj/j/Pj/i-j equals the ratio
E{N1_j j\nx_j j }/E{Nx_j j\[ij ) of expected stopping times induced by the DTMA.
31


3. NUMERICAL AND SIMULATION RESULTS
3.1 Numerical Results
3.1.1 Models in the Numerical Results
In consistency with the assumptions adopted in section 2.5, we adopted the following
traffic models for our numerical evaluations:
1. For each of the three traffic streams, voice/video/high speed data, we
simulated the DTMA for a single traffic class in the system depicted by Figure
2.1 and with selected capacity allocation functions /((/17) = We selected
Poisson processes for the message arrivals, and geometric distributions of
message lengths. We further considered the case where the distributions of
message lengths remain unchanged within each traffic stream, and where only
the Poisson rates of the message arrivals may then vary. In this case, it
suffices that message arrivals be only monitored by the traffic monitoring
systems, where each monitoring algorithm is updated at the beginning of the
frames (see figure 2.1). Let{rj) denote the central Poisson rates, in expected
number of packet arrivals per frame, for the arbitrary traffic stream (one of the
three). Then, directly from (2.1) in section 2.4.1, we conclude that,
considering algorithmic adaptations at beginnings of frames only, for
{rj^r1_j} ,adopting natural base logarithms, the log likelihood term in (2.1),
as well as the updating steps of the TMAs deployed by the neighboring nodes
can be derive as follows:
32


, fgj(.nr + l\n1,...,nr)\ e (,rw)(Zri_y)s+1
lg ( 771 ~--------Z-^) = l9-
\.9k(.nr + l|n1( ...,nr)J '"a e~(lri\lrj)
7
= - Tj) + ns+1ln
ns+i
IVi-j
lri
= -ifa-j ~ rj) + ns+i lglI^~
(3-1)
And the updating steps of the DTMA deployed term in (2.23), by the neighboring
nodes can be derive as follows:
TV TV W. \ns+i
Z, . 9j(nr+1\n1,...,nr)
w^j + log-------------1---------r = > WiUij + log
gi-j(nr+1\n1,...,nr) Z_, J
(=i J (=i
-(tri-;)(fn-y)T
e-(Tr;)(Zr.)1
WjUfj /(r!_y 7j) + ns+1log
i = 1
fri-j
/v
= WjUij + /[?} rj_y + ns+1log Ovy/ry)]
(3.2)
i = l
Where ns+1 represents the number of packet arrivals within the (s + 1 )th frame after
the beginning of the {r; -> r1_J} monitoring algorithm, and where l represents the
frame length.
Now define:
Z(ri,ri-i) = [ri-r1_i][log (-^-)] 1 (3.3)
r 1-t
where minCr^r^,) < ((ri,r1_i') < max(ri,r1_i). For each traffic stream, select
{rg.ry } rates such that C(r(-ri-;) arc rational numbers for both i=0,1 .the define the
integers ti l_i ands^-*, ti l_i < s,, as follows:
33


(3.4)

tj,i-i
The algorithmic thresholds can now all be selected as positive integers, and the log
likelihood algorithmic adaptation in equation (3.1) can be transformed to
{(nr+1 ftu-i ]! (3.5)
And the log likelihood algorithmic adaptation in equation (3.2) can be transformed to:
N
Si.i-i WiUij] /log (j't-j/rj')
( = 1
+ (-D
ime(i,l-i) [
>i,l-i nr+1
Itii-i]
(3.6)
where
ime(i, 1 i)
0; if rl_l > r(
1; if r1_i < rt
Considering the per frame algorithmic adaptations and the Poisson arrivals, Kullback-
Leibler numbers {ki{rj/rq}} can be derived as follows:
Ki{rj/rq} = lrq
+ In f
rq rq \rqJ
i> q)
2- For each of the voice, video, high speed data traffic streams, we selected the
process that generates shifts in message arrival rates as follows:
(3.7)
(A) The distribution of the time period during which a given rate, r,. is continuously
acting is geometric, having the form,
34


QiW = (1 ~ Pi) 1Pik 1)k > 1 (3.8)
Where k represents number of time slots. The expected time £{/,} during which rt is
continuously acting is
E{li} = (l-piy1 (3.9)
And the average fraction of time Yi for the r, activity is
Yi = ELoBM]'1 £{',} = E*=o(l pO"1]"1 (1 -PlT1 (3.10)
Assuming that the rats are ordered as r0 < r1, the yt's are selected ordered as y1 < y0.
Then, for some constant C > max the p. values are determined as
fro YiJ
Pi = 1 (CyiY1-, i = 0,1 (3.11)
For ease in graphic representation, a geometric structure is adopted in the selection of
the y,-s. specifically, for some constant a, 0 < a < 1, the yjs are generated as
follows:
Vo = Yo(a) = (1 a2)-1(l a)
Yi = FiO) = (1 a2) ](1 ~ a)a (3.12)
Thus, for any a value, the generated y( 's are such that yx < y0 and Yi + Yo = 1- The
following conclusions can be drawn from equation (3.12):
a) Yo(a)'s a decreasing function of a.
b) yo(a) *s an increasing function of a.
c) In general, as a decreases, the higher rate becomes increasingly bursty while
the frequency with which the lower rate occurs increases monotonically; as
a -> 0, y0approaches 1. As a increases, the frequencies of occurrence for the
35


two different rates tend to equalization; as a -* 1, the y, ,i = 0,1 values
approach 1/2.
(B) Given that some rate r* is acting, shifts to the other rate is equally probable.
3- For the low speed data traffic stream, we selected a Poisson arrival process, with
rate measured in number of expected packets per slot.
3.2 Simulation Results
3.2.1 Simulation of TMA and DTMA
We simulated the overall traffic monitoring/capacity allocation/transmission policies
system for the DTMA and compared its performance with that of the TMA. We used
the model that we discussed in section 3.1.1 and generated the fractions {yo.Ki} for
different values of a. The traffic class, that we selected, was considered to be
Poisson with rate pair (r0, rx) of generated message arrivals. The message lengths
were selected to be geometrically distributed, with average length equal to 2, while
the chosen pair of message arrival rates was (0.2, 0.8). In all figures, the shown traffic
rates are the average number of packet arrivals per slot. Thus, the rates generated for
the message traffic in each case are the rates shown, divided by the corresponding
average message lengths. A packet was selected as corresponding to one second in
transmission time. The frame length l was selected to be equal to 40 slots,
corresponding to 40 seconds in transmission time. We consider 2 and 4 neighboring
nodes utilized by the DTMA, in conjunction with local data. We selected the
thresholds (tj0-Tii) of the TMA and the DTMA a priori, where no on-line learning for
performance adaptation was performed. In all our cases we considered 2 and 4
neighboring nodes utilized by the DTMA and compare it to the TMA.
Two different set of simulations were performed to evaluate the system performance:
36


3.2.1.1 Simulation of first Transmission policy for both TMA and DTMA
In figures (3.1),(3. 2) and (3.3) we first simulated the case where we deploy the first
transmission policy described in section 2.3.1, where we computed rejection rates,
wasted capacity rates, and expected delays, as functions of the parameter a.
The rejection rates were computed based on the messages that were rejected due to
violation of the admission delay constraint studied in section 2.1, and the messages
that were interrupted due to false capacity allocations induced by the TMA and the
DTMA. Studying figure (3.1) we notice that, as we increase the value of a the
rejection rate increases as well. On the other hand, the rejection rate curve of the
TMA has higher values than those of the rejection rate curve of the DTMA. As we
increase the number of nodes, the rejection rate decreases, which is a relevant result,
since as the number of used nodes increases, the more the DTMA outperforms its best
TMA, in terms of correct decision probabilities and rejection rates, as discussed in
[13]. An appropriate adjustment of the TMA and DTMA thresholds may improve the
rejection rate performance.
Figure (3. 2) represent capacity waste rate, as a function of a, where we observe that
the decreased rejection rates are accompanied by increased wasted capacity rates. In
our simulation, the wasted capacity rate was computed as the number of slots that
remain unused in each frame portion assigned by the allocation function, divided by
the total number of slots in the same portion.
The delay of a message is measured as the delay experienced by its last packet.
Figure (3.3) shows the average delay of messages measured in number of slots and
computed also as a function of a. We also observe that, as compared to the TMA, the
DTMA improves delays, where the delays of the 2-nodes DTMA are better than those
of the TMA, and the delays of the 4-nodes DTMA are better than those of the 2-nodes
DTMA. It is important to point out that the Kullback-Leibler distance between the
acting processes is sufficiently large to induce high overall performance.
37


0.5
0.45
0.4
0.35
0.3
£ 0.25 h
CO
L_
0.2
0.15
0.1
0.05
0
Rejection Rates
O TMA
- 2 Nodes
4 Nodes
0


. J _
-
-+-

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
a
Figure 3.1 Rejection rate with first transmission policy
38


0.71

Capacity waste Rates
~T"
V)
0)
-*-
(0
0.711-
0.65
0.61-
0.55
0.5
O TMA
2 Nodes
4 Nodes
.... "N.. i ;
1
o _ .
; ' o
>--4
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
0.9
a
Figure 3.2 Wasted Capacity rate with first transmission policy
39


w
+
o
W
69.5
69
68.5
68
67.5
67
Delays
--0-- TMA
2 Nodes
$ 4 Nodes
v
-I
- ..0 ;/0
y

f mr
/ y*
I / A-'"
66.5-r^"': -- -
661
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
a
0.9
Figure 3.3 Average Delay with first transmission policy
3.2.1.2 Simulation of Second Transmission policy for both TMA and DTMA
In figures (3.4),(3.5) and (3.6) we simulated the case where the second transmission
policy, described in section (2.3.1), is deployed. Figure (3.4) exhibits the traffic
rejection rates of the second transmission policy, where we notice similar behavior as
that shown in figure (3.1). We also observe a noticeable decrease in the rejection rate
of the DTMA, as compared to that of the TMA. In particular, the traffic rejection
rates in figure (3.4) are relatively lower than those in figure (3.1).
Our results in figure (3.5) exhibit the wasted capacity rate, where, the expected
40


tradeoff between capacity waste and rejection rate is evident. The wasted capacity
increases, as the rejection rate decreases. We observe that the wasted capacity values
in figure (3.5) are lower than those in figure (3.2).
Finally, maintaining everything else as above, we computed the average delays
induced by the second transmission policy. The results are exhibited in figure (3.6).
As expected, the average delays improve when the DTMA is used. Figure (3.6)
shows better delay values than those in figure (3.3).
0.25
Rejection Rates
(/)
a)
(B
0.2 b
0.15 f ;
o
0.1
0.051
! O TMA
: 2 Nodes
t 4 Nodes
O o
o
- JÂ¥~~
t T

0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9
a
Figure 3.4 Rejection Rate with second transmission policy
41


(/)
a)
-4
TO
0.5
Capacity waste Rates
0.45*
0.4
0.35
0.3
0-~ TMA
2 Nodes
4 Nodes
V. 'x
--:
x£x
\\
'4

)
V
o
0.25 1
0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8
a
6
j
0.9
42


(0
4
o

Delays
540
T --0- TMA
52i 2 Nodes
^ 4 Nodes
50
48
O
46
441 -
42
I
j
401
i
38
36 1
0.1



0.2 0.3
0.4
_ .. L
0.5
a
0.6
0.7
"f--f
0.8 0.9
Figure 3.6 Average Delay with second transmission policy
43


4. Conclusion
In this thesis, we studied and evaluated the TMA and the DTMA, for a single traffic
class and compared their performances. The objective was to evaluate the DTMA
theoretical model via simulations. The simulation was successfully performed and
the performance evaluation was completed. The DTMA represents a performance
versus communications cost tradeoff, where it is implemented by a fusion center
structure in which the neighboring nodes provide partial information for the benefit of
reduced communication cost. When the number of neighboring nodes increases, the
average delay of the messages decreases. In terms of rejection and wasted capacity
rates, the DTMA outperforms the centralized TMA.
44


APPENDIX A. MATLAB PROGRAM FOR TMA FIRST TRANSMISSION
POLICY
^script file: TMA
%purpose:
i Thesis program for simulate the Traffic Monitoring Algorithm
% of the first transmission policy
%
%Date Programmer Description of change
%01/13/2011 Khaled Zaid Original code
clear ,close clc
alpha=l/2;
thresholdl=150;
threshold2=180;
coulumn_test=200;
y=zeros(200000,coulumn_test);
all_zeros=200000;
% Length of the frames
1 = 4 0 ;
% Rate used to generate the arrival rates
lambdal=.4;
lambda0=.1;
Etta=(lambdaO-lambdal)/log(lambdaO/lambdal);
[tl,sll] = rat(Etta);
S1 = 5 0 ;
t_l=11;
if lambda0>lambdal
ime=l;
else
ime=0;
end
% a used in graphic representation
alpha_for_gamma=.1;
% Generate the Gammas
gamma_0=(l-alpha_for_gamma)*1/!1-alpha_for_gammaA2);
gamma_l = alpha_for_gamma*(1-alpha_for_gamma)*1/(1-alpha_for_gamma*2) ;
C_constant=max(1/gamma_0,1/gamma^l);
C constantl=C constant+2;
45


% Calculating the Rhoes
zitaO=l-(1/(C_constantl*gamma_0));
zital=l-(1/(C_constantl*gamma_l));
% Genrating the arrival rates for rO and rl
for j=l:8000
xl=rand(1);
x2=rand(1);
11 = log(l-xl)/log(zitaO) ;
12 = log(l-x2)/log(zital) ;
Ll=ceil(11) ;
L2 = ceil (12) ;
The_messages_arrivall=zeros (1, LI) ;
The_whole_interval=zeros(1,LI);
for i=2:Ll+1
r=rand(1);
The_messages_arrivail(i)=The_messages_arrival1(i -1)-log(1-
r)/lambda0;
end
51 = The_messages_arrivall(The_messages_arrivall~=0);
if size(SI)==0
v=Sl ;
else
v=Sl(end);
end
The_messages_arrival2=zeros(1,L2);
for i=2:L2+1
r=rand(1);
The_messages_arrival2(i)=The_messages_arrival2(i-1)-log(1-
r)/lambda1;
end
52 = The_messages_arrival2(The_messages_arrival2~=0);
S2_l=v+S2;
all_arrival=[SI S2_l]
if j==l
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival= [] ;
else
vl = find(nonzeros(y(j- 1, :))) ;
ssdd=vl(end);
ssddl=y(j- 1,ssdd) ;
all__arrival = all_arrival + ssddl ;
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival= [] ;
end
end
46


y = reshape(y1);
y=(nonzeros(y))';
% The arrival rate array
arrival_time=y;
maximum_arrivals_time=max(arrival_time);
fram=40;
d=4 0 ;
H=ceil(maximum_arrivals_time/40);
count=0;
numbr_of_arrivals_in_each_fram=zeros(1,H);
c=arrival_time((arrival_time<=fram)&(arrival_time>=0)),-
numbr_of_arrivals_in_each_fram(1)=length(c);
for i=2:H;
c=arrival_time((arrival_time<=d+fram)&(arrival_time>=d)),-
numbr_of_arrivals_in_each_fram(i)=length(c);
if d>maximum_arrivals_time,break, end
d=d+fram
count=count+l;
end
count=count+l;
max_fram_length=max(numbr__of _arrivals_in_each_f ram);
mean_fram_arrivals=mean(numbr_of_arrivals_in_each_fram);
d=0 ;
A=zeros(count,max_fram_length);
for j=l:H;
cl=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
fram_equal=[cl,zeros(1,max_fram_length-length(cl))];
A(j,:)=A(j,:)+fram_equal;
if d>maximum_arrivals_time,break,end
d=d+fram ;
end
% Finding the the length of the Message of each arrival rates
mstart=ceil(log(1-rand(count,max_fram_length))./(log(alpha)))
[I,J]=size(A);
masseg_matrix=zeros(I,J);
for i=l:count
for j=1:max_fram_length
if A(i,j)~=0
masseg_matrix(i,j)=mstart(i,j);
else if A(i,j)==0
masseg_matrix(i,j)=0;
end
end
end
end
% Finding the changing time of both rates
TX(1) =0;TX1 = 0;TX 2 = 0;
U=0 ;
u 1 = 0 ;
for i=l:I
47


if TX1<150
TX(i+1)=max(0,TX(i)+(sl*numbr_of_arrivals_in_each_fram(i)-
40 *t_l) ) ;
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1>=150
u=u+l;
T_0(u)= TX1;
bbb(u)=i;
cucu=nonzeros(A(i,:));
time_end_of_the_frame_0(u)=cucu(end);
frame_end_cross_threhold_0(u)=i*40;
TX(i+1)=0;
end
elseif TX1>=150 && TX2<180
TX(i +1)=max(0,TX(i)-(si*numbr_of_arrivals_in_each_fram(i) -
4 0 t_l) ) ;
TX2=TX(i +1) ;
T22(i)=TX(i+1);
if TX2>=180
ul=ul+l;
T_1(ul)=TX2;
bbbl(u)=i;
cucul=nonzeros(A(i,:));
frame_end_cross_threhold_l(ul)= i*4 0;
if isempty(cucul)
time_end_of_the_frame_l(ul)=i*40;
else
cucul=nonzeros(A(i,:));
time_end_of_the_frame_l(ul)=cucul(end);
end
TX(i+1)=0;
TX1 = 0;TX2 = 0;
end
end
end
for nn=l:I
Sll=zeros(1,1);
Sll=Sll+thresholdl;
S22 = zeros(1,1) ;
S22=S22+threshold2;
end
plot(Til, -i 1)
hold on
plot (Sll, 'LineXidth ,2)
hold off
axis([1 1000 0 500])
f igure
plot (T22 ' I- )
hold or:
48


plot (S22, LineWidtii' 2)
axis([1 1000 0 500])
hold off
cross_for_both_TS=[];
for 0=1:length(frame_end_cross_threhold_l)
pp= [frame_end_cross_threhold_0(O)
frame_end_cross_threhold_l(0)];
cross_for_both_TS=[cross_for_both_TS pp] ;
end
cross_for_both_TS=cross_for_both_TS;
o. >.
% Transmission, Delay, Rejection and Capacity VJasted Calculat
Counter=zeros(1,8);
Counterl= [] ,-
Counter2= [] ;
delay_first=zeros(I,J);
SOFT_DECISION=zeros(1,I);
mass_rejected_of_delay_per_frame_test= [] ;
mass_rejected_of_insufficient_delay_per_frame_test=[];
WASTED_CAPACITY=zeros(1,I);
REJECTED_MASSEGE_ALL_FRAMES=[];
Delay_constraint=60;
Delay_first_all=[];
f rame_time_f or_the_beginnig=l
dn=0 ;
Al=zeros(I,J);
message_delay_constrl=zeros(I,J);
message_delay_constr=[];
for NN=1:(length(cross_for_both_TS)/2)
if frame_time_for_the_beginnig==cross_for_both_TS(end)/40
end_of_rO_to_rl=I(end)+1;
else
end_of_rO_to_rl=frame_end_cross_threhold_0(NN);
end
% Transmission of tile Change to the Lower rate
for i = f rame_time_for_the_beginnig(end_of_r0_to_rl/40-1)
f inding_time=ones (1,8) ,-
finding_timel=(1:8);
t ime_of_frame = i 4 0 f inding_t ime;
t ime_of_next_f rame__allocat ion= f ind ing_t imel +1 ime_of_frame
Counter=Counter-1;
Counter(Counter<0)=0
d=find(Counter==0);
dd=length(d);
delay_firstl=[];
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0;
j th=0;
for j=l:dd
CF=d(j);
49


j th=j th+1;
if masseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,j th) ;
delay_first(i,j)=time_of_next_frame_allocation(j)-A(i,j);
if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,jth+1);
j th=j th+1;
mass_rej ected_of_delay_per_frame=mass_rej ected_of_delay_per_frame+1;
numbe r_o f_avai1able_s1ot s=numbe r_of_ava i1ab1e_s1ot s+1;
A1(i,jth)=0;
end
A1(i,jth)=A(i,jth);
message_delay_constrl(i,jth)= i *4 0 -
A1(i,j th)+time_of_next_frame_allocation(CF) -
i*40 + 40* (masseg_matrix ( i j th) -1)
end
mass_rej ected_of_delay_per_frame_test=(mass_rej ected_of_delay_per_fr
ame_test mass_rejected_of_delay_per_frame]
% Wasted Capacity of each Frame
wasted_slots_per_frame=length(find(Counter==0));
WASTED_CAPACITY(i)= wasted_slots_per_frame;
% Rejection Calculation of all frames
if dd==0
number_of_rej ected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,:)));
elseif isempty(nonzeros(masseg_matrix(i,j th:end)))
number_of_rejected_masseg_insuff icient_slot = 0;
else
number_of_rejected_masseg_insufficient_slot=length(nonzeros(masseg__m
atrix(i,jth+1:end)));
endl=length(masseg_matrix(i,jth+1:end));
A1 (i,jth+1:endl)=0;
end
mass_rejected_of_insuf f icient_delay_per_frame_test=[mass_rej ected_of
_insufficient_delay_per_frame_test
number_of_rejected_masseg_insuff icient_slot] ;
mass_rej ected_of_each_framel=mass_rej ected_of_delay_per_frame+number
_of_rej ected_masseg_insuf f ic ient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counterl=[Counterl; Counter];
U= 1 ;
SOFT_DECISION(i)=u;
end
% Ti:ansmission of t.h6 ChictJK'ui- fo hiof-rth
if frame_time_for_the__beginnig==cross_for_both_TS(end)/40, break,end
frame_time_for_the_beginnig=frame_end_cross_threhold_l(NN)/40;
Counter second=[Counter zeros(1,24)];
50


for
i= (frame_end_cross_threhold_0 (NN) /40) (frame_time_for_the_beginnig-
1)
finding_time=ones(1,32);
f inding_t ime1=(1:3 2) ;
time_of_frame=i*40*finding_time ;
time_of_next_frame_allocation=finding_timel+time_of_frame;
Counter_second=Counter_second-1;
Counter_second(Counter_second<0)=0;
d=find(Counter_second==0);
dd=length(d)
delay_firstl= [] ;
mass__rejected_of_each_f ramel = 0 ;
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0
jth=0;
for j=l:dd
CF=d(j);
j th=j th+1;
if jth>J, break, end
if masseg_matrix(i,jth)==0,break, end
Counter_second(CF)=masseg_matrix(i,j th) ;
delay_first(i,j)=time_of_next_frame_allocation(j)-A(i,j);
if delay_first(i,j)>Delay_constraint
Counter_second(CF)=masseg_matrix(i,j th+1) ;
j th=j th+1;
mass_rejected_of_delay_per_frame=mass_rej ected_of_delay_per_frame+1;
number_of_available_slots=number_of_available_slots+l;
A1(i,jth)=0;
end
A1(i,jth)=A(i,jth);
message_delay_constrl(i,jth)=i*40-
A1 (i,jth)+time_of_next_frame_allocation(CF) -
i*40 + 40*(masseg_matrix(i,j th)-1) ;
end
mass_rejected_of_delay_per_frame_test=[mass_rej ected_of_delay_per_fr
ame_test mass__rejected_of_delay_per_frame]
wasted_slots_per_frame = length(find(Counte r_s e cond= = 0)) ;
WASTED_CAPACITY (i) =wasted_slots__per_f rame ;
% Rei ect ion ''i -si t y';d.rupc::
i f isempty(nonzeros(masseg_matrix(i,j th:end)))
number_of__rejected_masseg_insuff icient_slot = 0;
else
number_of_rejected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,jth+l:end)));
endl = length (masseg_matrix ( i j th+1: end) )
A1 (i j th+1 endl) =0 ;
end
mass_rej ected_of_insuf f icient_delay_per_f rame_test=[mass_rejected_of
51


_insufficient_delay_per_frame_test
number_of_rejected_masseg_insufficient_slot];
mass_rej ected_of_each_framel=mass_rej ected_of_delay_per_frame+number
_of_rejected_masseg_insuf f icient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counter2=[Counter2; Counter_second];
u=0;
SOFT_DECISION(i)=u;
end
if isempty(nonzeros(Counter_second(9:32)))
Number_of_inturpted_masseges=0 ;
else
number_found=Counter_second(9:32)-1;
number_found(number_foundc0)=0;
Number_of_inturpted_masseges=length(nonzeros(number_found));
end
REJECTED_MASSEGE_ALL_FRAMES(end)=REJECTED_MASSEGE_ALL_FRAMES(end)+Nu
mber_of_inturpted_masseges;
length_of_rej cted=REJECTED_MASSEGE_ALL_FRAMES(end) ;
for jf=1:length_of_rejcted
cdfl = f ind(nonzeros(A1(i, :))) ;
if (isempty(cdf1)) ,break,end
dnn=cdf1(end);
A1(i,dnn)=0;
end
Counter=Counter_second(1:8);
end
%%
it: "I 11 c Vr;. t :: v- .;t t ;.. it: l ' l b : I-
%%%%%%%%%%%%%%%%*
% LAST FRAMES CALCULATION of the Lower Rate
for i=frame_time_for_the_beginnig:(I(end))
finding_time=ones(1,8);
f inding_t ime 1 = (1: 8)
t ime_of_f rame= i* 4 0 f inding_t ime;
t ime_of_next_f rame_al location=f inding_timel +time_of_f rame ;
Counter=Counter-1
Counter(Counter<0)=0;
d=find(Counter==0);
dd=length(d);
number_of_available_slots=d;
mass_re j ected_of__delay_per_f rame = 0 ;
jth=0;
for j=l:dd
CF=d(j);
jth=jth+l;
if masseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,j th) ;
delay_f irst(i,j)=t ime_of_next_frame_allocation(j)-A(i,j) ;
52


if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,j th+1);
j th=j th+1;
mass_rejected_of_delay_per_frame=mass_rej ected_of_delay_per_frame + l;
number_of_available_slots=number_of_available_slots+l;
A1 (i,jth)=0;
end
A1(i,j th)=A(i,j th);
message_delay_constrl(i,jth)=i*40-
A1(i,jth)+time_of_next_frame_allocation(CF)-
1*40 + 40*(masseg_matrix(i,j th)-1);
end
mass_rejected_of_delay_per_frame_test=[mass_rej ected_of_delay_per_fr
ame_test mass_rejected_of_delay_per_frame];
% Wasted Capacity of each Frame
wasted_slots_per_frame=length(find(Counter==0));
WASTED_CAPACITY(i)=wasted_slots_per_frame;
% Rejection Calculation of all frames
if dd==0
number_of_rejected_masseg_insufficient_slot=length(nonzeros(masseg_m
atrix(i,:)));
elseif isempty(nonzeros(masseg_matrix(i,j th:end)))
number_of_rej ected_masseg_insufficient_slot = 0;
else
number_of_rej ected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,j th+1:end)));
endl = length(masseg_matrix(i,j th+1:end));
A1(i,jth+1:endl)=0;
end
mass_rej ected_of_insufficient_delay_per_frame_test=[mass_rej ected_of
_insuff icient_delay_per_frame_test
number_of_rejected_masseg_insufficient_slot];
mass_rej ected_of_each_framel=mass_rej ected_of_delay_per_frame+number
_of_rej ected_masseg_insufficient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counterl=[Counterl; Counter];
U= 1 ;
SOFT_DECISION(i)=u;
end
% Calculaiion Erocess of Uie Delay or the whole message
message_delay_constrll=zeros(I,J);
for i = 1:1
for j =1:J
if A1(i,j)>0
A1(i,j)=1;
end
message_delay_constrll(i,j)=A1(i,j)*message_delay_constrl(i,j);
end
end
53


all_delay_together=sum(message_delay_constrll(:));
DELAY=all_delay_together/length(nonzeros(A1(:)));
g, o ^ c, o, o. 5, s o, o. 5, P, 5, 1 o, ,
3 O O G c 'o O O o '0 % 0 "0 0 q 0 c 'o o
[II Jl]=size(Counterl);
[12 J2]=size(Counter2);
% Wasted Capacity Rate Calculation
Wasted_capacity_rate=sum(Counterl(:)==0)/(Il*Jl)+
sum(Counter2(:)==0)/(I2*J2)
% Rejection Rate Calculation
rejection_rate=sum(nonzeros(REJECTED_MASSEGE_ALL_FRAMES))/(length(y))
% Calculation the Weigh used in the Distributed TMA
wl=log(((1-Wasted_capacity_rate)*(1-
rejection_rate))/(rejection_rate*Wasted_capacity_rate))
save SOFT DECISICNl
54


APPENDIX B. MATLAB PROGRAM FOR DTMA 2 NODES FIRST
TRANSMISSION POLICY
The variables and the parameters in the DTMA program are the same as that used in
the TMA program except that we made few changes in the TMA program. First when
the TMA program operates, the program saves all the value of the parameters that are
used in the DTMA. Then, the DTMA will load, these parameters such as, the soft
decision and weigh, and use it in the updating step.
To obtain the two node DTMA program, we replaced lines from 1 to 193 by the
following program
fscript file: DTMA 2 nodes
spurpose:
% Thesis program. Lor simulate the Distributed Tralfio Monitoring
%Algorithm of the first transmission police
iDate Programmer Description of change
1 = r- - = ~ ~ ^ ~ ^ - -
ice,'12/2011 Khaled raid Original code
clear ,close clc
% Load cl and v.T: for first node and second node saved using TMA
load SOFT_DECISIOH1
SOFT_DECISIONl=SOFT_DECISION;
wl=wl
load SOF'iy DECIS1CM2
w2=w2
SOFT_DECISION2=SOFT_DECISION;
[B1 Zl]=size(SOFT_DECISIONl);
[B2 Z2]=size(SOFT_DECISION2);
f inal_frame_allowable=min(Zl,Z2) ;
SOFT_DECISIONl=SOFT_DECISIONl(1:final_frame_allowable);
SOFT_DECISION2 = SOFT_DECISION2(1:f inal__frame_allowable) ;
clear v, clear cross for both TS, clear DEJECTED MASSSGE ALL FRAMED
alpha=l/2;
coulumn_test = 2 0 0 ;
y=zeros (200000 coulumn__test) ;
all zeros=18000;
55


lambdal=.4
lambda0=.1;
thresholdl=150;
threshold2=180;
Etta=(lambdaO-lambdal)/log(lambdaO/lambdal);
[tl,sll] = rat(Etta);
S1 = 5 0 ;
t_l=ll;
1 = 4 0 ;
if lambdaO>lambda1
ime=l;
else
ime=0;
end
alpha_for_gamma=.1;
gamma_0=l/(l-alpha_for_gammaA2)*(1-alpha_for_gamma);
gamma_l=alpha_for_gamma*1/(l-alpha_for_gamma^2)*(l-alpha_for_gamma)
C_constant=raax(1/gamma_0,1/gamma_l);
C_constantl=C_constant+2;
zitaO=l-(1/(C_constantl*gamma_0));
zital=l-(1/(C_constantl*gamma_l));
for j =1: 8800
xl=rand(1);
x2=rand(1);
ll=log(l-xl)/log(zitaO);
l2=log(l-x2)/log(zital);
Ll=ceil(11);
L2 = ceil (12) ;
The_messages_arrivall=zeros(1,LI);
The_whole_interval=zeros(1,LI);
for i=2:LI+1
r=rand(1);
The_messages_arrivall(i)=The_messages_arrivall(i-1)-log(1-
r)/lambdaO;
end
51 = The_messages_arrivall(The_messages_arrivall~=0);
if size(SI)==0
v=Sl ;
else
v=Sl(end);
end
The_messages_arrival2=zeros(1,L2);
for i=2:L2+1
r=rand(1);
The_messages_arrival2(i)=The_messages_arrival2(i-1)-log(1-
r)/lambdal;
end
52 = The_messages__arrival2(The_messages_arrival2~=0);
S2 l=v+S2 ;
56


all_arrival=[SI S2_l];
if j==l
ccf=coulumn_test-length(all_arrival) ;
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival=[];
else
vl=find(nonzeros(y(j-1,:)));
ssdd=vl(end);
ssddl=y(j-1,ssdd);
all_arrival=all_arrival+ssddl;
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y ( j / : ) =y ( j : ) +all__arrival ;
all_arrival=[];
end
end
y = reshape (y. [] 1) ;
y=(nonzeros(y))';
arrival_time=y;
maximum_arrivals_time=max(arrival_time);
fram=40;
d=4 0 ;
H=ceil(maximum_arrivals_time/40);
count=0;
numbr_of_arrivals_in_each_fram=zeros(1,H);
c=arrival_time((arrival_time<=fram)&(arrival_time>=0));
numbr_of_arrivals_in_each_fram(1)=length(c);
for i = 2:H;
c=arrival_time((arrival_time<=d+fram)&(arrival__time>=d));
numbr_of_arrivals_in_each_fram(i)=length(c);
if d>maximum_arrivals_time,break,end
d=d+fram
count=count+l;
end
count=count+l;
max_fram_length=max(numbr_of_arrivals_in_each_fram);
mean_fram_arrivals=mean(numbr_of_arrivals_in_each_fram);
d= 0 ;
A=zeros(count,max_fram_length);
for j=l:H;
cl=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
fram_equal=[cl,zeros(1,max_fram_length-length(cl))];
A(j,:)=A(j,:)+fram_equal;
if d>maximum_arrivals_time,break,end
d=d+fram ;
end
mstart=ceil(log(1-rand(count,max_fram_length))./(log(alpha)))
[I,J]=size(A);
masseg_matrix=zeros(I,J);
57


for i=l:count
for j=l:max_fram_length
if A(i,j)~=0
masseg_matrix(i,j)=mstart(i,j);
else if A(i,j)==0
masseg_matrix(i,j)=0;
end
end
end
end
A=A(1:final_frame_allowable
masseg_matrix=masseg_matrix(1:final_frame_allowable,:);
[I,J]=size(A) ;
length_of_y=length(nonzeros(A(:)));
% The Updating step of DTMA
TX(1)=0;TX1 = 0;TX2 = 0;
u= 0 ;
Ul = 0;
for i = 1:1
if TX1<105.3588
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i)*w2;
TX(i+1)=max(0,TX(i)+(sum_of_weigh_and_soft_decieion*sl/log(lambdal/1
ambdaO)+sl*numbr_of_arrivals_in_each_fram(i)-40*t_l));
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1>=105.3588
U=U+1;
T_0(u)=TX1;
bbb(U) = i;
cucu=nonzeros(A(i,:));
time_end_of_the_frame_0(u)=cucu(end);
frame_end_cross_threhold_0(u)=i*40;
TX(i + 1)= 0;
end
elseif TX1>=105.3588 && TX2<118.7177
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i)*w2;
TX(i +1)=max(0,TX(i) -
(sum_of_weigh_and_soft_decieion*sl/log(lambdal/lambda0)+sl*numbr_of_
arrivals_in_each_fram(i)-40*t_l));
TX2=TX(i+1);
T22(i)=TX(i+1);
if TX2>=118.7177
Ul=Ul+l;
T_1(ul)=TX2;
bbb1(u)= i;
cucul=nonzeros(A(i,:));
frame_end_cross_threhold_l(ul)=i *4 0;
if isempty(cucul)
time_end_of_the_frame_l(ul)=i*40;
else
58


cucul=nonzeros(A(i,:));
time_end_of_the_frame_l(ul)=cucul(end)
end
TX(i+1)=0;
TX1=0;TX2=0;
end
end
end
for nn=l:I
Sll=zeros (1,1) ;
Sll=Sll+thresholdl;
S22=zeros(1,1);
S22=S22+threshold2;
end
plot(Til, '- -rs1)
hold on
plot(Sll,'LineWidth1,2)
hold off
axis([1 1000 0 500])
figure
plot(T22,'--be')
hold on
plot(S22,1LineWidth',2)
axis([1 1000 0 500])
hold off
cross_for_both_TS=[];
for 0=1:length(frame_end_cross_threhold_l)
pp=[frame_end_cross_threhold_0(O)
frame_end_cross_threhold_l(O)];
cross_for_both_TS=[cross_for_both_TS pp] ;
end
cross for both TS=cross for both TS;


APPENDIX C. MATLAB PROGRAM FOR DTMA 4 NODES FIRST
TRANSMISSION POLICY
To obtain the DTMA 4 nodes program, replace lines from 1 to 193 by the following
program
Iscript file: DTMA 4 nodes
Ipurpose:
% Thesis program for simulate the Distributed Traffic Monitoring
%Algorithm 4 nodes of the first transmission policy
%
%Date Programmer Description of change
%01/13/2011 Khaled Zaid Original code
clear ,close clc
load SOFT DHCIS10N1
S0FT_DECISI0N1=S0FT_DECISI0N;
wl=wl
load SOFT_DECISIOH2
w2=w2
SOFT_DECISION2=SOFT_DECISION;
load 30FT_DECI8I.GN3
SOFT_DECISION3 = SOFT_DECISION;
w3=w3
load S0FTJDECISI0N4
SOFT_DECISION4=SOFT_DECISION;
w4=w4
[B1 Zl]=size(S0FT_DECISI0N1);
[B2 Z2]=size(SOFT_DECISION2);
[B3 Z3]=size(SOFT_DECISION3);
[B4 Z4]=size(S0FTJDECISI0N4);
ZZ=[Z1 Z2 Z3 Z4];
final_frame_allowable=min(zz(:));
SOFT_DECISIONl=SOFT_DECISIONl(1:final_frame_allowable);
S0FT_DECISI0N2=S0FT_DECISI0N2(1:final_frame_allowable);
SOFT_DECISION3=SOFT_DECISION3(1:final_frame_allowable);
SOFT_DECISION4=SOFT_DECISION4(1:final_frame_allowable);
clear v, clear cross for_both TS, clear REJECTED __M AS S E G E A I. L F RAM E S
alpha=l/2;
coulumn_test = 200 ;
y=zeros(200000,coulumn_test);
all_zeros=18500;
lambda 1= 4
lambda0=.1;
60


thresholdl=150;
threshold2=180;
Etta=(lambdaO-lambdal)/log(lambdaO/lambdal);
[tl,sll] = rat(Etta);
Sl=50;
t_l=11;
1 = 40 ;
if lambdaO>lambda1
ime=l;
else
ime=0;
end
alpha_for_gamma=.1;
gamma_0 = l/ (l-alpha_for__gamma^2) (1 -alpha_for_gamma) ;
gamma_l=alpha_for_gamma*1/(l-alpha_for_gammaA2)*(1-alpha_for_gamma)
C_constant=max(l/gamma_0,l/gamma_l);
C_constantl=C_constant+2 ;
zitaO=l-(1/(C__constantl*gamma_0));
zital=l-(1/(C_constantl*gamma_l));
for j =1:9000
xl=rand(1);
x2=rand(1);
ll=log(1-xl)/log(zitaO);
12=log(1-x2)/log(zital);
LI = ceil (11) ;
L2=ceil (12);
The_messages_arrivall=zeros(1,LI);
The_whole_interval=zeros(1,LI);
for i=2:L1+1
r=rand(1) ;
The_messages_arrivall(i)=The_messages_arrivall(i-1)-log(1-
r)/lambdaO;
end
51 = The_messages_arrivall(The_messages_arrivall~=0);
if size(SI)==0
v=Sl;
else
v=Sl(end);
end
The_messages_arrival2=zeros(1,L2);
for i =2:L2 +1
r=rand (1);
The__messages__arrival2 ( i ) =The_messages_arr ival2 (i-1) -log (1 -
r)/lambdal;
end
52 = The_messages_arrival2(The_messages_arrival2~=0);
S2_l=v+S2;
all_arrival=[SI S2_l];
if j==l
ccf=coulumn_test-length(all_arrival);
61


all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival= [] ;
else
vl=find(nonzeros(y(j-l,:)));
ssdd=vl(end);
ssddl=y(j-1,ssdd);
all_arrival=all_arrival+ssddl;
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival=[];
end
end
y = reshape(y.',[],1);
y=(nonzeros(y))';
arr ival__time=y;
maximum_arrivals_time=max (arrival_time)
fram=4 0;
d=4 0 ;
H=ceil(maximum_arrivals_time/40);
count=0;
numb r_of_arr ivals_in_each_f ram= zeros(1,H) ;
c=arrival_time((arrival_time<=fram)&(arrival_time>=0));
nutnbr_of_arrivals_in_each_f ram (1) =length (c) ;
for i = 2:H;
c=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
numbr_of_arrivals_in_each_fram(i)=length(c);
if d>maximum_arrivals_time,break,end
d=d+fram ;
count=count+1;
end
count=count+l;
max_fram_length=max(numbr_of_arrivals_in_each_fram);
mean_fram_arrivals=mean(numbr_of_arrivals_in_each_fram);
d=0 ;
A=zeros(count,max_fram_length);
for j =1:H;
cl=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
fram_equal=[cl,zeros(1,max_fram_length-length(cl))];
A(j,:)=A(j,:)+fram_equal;
if d>maximum_arrivals_time,break,end
d=d+fram
end
mstart = ceil(log(1- rand(count,max_fram_length)) ./(log(alpha)))
[I,J]=size(A);
masseg_matrix=zeros(I,J);
for i=l:count
for j=1:max_fram_length
if A(i,j)~=0
62


end
masseg_matrix(i,j)=mstart(i,j);
else if A(i,j)==0
masseg_matrix(i,j)=0 ;
end
end
end
A=A(1:final_frame_allowable,:);
masseg_matrix=masseg_matrix(1:final_frame_allowable,:);
[I,J]=size(A);
length_of_y=length(nonzeros(A(:)));
TX (1)= 0;TX1 = 0;TX2 = 0;
u=0 ;
Ul = 0 ;
for i=l:I
if TX1<78.8321
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i
)*w2+w3 *SOFT_DECISION3(i)+w4*SOFT_DECISION4(i);
TX(i+1)=max(0,TX(i)+(sum_of_weigh_and_soft_decieion*sl/log(lambdal/1
ambdaO)+sl*numbr_of_arrivals_in_each_fram(i)-40*t_l));
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1>=78.8321
U=U+1;
T_0(u)=TX1;
bbb(u)= i;
cucu=nonzeros(A(i,:));
time_end_of_the_frame_0(u)=cucu(end);
frame_end_cross_threhold_0(u)=i*40;
TX(i+1)=0;
end
elseif TX1>=78.8321 && TX2<121.16
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i
)*w2 +w3 *SOFT_DECISION3(i)+w4*SOFT_DECISION4(i) ;
TX(i +1)=max(0,TX(i)-
(sum_of_weigh_and_soft_decieion*sl/log(lambda1/lambdaO)+sl*numbr_of_
arrivals_in_each_fram(i)-40*t_l));
TX2=TX(i+1);
T22 (i)=TX(i + 1) ;
if TX2 > = 121.16
ul=ul+l;
T_1(ul)=TX2;
bbbl(u)=i;
cucul=nonzeros(A(i,:));
frame_end_cross_threhold_l(ul)=i*40;
if isempty(cucul)
time_end_of_the_frame_l(ul)=i*40;
else
cucul=nonzeros(A(i,:));
time end of the frame 1(ul)=cucul(end);
63


end
TX(i +1)= 0 ;
TX1=0;TX2=0;
end
end
end
for nn=l:I
Sll=zeros(1,1);
Sll=Sll+thresholdl;
S22=zeros(1,1);
S22=S22+threshold2;
end
plot(Til, '- -rs')
hold on
plot(Sll,'LineWidth',2)
hold off
axis([1 1000 0 500])
figure
plot(T22,'--bs')
hold on
plot(S22,'LineWidth1,2)
axis([1 1000 0 500])
hold off
cross_for_both_TS=[];
for 0=1:length(frame_end_cross_threhold_l)
pp=[frame_end_cross_threhold_0(O)
frame_end_cross_threhold_l(O)];
cross_for_both_TS=[cross_for_both_TS pp]
end
cross for both TS=cross for both TS;
64


APPENDIX D. MATLAB PROGRAM FOR TMA SECOND TRANSMISSION
POLICY
Iscript file: TMA
^purpose:
% Thesis program for simulate the Traffic Monitoring Algorithm
% of the Second transmission policy
%Date Programmer Description of change
%01/13/2011 Khaled Zaici Original code
clear ,close clc
alpha=l/2;
coulumn_test=200;
y=zeros(200000,coulumn_test);
all_zeros=200000;
lambda1=.4;
lambda0=.1;
thresholdl = 150 ;
threshold2=180;
Etta=(lambdaO-lambda1)/log(lambdaO/lambdal);
[tl,sll] = rat(Etta);
Sl=50;
t_l=ll;
1=40;
if lambdaO>lambdal
ime=l;
else
ime=0;
end
alpha_for_gamma=.4;
gamma_0=(1-alpha_for_gamma)* 1/(1-alpha_for_gamma*2) ;
gamma_l=alpha_for_gamma*(l-alpha_for__gamma)*1/(1-alpha_for_gammaA2);
C_constant=max(l/gamma_0,1/gamma_l);
C_constantl = C_constant + 2 ;
zita0=l-(1/(C_constantl*gamma_0));
zital=l-(1/(C_constantl*gamma_l));
for j=l: 14000
xl=rand(1);
x2=rand(1);
Il=log(l-xl)/log(zita0);
12=log(l-x2)/log(zital);
Ll=ceil(11) ;
L2 = ceil (12) ;
The_messages_arrival1=zeros(1,LI);
The_whole_interval=zeros(1,LI);
for i=2:Ll+1
65


r=rand(1) ;
The_messages_arrivall(i)=The_messages_arrivall(i-1)-log(1-
r)/lambdaO;
end
51 = The_messages_arrivall(The_messages_arrivall~=0);
if size(SI)==0
v=Sl;
else
v=Sl(end);
end
The_messages_arrival2=zeros(1, L2);
for i=2:L2+l
r=rand(1);
The_messages_arrival2(i)=The_messages_arrival2(i-1)-log(1-
r)/lambdal;
end
52 = The_messages_arrival2(The_messages_arrival2~=0);
S2_l=v+S2;
all__arrival= [SI S2_l] ;
if j==l
ccf=coulumn_test-length(all_arrival)
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival= [] ;
else
vl = find(nonzeros(y(j-l, :))) ;
ssdd=vl(end);
ssddl=y(j-1,ssdd);
all_arrival=all_arrival+ssddl;
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y(j,:)=y(j,:)+all_arrival;
all_arrival= [] ;
end
end
y = reshape (y1) ;
y=(nonzeros(y))';
arrival_time=y;
maximum_arrivals_time=max(arrival_time);
fram=40;
d=4 0 ;
H=ceil(maximum_arrivals_time/40);
count=0;
numbr_of_arrivals_in_each_fram=zeros(1,H);
c=arrival_time((arrival_time<=fram)&(arrival_time>=0));
numbr_of_arrivals_in__each_f ram (1) = length (c) ;
for i=2:H;
c=arrival_time((arrival time<=d+fram)&(arrival_time>=d))
numbr_of_arrivals_in_each_fram(i)=length(c);
if d>maximum arrivals time,break,end
66


d=d+fram ;
count=count+l;
end
count=count+1;
max_fram_length=max(numbr_of_arrivals_in_each_fram);
mean_fram_arrivals=mean(numbr_of_arrivals_in_each_fram);
d=0 ;
A=zeros(count,max_fram_length);
for j=l:H;
cl=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
fram_equal=[cl,zeros(1,max_fram_length-length(cl))];
A(j,:)=A(j,:)+fram_equal;
if d>maximum_arrivals_time,break,end
d=d+fram
end
mstart=ceil(log(1-rand(count,max_fram_length))./(log(alpha)));
[I,J]=size(A);
masseg_matrix=zeros(I, J) ;
for i=l:count
for j=1:max_fram_length
if A(i,j)~=0
masseg_matrix(i,j)=mstart ( i j) ;
else if A(i,j)==0
masseg_matrix(i,j)=0;
end
end
end
end
TX (1) = 0;TX1 = 0;TX 2 = 0 ;
u=0 ;
U1 = 0 ;
for i=l:I
if TX1<150
TX ( i + 1) =max (0 TX ( i) + (si *numbr__of_arrivals_in_each_f ram ( i) -
4 0 t_l) ) ;
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1> = 150
U=U+1;
T_0(u)=TX1;
bbb(u)=i;
cucu=nonzeros(A(i,:));
time_end_of_the_frame_0(u)=cucu(end);
frame_end_cross_threhold_0(u)=i*40;
TX ( i +1) = 0 ;
end
elseif TX1> = 150 && TX2<18 0
TX { i + 1) =max ( 0 TX ( i) ( si *numbr_of_arrivals__in_each_f ram ( i ) -
40*t_l));
TX2=TX(i+1);
67


T22(i)=TX(i+1);
if TX2> = 180
ul=ul+l;
T_1(ul)=TX2;
bbbl(u)=i;
cucul=nonzeros(A (i, :) ) ;
frame_end_cross_threhold_l(ul)=i*40;
if isempty(cucul)
time_end_of_the_frame_l(ul)= i*4 0;
else
cucul=nonzeros(A(i,:));
time_end_of_the_frame_l(ul)=cucul(end)
end
TX(i +1)= 0;
TX1 = 0;TX2 = 0;
end
end
end
for nn=l:I
Sll=zeros(1,I),-
Sll=Sll+thresholdl;
S22=zeros(1,1);
S22=S22+threshold2;
end
plot(Til, 1 -rs1)
hold on
plot(Sll,1LineWidth',2)
hold off
axis([1 1000 0 500])
f igure
plot(T22, .bs')
hold on
plot(S22,1LineWidth',2)
axis([1 1000 0 500])
hold off
cross_for_both_TS=[];
for 0=1:length(frame_end_cross_threhold_l)
pp= [frame_end_cross_threhold_0(O)
frame_end_cross_threhold_l (O) ] ,-
cross_for_both_TS=[cross_for_both_TS pp] ;
end
cross_for_both_TS=cross_for_both_TS;
Counter=zeros(1,8);
Counter_for_Al=zeros(1,8);
Counter_for_Al_32=zeros(1,32);
Counterl= [] ;
Counter2= [] ;
Delay_l=l0;
max__nutnber_of_packet=max (masseg_matrix ( : ) ) ;
SOFT DECISION=zeros(1,1);
68


delay_first=zeros(I,J);
mass_rejected_of_delay_per_frame_test=[];
mass_rejected_of_insufficient_delay_per_frame_test=[];
WASTED_CAPACITY=zeros(1,1) ;
REJECTED_MASSEGE_ALL_FRAMES=[];
Delay_constraint=60;
Delay_first_all=[];
frame_time_for_the_beginnig=l;
Al=zeros(I,J);
Delay_Matrix=zeros (I, J)
for NN=1:(length(cross_for_both_TS)/2-1)
for
i=frame_time_for_the_beginnig:(frame_end_cross_threhold_0(NN)/40-1)
finding_time=ones(1, 8);
finding_timel=(1:8);
t ime_of_f rame = i 4 0 f inding_t ime;
time_of_next_frame_allocation=f inding_timel+time_of_frame;
time_of_next_frame_allocationl = zeros(1,8) ;
Counter=Counter-1;
Counter(Counter<0)=0 ;
d=find(Counter==0);
dd=length(d);
time_subs=[];
number_of_available_slots=d;
mass_rejected of delay per frame = 0;
j th=0;
for j=l:dd
CF=d(j);
j th=j th+1;
if masseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,j th) ;
Counter_for_Al(CF)=A(i,jth);
delay_first(i,j)=time_of_next_frame_allocation(j)-A(i,j);
if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,jth+1);
j th=j th+1;
mass_rej ected_of_delay_per_frame=mass_rej ected_of_delay_per_frame + 1;
number_of _available_slots=number_of_available_slots + l ,-
A1 ( i,j th)=0 ;
Counter_for_Al(CF)=0;
end
A1(i,j th)=A(i,jth) ;
end
?. c. o. a. c-. c, u. o o. a. o. e.
5 c v o '6 o ; '6 'o 'o b o '6
for jfk=l:max_number_of_packet
location_Numbers_of_zeros_available=find(Counter==0);
Numbers_of_zeros__available=length(find(Counter==0));
location_of_Counter_g_l = find(Counter>l) ;
69


location_masseg_matrix_g_l=find(masseg_matrix(i, :)>1)
Number_of_1ocation_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter=Counter;
Counter_for_Al=Counter_for_Al;
if Numbers_of_zeros_available==0 |
Number_of_location__of_Counter_g_l==0 ,break,end
elseif Numbers_of_zeros_available<
Numb e r_o f_1oc a t i on_o f_Count e r_g_1
for j j =1: Numbers__of_zeros_available
CD=location_of_Counter_g_l(j j) ;
Counter_for_Al(CD)=A(i,CD);
Counter(CD);
Counter(CD)=Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
elseif Numbers_of_zeros_available >=
N umb e r_o f_locati on_o f_Counte r_g_1
for j j =1:Number_of_location_of_Counter_g_l
CD=location_of_Counter_g_l(j j) ;
Counter(CD)=Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
end
end
% Delay Calculation
for j j j =1:8
delay_l=0;
delay_2=0;
Location_of_f irst_A=f ind(A(i,j j j)==Counter_for_Al(:)) ;
if isempty(Location_of_first_A)
if masseg_matrix(i,jjj)>0
delay_f irst_packet = i *4 0- A(i,j j j) ;
else
delay_f irst_packet = 0;
delay_l=0;
end
else
if masseg_matrix(i,jjj)>0
delay_f irst_packet = i*4 0- A(i,j j j)+Locat ion_of_first_A(1);
length_Location_of_f irst_A=length(Locat ion_of_f irst_A)
if length_Location_of_first_A >1
for j fn=l:length_Location_of_first_A-1
delay__l= (Locat ion_of_f irst_A (j f n +1) -
Location_of_f irst_A(j fn))+delay_l;
70


end
end
else
delay_first_j?acket=0;
delay_l=0;
end
end
if masseg_matrix(i,jjj)>1
delay_2=(masseg_matrix(i,j j j)-1)*40;
end
Delay_Matrix(i,j j j)=delay_f irst_packet+delay_l + delay_2;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%
mass_rej ected_of_delay_per_frame_test =[mass_rej ected_of_delay_jper_f r
ame_test mass_rejected_of_delay_per_frame];
wasted_slots_per_frame=length(find(Counter==0));
WASTED_CAPACITY(i)= wasted_slots_per_frame;
if dd==0
number_of_rejected_masseg_insufficient_slot=length(nonzeros(masseg_m
atrix( i : ) ) ) ;
elseif isempty(nonzeros(masseg_matrix(i,j th:end)))
number_of_rejected_masseg_insufficient_slot=0;
else
number_of_rej ected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,jth+l:end)));
end
mass_rej ected_of_insufficient_delay_per_frame_test=[mass_rej ected__of
_insuff icient_delay_per_frame_test
number_of__re j ected_masseg_insuff icient_slot] ;
mass_rej ected_of_each_framel=mass_rej ected_of_delay__per_frame+number
_of_rej ected_masseg_insuff icient_slot,-
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_re j ected__of _each_f ramel],-
Counterl= [Counterl; Counter] ;
u=l ;
SOFT_DECISION(i)=u;
end
%%%%%%*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%?%%!%%%%%%%%%%%%%%%%%%%%%%
i 3 i i %
frame_time_for_the_beginnig=frame_end_cross_threhold_l(NN)/40;
Counter__second= [Counter zeros (1,24)] ,-
Counter_for_Al_32=[Counter_for_Al zeros(1,24)];
for
i=(frame_end_cross_threhold_0(NN)/40):(frame_time_for_the_beginnig-
1)
f inding_time=ones(1,32) ;
71


finding_timel=(1:32);
t ime_of_f rame = i 4 0 f inding_t ime;
time_of_next_frame_allocation=finding_timel+time_of_frame;
Counter_second=Counter_second-1,-
Counter_second(Counter_second<0)=0;
d=find(Counter_second==0);
dd=length(d);
mass_rej ected_of_each_framel = 0;
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0;
jth=0;
for j=l:dd
CF=d(j);
j th=j th+1;
if jth>J, break, end
if masseg_matrix(i,jth)= = 0, break, end
Counter_second (CF) =masseg_raatrix (i, j th) ,-
delay_f irst (i j ) =time_of_next_frame_allocation (j ) A (i j )
if delay_first(i,j)>Delay_constraint
Counter_second(CF)=masseg_matrix(i,j th+1) ;
j th=j th+1;
mass_rej ected_of__delay_per_frame=mass_rej ected_of_delay_per_frame+1 ;
number_of_available_slots=number_of __available_slots + l;
A1(i,jth)=0;
end
A1(i,jth)=A(i,jth);
end
. o, o, O. o.
- ?- y- y- £
for jfk=l:max_number_of_packet
location_Numbers_of_zeros_available = f ind(Counter_second= = 0) ;
Numbers_of_zeros_available=length(find(Counter_second==0));
location_of_Counter_g_l=find(Counter_second>l);
Number_of_location_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter_second=Counter_second;
if Numbers_of__zeros_available = = 0 |
Number_of_location_of_Counter_g_l==0 ,break,end
el seif Numbers_of_zeros_available<
Number_of_1ocation_of_Counter_g_l
for j j =1:Numbers_of_zeros_available
CD=location_of_Counter_g_l(j j) ;
Counter_second(CD)=Counter_second(CD)-1 ;
CFF=location_Numbers_of_zeros_available(jj);
if CD > J
Counter for A1 32(CFF)=0;
72


else
Counter_for_Al_32(CFF)=A(i,CD);
end
Counter_second(CFF)=1;
end
elseif Numbers_of_zeros_available >=
Number_of_location_of_Counter_g_l
for j j =1:Number_of_location_of_Counter_g_l
CD=location_of_Counter_g_l(jj);
Counter_second(CD)=Counter_second(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter_second(CFF)=1;
if CD > J
Counter_for_Al_32(CFF)=0;
else
Counter_for_Al_32(CFF)=A(i,CD);
end
end
end
end
% DELAY CALCULATION
for j j j = 1:J
delay_l=0;
delay_2=0;
Location_of_first_A_32=find(A(i,j j j)==Counter_for_Al_32(:))
if isempty(Location_of_f irst_A_3 2)
if masseg_matrix(i,jjj)>0
delay_f irst_packet = i*40-A(i,j j j) ;
else
delay_first_packet = 0 ;
delay_l=0;
end
else
if masseg_matrix(i,jjj)>0
delay_f irst__packet = i*4 0 A ( i j j j ) +Location_of_f irst__A_3 2 (1);
length_Location_of_f irst_A_32 = length(Location_of_f irst_A_3 2) ;
if length_Location_of_first_A_32 >1
for j fn=l:length_Location_of_f irst_A_32-1
delay_l= (Location__of_f irst_A_3 2 (j fn+1) -
Location_of_first_A_32(j fn))+delay_l;
end
end
else
delay_f irst_packet = 0;
delay_l=0;
end
end
if masseg_matrix(i,jjj)>1
delay__2= ( (masseg_matr ix (i,jjj)-l)*40)/2;
end
73


Delay_Matrix(i,jjj)=delay_first_packet+delay_l+delay_2/2;
end
oo o'o'o'o o o'o'o 0'S o "b c'o'ob'o'o'o o'ob'o o o o 15 OQ'oobooo'o'b'o'o'bo'a'o'o'o'o'oo'oo'o'b'o'o'o'ooooQ'o'o'oo'o'o
o, t, a, o_
'6 o o 'o
mass_rej ected_of_delay_per_frame_test=[mass_rej ected_of_delay_per_fr
ame_test mass_rejected_of_delay_per_frame];
wasted_slots_per_frame=length(find(Counter_second==0));
WASTED_CAPACITY(i)= wasted_slots_per_frame;
if isempty(nonzeros(masseg_matrix(i,jth:end)))
number_of_rejected_masseg_insufficient_slot=0;
else
number_of_rejected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,jth+1:end)));
endl=length(masseg_matrix(i,jth+1:end));
A1(i,jth+1:endl)=0;
end
mass_rej ected_of_insufficient_delay_per_frame_test=[mass_rej ected_of
_insuf f icient_delay_per_frame_test
number_of_rej ected_masseg_insuff icient_slot] ;
mass_rejected_of_each_framel=mass_rejected_of_delay_per_frame+number
_of_rej ected_masseg_insuf f icient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counter2=[Counter2; Counter_second];
U = 0 ;
SOFT_DECISION(i)=u;
end
if isempty(nonzeros(Counter_second(9:32)))
Number_of_inturpted_masseges=0;
else
number_found=Counter_second(9:32)-1;
number_found(number_found<0)=0;
Number_of_inturpted_masseges=length(nonzeros(number_found));
end
REJECTED_MASSEGE_ALL_FRAMES(end)=REJECTED_MASSEGE_ALL_FRAMES(end)+Nu
mber_of_inturpted_masseges;
length_of_rejcted=REJECTED_MASSEGE_ALL_FRAMES(end);
for jf=1:length_of_rejcted
cdfl=find(nonzeros(A1(i,:)));
if (isempty(cdf1)) ,break,end
dnn=cdf1(end);
A1(i,dnn)=0;
end
Counter=Counter_second(1:8);
end
for i=frame_time_for_the_beginnig:(I(end))
f inding_time=ones(1,8) ;
finding_timel=(1:8);
time_of_frame=i*40*finding_time;
time_of_next_f rame_al 1 ocat ion=f inding_timel + time_of_f rame
74


Counter=Counter-1;
Counter(Counter<0)=0;
d=find(Counter==0);
dd=length(d);
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0;
jth=0;
for j=l:dd
CF=d(j ) ;
j th=j th+1;
if raasseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,j th) ;
delay_f irst(i,j)=time_of_next_frame_allocation(j)-A(i, j) ;
if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,jth+1);
j th=j th+1;
mass_rejected_of_delay_per_frame=mass_rejected_of_delay_per_frame+1
number_of_available_slots=number_of_available_slots+l;
A1(i,j th)=0;
end
A1(i,jth)=A(i,jth);
end
% Transmission of Available slots
for jfk=l:max_number_of_packet
location_Numbers_of_zeros_available = f ind(Counter= = 0) ;
Numbers_of_zeros_available=length(find(Counter==0));
location__of_Counter_g_l = f ind (Counter>l) ;
Number_of_location_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter=Counter;
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0 ,break,end
elseif Numbers_of_zeros_available<
Number_of_location_of_Counter_g_l
for jj=l:Numbers_of__zeros_available
CD=location_of_Counter_g_l(jj);
Counter(CD)=Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter__for_Al (CFF) =A(i,CD) ;
end
elseif Numbers_of_zeros_available >=
Number_of_location_of_Counter_g_l
for j j =1:Number_of_location_of_Counter_g_l
CD=location_of_Counter_g_l(jj);
Counter(CD)=Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(jj);
Counter(CFF)=1;
Counter for A1(CFF)=A(i,CD);
75


end
end
end
% Delay Calculation
for j j j = 1: 8
delay__l = 0
delay_2=0;
Location_of_first_A=find(A(i,j j j)==Counter_for_Al(:)) ;
if isempty(Location_of_first_A)
if masseg_matrix(i,jjj)>0
delay_first_packet=i*40-A(i,j j j);
else
delay_first_packet=0;
delay_l=0;
end
else
if masseg_matrix(i jjj ) >0
delay_f irst_packet=i*40-A(i,j j j)+Location_of_first_A(1);
length_Location_of_first_A=length(Location_of_first_A);
if length_Location_of_first_A >1
for j fn=l:length_Location_of_first_A-1;
delay_l=(Location_of_first_A(j fn+1)-
Location_of_first_A(j fn))+delay_l;
end
end
else
delay_f irst_packet = 0;
delay_l=0;
end
end
if masseg_matrix(i,jjj)>1
delay_2=(masseg_matrix(i,j j j)-1)*40;
end
Delay_Matrix(i,j j j)=delay_first_packet+delay_l+delay_2;
end
mass__re j ected_of_delay_per_f rame_test= [mass_re j ected_of_delay_per_f r
ame_test massrejected_of_delay_per_frame];
wasted_slots_per_frame = length(find(Counter= = 0) ) ;
WASTED_CAPACITY(i)=wasted_slots_per_frame;
if dd==0
number_of_rej ected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,:)));
elseif isempty(nonzeros(masseg_matrix(i,j th:end)))
number_of_rej ected_masseg_insuff icient_slot = 0;
else
number_of_rej ected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,jth+l:end)));
endl = length(masseg_matrix(i,j th+1:end)) ;
Al (i,j th+1:endl)=0;
76


end
mass_re j ected_of_insuf f icient_delay_per__f rame_test = [mass_re j ected_of
_insufficient_delay_per_frame_test
number_of_rej ected_masseg_insufficient_slot] ;
mass_rejected_of_each_framel=mass_rejected_of_delay_per_frame+number
_of_rej ected_masseg_insufficient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counterl=[Counterl; Counter];
U=1 ;
SOFT_DECISION(i)=u;
end
for i=l:I
for j =1 : J
if A1(i,j)>0
A1(i,j)=1;
end
end
end
all_delay_together=sum(Delay_Matrix(:));
DELAY=(all_delay_together/length(nonzeros(Delay_Matrix(:)))-Delay_l)
[II Jl]=size(Counterl);
[12 J2]=size(Counter2);
Wasted_capacity_rate=sum(Counterl(:)==0)/(ll*Jl)+
sum(Counter2(:)==0)/(I2*J2)
rej ection_rate = sum(nonzeros(REJECTED_MASSEGE_ALL_FRAMES))/(length(y)
)
w2=log(((1-Wasted_capacity_rate)*(1-
rejection_rate))/(rejection__rate*Wasted_capacity_rate))
save SOFT DECISIONS
77


APPENDIX E. MATLAB PROGRAM FOR DTMA 2 NODES SECOND
TRANSMISSION POLICY
Iscript file: 2 nodes DTMA
Ipurpose:
% Thesis program for simulate the Distributed Traffic Monitoring
%Algorithm 2 nodes of the Second transmission policy
%Date Programmer' Description of change
%0l/l3/2011 Khaled Zaid Original code
clear ,close clc
load SGFT_DECISIONI
S0FT_DECISI0N1=S0FT_DECISI0N;
wl=wl
load SOFT_DECISI0N2
w2=w2
S0FT_DECISI0N2=S0FT_DECISI0N;
[B1 Zl]=size(S0FT_DECISI0N1);
[B2 Z2]=size(S0FT_DECISI0N2);
f inal_frame_allowable=min(Zl,Z2) ;
SOFT_DECISIONl=SOFT_DECISIONl(1:final_frame_allowable);
SOFT_DECISION2=SOFT_DECISION2(1:final_frame_allowable);
clear y, clear cross for both_TS, clear REJECTED MASSEGE ALL FRAMES
alpha=l/2;
coulumn_test=200;
y=zeros(200000,coulumn_test);
all_zeros=200000;
1ambda1=.4;
lambda0=.1;
thresholdl=150;
threshold2 = 180 ;
Etta= (lambdaO-latnbdal) /log (lambdaO/lambdal) ;
[tl,sll] = rat(Etta);
S1 = 5 0 ;
t_l=ll;
1 = 4 0 ;
if Iambda0>lambdal
ime=l;
else
ime=0;
end
alpha for_gamma= 8
gamma_0=(1-alpha_for_gamma)* 1/(1-alpha_for_gammaA2) ;
gamma_l=alpha_for_gamma*(l-alpha_for_gamma)*1/(1-alpha_for_gamma^2)
C_constant=max(1/gamma_0,1/gamma_l);
C constantl^C constant+2;
78


zitaO=l-(1/(C_constantl*gamma_0));
zital=l-(1/(C_constantl*gamma_l));
for j =1:22500
xl=rand(1);
x2=rand(1);
ll=log(l-xl)/log(zitaO);
12=log(l-x2)/log(zital);
Ll = ceil (11) ;
L2 = ceil (12) ;
The_messages_arrivall=zeros(1,LI);
The_whole_interval=zeros(1,LI);
for i=2:Ll+1
r=rand(1);
The_messages_arrival1(i)=The_messages_arrivail(i-1)-log (1
r)/lambdaO;
end
51 = The_messages_arrivall(The_messages_arrivall~=0);
if size(Sl)==0
v=Sl ;
else
v=Sl(end);
end
The_messages_arrival2=zeros(1,L2);
for i=2:L2+1
r=rand(1);
The_messages_arrival2(i)=The_messages_arrival2(i-1)-log(1
r)/lambdal;
end
52 = The_messages_arrival2(The_messages_arrival2~=0);
S2_l=v+S2;
all_arrival=[SI S2_l];
if j==l
ccf=coulumn_test-length(all_arrival);
all_arrival=[all_arrival zeros(1,ccf)];
y (j : ) =y (j : ) +all__arrival ;
all_arrival= [] ;
else
vl = f ind(nonzeros(y(j-1, :))) ;
ssdd=vl(end);
ssddl=y(j-1,ssdd);
all__arrival = all_arrival + ssddl ;
ccf=coulumn_test-length(all_arrival);
al l_arrival = [all__arrival zeros (1, ccf ) ] ;
y (j, ;)y(j/ :)+all_arrival;
all_arrival=[];
end
end
y = reshape(y1) ;
y=(nonzeros(y))1;
79


arrival_time=y;
raaximura_arrivals_tirae=raax(arrival_time);
fram=40;
d=4 0 ;
H=ceil(maximum_arrivals_time/40);
count=0;
numbr_of_arrivals_in_each_fram=zeros(1,H);
c=arrival_time((arrival_time<=fram)&(arrival_time>=0));
numbr_of_arrivals_in_each_fram(1)=length(c);
for i = 2 : H ;
c=arrival_time{(arrival_time<=d+fram)&(arrival_time>=d));
numbr_of_arrivals_in_each_fram (i) =length (c)
if d>maximum__arrivals_time, break, end
d=d+fram
count=count+1;
end
count=count+1;
max_fram_length=max(numbr_of_arrivals_in_each_fram);
mean_fram_arrivals=mean(numbr_of_arrivals_in_each_fram);
d=0;
A=zeros(count,max_fram_length);
for j=l:H;
cl=arrival_time((arrival_time<=d+fram)&(arrival_time>=d));
fram_equal=[cl,zeros(1,max_fram_length-length(cl))];
A(j,:)=A(j,:)+fram_equal;
if d>maximum_arrivals_time,break,end
d=d+fram
end
mstart=ceil(log(1-rand(count,max_fram_length))./(log(alpha)))
[I,J]=size(A);
masseg_matrix=zeros(I,J);
for i=l:count
for j=1:max_fram_length
if A(i,j)~=0
masseg_matrix(i,j)=mstart(i,j);
else if A(i,j)==0
masseg__matrix ( i j ) =0 ;
end
end
end
end
A=A(1:final_frame_allowable,:);
masseg_matrix=masseg_matrix(1:final_frame_allowable,:);
[I,J]=size(A);
length_of_y=length(nonzeros(A(:)));
TX(1)=0;TX1=0;TX2=0;
u=0 ;
ul = 0 ;
for i = 1:I
80


if TX1< 202.3981 %269.2458
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i
) *w2 ;
TX(i+1)=max(0,TX(i)+(sum_of_weigh_and_soft_decieion*sl/log(lambdal/1
ambdaO)+sl*numbr_of_arrivals_in_each_fram(i)-40*t_l));
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1>=202.3981 %269.2458
U=U+1;
T_0(u)=TX1;
bbb(u)= i;
cucu=nonzeros(A(i,:));
time_end_of_the_frame_0(u)=cucu(end);
f rame__end_cross_threhold_0 (u) =i*40 ;
TX(i +1)= 0 ;
end
elseif TX1>=202.3981 && TX2< 245.2037 1269.2458
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+S0FT_DECISI0N2(i
) *w2 ;
TX(i +1)=max(0,TX(i)-
(sum_of_weigh_and_soft_decieion*sl/log(lambda1/lambda0)+sl*numbr_of_
arrivals__in_each_f ram ( i) -40*t_l) ) ;
TX2=TX(i + 1) ;
T22(i)=TX(i + 1) ;
if TX2>= 245.2037
ul=ul+l;
T_1(ul)=TX2;
bbbl(u)=i;
cucul=nonzeros(A(i,:));
frame_end_cross_threhold_l(ul)=i*40;
if isempty(cucul)
time_end_of_the_frame_l(ul)=i*40;
else
cucul=nonzeros(A(i,:));
time_end_of_the_frame_l(ul)=cucul(end);
end
TX(i +1)= 0 ;
TX1 = 0;TX2 = 0 ;
end
end
end
for nn=l:I
Sll = zeros(1,1) ;
Sll=Sll+thresholdl;
S22 = zeros(1,1) ;
S22=S22+threshold2;
end
plot (Til,
hold on
81


plot(Sll,'LineWidth',2)
hold off
axis([1 1000 0 500] )
figure
plot(T22,'--bs')
hold on
plot(S22,'LineWidth,2)
axis( [1 1000 0 500])
hold off
cross_for_both_TS=[];
for 0=1:length(frame_end_cross_threhold_l)
pp=[frame_end_cross_threhold_0(0)
frame_end_cross_threhold_l(0)];
cross_for_both_TS=[cross_for_both_TS pp] ;
end
cross_for_both_TS=cross_for_both_TS;
o. o
% transmission, delay, rejection and capacity wasted
Counter=zeros(1,8),-
Counter_for_Al = zeros(1, 8);
Counter_for_Al_32=zeros(1,32);
Counterl=[];
Counter2=[];
max_number_of_packet=max(masseg_matrix(:));
S0FT_DECISI0N=zeros(1,1);
delay_first=zeros(I,J);
mass_rejected_of_delay_per_frame_test=[];
mass_rejected_of_insufficient_delay_per_frame_test= [] ;
WASTED_CAPACITY=zeros(1,1);
REJECTED_MASSEGE_ALL_FRAMES=[];
Delay_constraint=60;
wated_factor=.3;
Delay_first_all=[];
frame_time_for_the_beginnig=l;
Al=zeros(I,J);
Delay_Matrix=zeros(I, J) ;
for NN=1:(length(cross_for_both_TS)/2-1)
for
i = frame_time_for_the_beginnig: (frame_end_cross__threhold_0(NN)/40- 1)
f inding_t ime=ones(1,8);
finding_timel=(1:8);
time_of_frame=i*40*finding_time;
t ime_of_next_frame_allocat ion= f inding_t imel +1 ime_of_frame;
time_of_next_frame_allocationl=zeros(1,8);
Counter=Counter-1;
Counter(Counter<0) =0 ;
d=find(Counter==0);
dd=length(d);
time_subs= [] ;
number of available slots=d;
82


mass_rej ected_of_delay_per_frame = 0;
j th=0;
for j=l:dd
CF=d(j);
j th=j th+1;
if masseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,j th) ;
Counter_for_Al(CF)=A(i,jth);
delay_first(i,j)=time_of_next_frame_allocation(j)-A(i,j);
if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,j th+1) ;
jth=jth+l;
mass_rej ected_of _delay__per_f rame=mass_re j ected_of_delay_per_frame+1;
number_of_available_slots=number_of_available_slots+l;
A1(i,jth)=0;
Counter_for_Al(CF)= 0;
end
A1(i,jth)=A(i,jth);
end
for j fk=l:max_number_of_packet
location_Numbers_of_zeros_available=find(Counter==0);
Numbers_of_zeros_available=length(find(Counter==0));
location_of_Counter_g_l=find(Counter>l);
location_masseg_inatrix_g_l = find(masseg_matrix(i, :)>1) ;
Number_of_location_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter=Counter;
Counter_for_Al=Counter_for_Al;
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0 ,break,end
elseif Numbers_of_zeros_available<
Number_of_location_of_Counter_g_l
for j j =1:Numbers_of_zeros_available
CD=location_of_Counter_g_l(j j) ;
Counter_for_Al(CD)=A(i,CD);
Counter(CD);
Counter(CD)=Counter(CD)-1;
CFF = location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
elseif Numbers_of_zeros_available >=
Number_of_locat ion_of __Counter_g__l
for j j =1:Number_of_location_of_Counter_g_l
83


CD=location_of_Counter_g_l(j j) ;
Counter(CD)=Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
end
end
for j j j =1: 8
delay_l=0;
delay_2=0;
Location_of_f irst_A=f ind(A(i,j j j)==Counter_for_Al(:)) ;
if isempty(Location_of_first_A)
if masseg_matrix(i,jjj)>0
delay_f irst_packet = i*40-A(i,j j j) ;
else
delay_first_packet=0;
delay_l = 0
end
else
if masseg_matrix(i,jjj)>0
delay_first_packet = i*40-A(i,j j j)+Location_of_first_A(1);
length_Location_of_f irst_A=length(Location_of_first_A)
if length_Location_of_first_A >1
for j fn=l:length_Location_of_first_A-l
delay_l= (Location_of_f irst__A( j fn+1) -
Location_of_f irst_A(j fn))+delay_l;
end
end
else
delay_first_packet=0;
delay_l=0;
end
end
if masseg_matrix(i,jjj)>1
delay_2=(masseg_matrix(i,j j j) -1)*40;
end
Delay_Matrix(i,j j j)=delay_f irst_packet+ delay_l;
end
mass rej ected_of_delay_per_frame_test=[mass_rejected_of_delay_per_f
ame_test mass_rejected_of_delay_per_frame];
wasted_slots_per_f rame = length ( f ind (Counter= = 0 ) )
WASTED_CAPACITY(i)= wasted_slots_per_frame;
if dd==0
84


number_of_rejected_masseg_insufficient_slot=length(nonzeros(masseg_m
atrix(i,: ) ) ) ;
elseif isempty(nonzeros(masseg_matrix(i,jth:end)))
number_of_rejected_masseg_insufficient_slot=0;
else
number_of_rej ected_masseg_insufficient_slot = length(nonzeros(masseg_m
atrix(i,jth+1:end)));
end
mass_rej ected_of_insufficient_delay_per_frame_test=[mass_rejected_of
_insuff icient_delay_per_frame_test
number_of_rej ected_masseg_insufficient_slot] ;
mass_rej ected_of_each_framel=mass_rej ected_of_delay_per_frame+number
_of_rej ected_masseg_insuff icient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counterl=[Counterl; Counter];
u=l ;
SOFT_DECISION(i)=U;
end
"6 %
frame_time_for_the_beginnig=frame_end_cross_threhold_l(NN)/40;
Counter_second=[Counter zeros(1,24)];
Counter_for_Al_32=[Counter_for_Al zeros(l,24)];
for
i=(frame_end_cross_threhold_0(NN)/40):(frame_time_for_the_beginnig-
l)
finding_time=ones(1,32);
f inding__timel= (1:32) ;
t ime_of _f rame = i *4 0 f inding_t ime ;
t ime_o f_next_f rame_allocat ion=f ind ing_t ime1 +1 ime_of_f rame;
Counter_second=Counter_second-1;
Counter_second(Counter_second<0)=0;
d=find(Counter_second==0);
dd=length(d)
mass_rej ected_of_each_framel = 0;
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0;
j th=0;
for j=l:dd
CF=d(j);
j th=j th+1;
if jth>J, break, end
if masseg_matrix(i,jth)==0,break, end
Counter_second(CF)=masseg_matrix(i,jth);
delay_f irst ( i j ) =t ime_of__next_f rame_allocation (j ) -A ( i j ) ;
if delay_first(i,j)>Delay_constraint
85


Counter_second(CF)=masseg_matrix(i,j th+1);
j th=j th+1;
mass_rej ected_of_delay_per_frame=mass_rejected_of_delay_per_frame+1;
numbe r_o f_ava ilable_slots =number_o f_avai1ab1e_s1ot s +1;
A1 (i, j th) =0
end
A1(i,jth)=A(i,jth);
end
o o. o, o, o o.Q,q, o 0.0,0, o o. q, o, o o. q, o, o o. o, o, o, o. o. o, o, o. a, o, o, o. q, o, o, o, a, a o, c. e, o, o, o, a, o, o, o. o, o, o, o. g, o, o,. o. c. o o o, q, o, o, c, o,
'o b "5 'o 'o 'a "a o b b "5 'o 'o 'o a o 'o o "o 'o b 'o 15 'o o "b o "o 'o o o o 'o "6 "e "& o 'o o "a o b 'o "o o b 'o "5 o b 'o o o bob o b 'o o o b 'o "c o
o,o o, o. c, o,, o, o, e, o q, o, c, o, o, o., v, 0.. o, o, v. 0,. q. o, o, o,. o, q, o, o,
'0 "3 b "b 'o 3 'o 'o o b 'c b 'c o 'e 'b 'b o 'o 'b 'b o 'o *o fc o 'o 'b b o
for jfk=l:max_number_of_packet
location_Numbers_of_zeros_available=find(Counter_second==0);
Numbers_of_zeros_available=length(find(Counter_second==0));
1oc a t i on_o f_Count e r_g_l = f ind(Count e r_s e cond>1);
Number_of_location_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter_second=Counter_second;
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0 ,break,end
elseif Numbers_of_zeros_available<
Number_of_location_of_Counter_g_l
for j j =1:Numbers_of_zeros_available
CD=location_of_Counter_g_l(jj);
Counter_second(CD)=Counter_second(CD)-1;
CFF=location_Numbers_of_zeros_available(j j);
if CD > J
Counter_for_Al_32(CFF)= 0;
else
Counter_for_Al_32(CFF)=A(i,CD);
end
Counter second(CFF)=1;
end
elseif Numbers_of_zeros_available >=
Number_of_location_of_Counter_g_l
for j j =1:Number_of_location_of_Counter_g_l
CD=location_of_Counter_g_l(jj);
Counter_second(CD)=Counter_second(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter_second(CFF)=1;
if CD > J
Counter_for_Al_32(CFF)=0;
else
Counter_for_Al_3 2(CFF)=A(i,CD) ;
end
end
end
86


end
fr jjj=l:J
delay_l=0;
delay_2=0
Location_of_first_A_32=find(A(i,j j j)==Counter_for_Al_32(:)) ;
if isempty(Location_of_first_A_32)
if masseg_matrix(i,jjj)>0
delay_f irst_packet=i*40-A(i,j j j) ;
else
delay_first_packet=0 ;
delay_l=0;
end
else
if masseg_matrix(i,jjj)>0
delay_first_packet=i*40-A(i,jjj)+Location_of_first_A_32(1);
length_Location_of_first_A_32=length(Location_of_first_A_32);
if length_Location_of_first_A_32 >1
for j fn=l:length_Location_of_first_A_32-1
delay_l=(Location_of_first_A_32(j fn+1) -
Location_of_first_A_32(j fn))+delay_l;
end
end
else
delay_first_packet=0;
delay_l=0;
end
end
if masseg_matrix(i,jjj)>1
delay_2=(masseg_matrix(i,j j j)-1)*40;
end
Delay_Matrix{i,j j j)=delay_first_packet+delay_l+delay_2/l.5;
end
%%%%%%%%%%%%%%%%%%%%%%%!%%%%%%%%%%%%%%%!:%%%%%%%%%%%%%%%%%%%%%%%%
mass_rej ected_of_delay_per_frame_test=[mass_rejected_of_delay_per_fr
ame_test mass_rejected_of_delay_per_frame];
wasted_slots_per_frame=length(find(Counter_second==0));
WASTED_CAPACITY(i)= wasted slots per frame;
if isempty(nonzeros(masseg_matrix(i,jth:end)))
number_of_rejected_masseg_insufficient_slot=0;
else
number_of_rejected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i,jth+l:end)));
endl=length(masseg_matrix(i,jth+1:end));
A1(i,j th+1:endl)=0;
end
mass_rej ected_of_insuf f icient_delay_per_frame_test=[mass_rej ected__of
87


_insufficient_delay_per_frame_test
number_of_rej ected_masseg_insuff icient_slot] ;
mass_rejected_of_each_framel=mass_rej ected_of_delay_per_frame+number
_of_rej ected_masseg_insuff icient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_re j ected_of__each_f ramel] ;
Counter2=[Counter2; Counter_second];
u=0 ;
SOFT_DECISION(i)=u;
end
if isempty(nonzeros(Counter_second(9:32)))
Number_of_inturpted_masseges=0;
else
number_found=Counter_second(9:32)-1;
number_found(number_found<0)=0;
Number_of_inturpted_masseges=length (nonzeros (number_found) )
end
REJECTED_MASSEGE_ALL_FRAMES(end)=REJECTED_MASSEGE_ALL_FRAMES(end)+Nu
mber_of_inturpted_masseges;
length_of_rejcted=REJECTED_MASSEGE_ALL_FRAMES(end);
for jf=1:length_of_rejcted
cdfl = find(nonzeros(A1(i :))) ;
if (isempty(cdf1)) ,break,end
dnn=cdf1(end);
A1(i,dnn)=0;
end
Counter=Counter_second(1:8);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%
for i=frame_time_for_the_beginnig:(I(end))
f inding__time=ones (1,8) ;
f inding_timel=(1:8) ;
t ime_of_frame = i 4 0 f inding_t ime;
t ime_of_next_f rame_allocat ion= f inding_t ime1 +1 ime_of_frame;
Counter=Counter-l;
Counter(Counter<0)=0;
d=find(Counter==0);
dd=length(d);
number_of_available_slots=d;
mass_rej ected_of_delay_per_frame = 0;
j th=0;
for j =1:dd
CF=d(j ) ;
j th=j th+1;
if masseg_matrix(i,jth)==0,break, end
Counter(CF)=masseg_matrix(i,jth) ;
88


delay_first(i,j)=time_of_next_frame_allocation(j)-A(i,j);
if delay_first(i,j)>Delay_constraint
Counter(CF)=masseg_matrix(i,j th+1) ;
j th=j th+1;
mass_rejected_of_delay_per_frame=mass_rej ected_of_delay__per_frame + 1
number_of_available_slots=number_of_available_slots+l;
A1(i,j th)=0;
end
A1(i,j th)=A(i,j th) ;
end
for j fk=1:max_number_of_packet
location_Numbers_of_zeros_available = f ind(Counter= = 0) ;
Numbers_of_zeros_available=length(find(Counter==0));
location_of_Counter_g_l=find(Counter>l);
Number_of_location_of_Counter_g_l=length(location_of_Counter_g_l);
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0
Counter=Counter;
if Numbers_of_zeros_available==0 |
Number_of_location_of_Counter_g_l==0 ,break,end
elseif Numbers_of_zeros_available<
Numbe r_o f_locati on_o f _C ount e r_g_1
for j j =1:Numbers_of_zeros_available
CD=location_of_Counter_g_l(jj);
Counter(CD)^Counter(CD)-1;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
elseif Numbers_of_zeros_available >=
Number_of_location_of_Counter_g_l
for j j =1:Number_of_location_of_Counter_g_l
CD=location_of_Counter_g_l(jj);
Counter(CD)^Counter(CD)-1 ;
CFF=location_Numbers_of_zeros_available(j j) ;
Counter(CFF)=1;
Counter_for_Al(CFF)=A(i,CD);
end
end
end
for j j j =1:8
delay_l=0;
delay_2=0;
Location_of_first_A=f ind(A(i,j j j)==Counter_for_Al(:) ) ;
if isempty (Location_of__f irst_A)
if masseg__matr ix ( i j j j ) >0
delay_f irst_packet = i*40-A(i,j j j) ;
else
89


delay_first_packet=0 ;
delay_l=0;
end
else
if masseg_matrix(i,jjj)>0
delay_first_packet=i*40-A(i,jjj)+Location_of_first_A(l);
length_Location_of_first_A=length(Location_of_first_A);
if length_Location_of_first_A >1
for j fn=l:length_Locat ion_of_first_A-1;
delay_l=(Location_of_first_A(j fn+1)-
Location_of_first_A(j fn))+delay_l;
end
end
else
delay_first_packet = 0 ;
delay_l=0;
end
end
if masseg_matrix(i jjj)>1
delay_2=(masseg_matrix(i,jjj)-1)*40;
end
Delay_Matrix(i,j j j)=delay_first_packet+delay_l+delay_2;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%!%%%%%%% %%%%%%%%%%%%%%%%%%%%%
%%%%
mass_rejected_of_delay_per_frame_test=[mass_rejected_of_delay_per_fr
arae_test mass_rejected_of_delay_per_frame];
wasted_slots_per_frame = length(find(Counter= = 0) ) ;
WASTED_CAPACITY(i)=wasted_slots_per_frame;
if dd==0
number_of_rejected_masseg_insuff icient_slot = length(nonzeros(masseg_m
atrix(i :)) ) ;
elseif isempty(nonzeros(masseg_matrix(i,jth:end)))
number_of_rejected_masseg_insufficient_slot=0;
else
number_of_rejected_masseg_insufficient_slot=length(nonzeros(masseg_m
atrix(i,jth+1:end)));
endl = length(masseg_matrix(i,j th+1:end)) ;
A1 (i,j th+1:endl)= 0;
end
mass_rejected_of_insuff icient_delay_per_frame_test=[mass_rej ected_of
__insuf f icient_delay_per_f rame_test
number_of_rej ected_masseg_insuff icient_slot] ;
90


mass_rej ected_of__each_f ramel=mass_re j ected_of_delay_per_frame+number
_of_rejected_masseg_insufficient_slot;
REJECTED_MASSEGE_ALL_FRAMES=[REJECTED_MASSEGE_ALL_FRAMES
mass_rejected_of_each_framel];
Counterl=[Counterl; Counter];
u=l;
SOFT_DECISION(i)=u;
end
for i=l:I
for j =1:J
if A1(i,j)>0
A1(i,j)=1;
end
end
end
o o. o. o. 0. 0, o, o. o o. o. c. O- >. o, d o, o o, o, o o. a. c, o. o, o. o.. o. o.
o "e "g "o & c "o "h b 'o '6 b "o "e "o "g o c b o o 'c 'b o bob c o b c.
all_delay_together=sum(Delay_Matrix(:));
DELAY=all_delay_together/length(nonzeros(Delay_Matrix(:)))
[II Jl]=size(Counterl);
[12 J2]=size(Counter2);
Wasted_capacity_rate=(sum(Counterl(:) = = 0) /(I1*Jl)+
sum(Counter2(:)==0)/(I2*J2)-wated_factor)
rej ection_rate=sum(nonzeros(REJECTED_MASSEGE_ALL_FRAMES))/(length(y)
)
91


APPENDIX F. MATLAB PROGRAM FOR 4 NODES DTMA SECOND
TRANSMISSION POLICY
This program is no different from the previous program except few steps which:
At the beginning we will use the following code
%script file: 4 nodes DTMA
Ipurpose:
% Thesis program for simulate the Distributed Traffic Monitoring
^Algorithm of the Second transmission policy
%Date Programmer Description of change
%01/13/2Oil Khaled Zaid Original code
clear ,close clc
load SOFTJDECISICHl
SOFT_DECISIONl=SOFT_DECISION;
wl=wl
load SOFT..DECISI0N2
w2=w2
SOFT_DECISION2=SOFT_DECISION;
load SOFT..DECISIONS
S0FT_DECISI0N3=S0FT_DECISI0N;
w3=w3
load S0FT_DEC1SICN4
SOFT_DECISION4=SOFT_DECISION;
w4=w4
[B1 Zl]=size(SOFT_DECISIONl);
[B2 Z2]=size(SOFT_DECISION2);
[B3 Z3]=size(SOFT_DECISION3);
[B4 Z4]=size(SOFT_DECISION4);
zz= [Zl Z2 Z3 Z4] ;
final_frame_allowable=min(zz(:));
SOFT_DECISIONl=SOFT_DECISIONl(1:final_frame_allowable);
SOFT_DECISION2=SOFT_DECISION2(1:final_frame_allowable);
SOFT_DECISION3 = SOFT_DECISI0N3(1:final_frame_allowable) ;
SOFT_DECISION4=SOFT_DECISION4(1:final_frame_allowable);
clear y, clear cross _for_botly TO, clear REJECTFD__MASSEGE__ALIj__FK.-.MES
We chose the two thresholds equal to the values 110 for the change of the lower rate
and 124.2121 for the monitoring of the higher rate, therefore the updating step of the
test will be:
92


TX(1)= 0;TX1 = 0;TX2 = 0 ;
U=0;
ul = 0 ;
for i=l:I
if TX1< 110.0000
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i
)*w2+w3*SOFT_DECISION4(i)*SOFT_DECISION4(i);
TX(i + 1)=max(0,TX(i)+(sum_of_weigh_and_soft_decieion*sl/log(lambdal/1
ambdaO)+sl*numbr_of_arrivals_in_each_fram(i)-40*t_l));
TX1=TX(i+1);
Til(i)=TX(i+1);
if TX1>=110.0000
U=U+1;
T_0(u)=TX1;
bbb(u)=i;
cucu=nonzeros(A(i,:))
time_end_of_the_frame_0 (u) =cucu(end)
frame_end_cross_threhold_0(u)=i*40;
TX(i+1)=0;
end
elseif TX1>=110.0000 && TX2<124.2121
sum_of_weigh_and_soft_decieion=SOFT_DECISIONl(i)*wl+SOFT_DECISION2(i
)*w2+w3*SOFT_DECISION4(i)*SOFT_DECISION4(i);
TX(i+1)=max(0,TX(i)-
(sum_of_weigh_and_soft_decieion*sl/log(lambdal/lambdaO)+sl*numbr_of_
arrivals_in_each_fram(i)-40*t_l));
TX2=TX(i+1);
T22(i)=TX(i+1);
if TX2>=124.2121
Ul=Ul+l;
T_1(ul)=TX2;
bbbl(u)=i;
cucul=nonzeros(A(i,:));
frame_end_cross_threhold_l(ul)=i*40;
if isempty(cucul)
time_end_of_the_frame_l(ul)=i*40;
else
cucul=nonzeros(A(i,:));
time_end_of_the_frame_l(ul)=cucul(end);
end
TX(i+1)=0;
TX1=0;TX2=0;
end
end
end
93