Top Banner
Department of CSSE, Auburn University 1 COMP6340: Network Quality Assurance and Simulation Ns2-PROJECT Phase II – Simulation of ALOHA http://www.auburn.edu/~jinjinr/comp6340/ Authors Ben Brahim Taha Jingren Jin Arunkumar T J
32
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Aloha

Department of CSSE, Auburn University

1

COMP6340: Network Quality Assurance and Simulation

Ns2-PROJECT

Phase II – Simulation of ALOHA http://www.auburn.edu/~jinjinr/comp6340/

Authors

Ben Brahim Taha

Jingren Jin

Arunkumar T J

Page 2: Aloha

Department of CSSE, Auburn University

2

Contents 1 INTRODUCTION.............................................................................................................................3

2 THEORETICAL ANALYSIS ..........................................................................................................4

2.1 THE ALOHA PROTOCOL ...............................................................................................................4 2.1.1 The Basic Concept..............................................................................................................4 2.1.2 Theoretical Analysis of Pure Aloha ...................................................................................4 2.1.3 Theoretical Analysis of Slotted ALOHA ............................................................................5

2.2 CARRIER SENSE MULTIPLE ACCESS WITH COLLISION DETECTION.............................................6 2.2.1 Theoretical Analysis of CSMA/CD ....................................................................................6

3 SIMULATION AND ANALYSIS ....................................................................................................8

3.1 PROBLEM STATEMENT .................................................................................................................8 3.2 SIMULATION AND ANALYSIS OF PURE ALOHA.............................................................................8

3.2.1 Verification of maximum Link Efficiency of ALOHA.........................................................8 3.2.2 Experiments with the simulator .........................................................................................9 3.2.3 Variation of Parameters during simulation .....................................................................10 3.2.4 Effect of Bandwidth on Link Efficiency............................................................................11 3.2.5 Effect of Frame size on Link Efficiency ...........................................................................12 3.2.6 Effect of Number of stations on Link Efficiency ..............................................................12

3.3 SIMULATION AND ANALYSIS OF SLOTTED ALOHA.....................................................................13 3.3.1 Verification of maximum Link Efficiency of ALOHA.......................................................13 3.3.2 Experiments with the simulator .......................................................................................14 3.3.3 Variation of Parameters during simulation .....................................................................15

Statistical observations ..................................................................................................................................16 Correlation of collision fraction with the idle time fraction .........................................................................16

3.3.4 Effect of Bandwidth on Link Efficiency............................................................................17 3.3.5 Effect of Frame size on Link Efficiency ...........................................................................18 3.3.6 Effect of Number of stations on Link Efficiency ..............................................................19 3.3.7 Experiment with different back off distributions .............................................................19

3.3.7.1 Uniform back off distribution.....................................................................................................19 3.4 SIMULATION AND ANALYSIS OF CSMA/CD..............................................................................21

3.4.1 Verification of maximum Link Efficiency of ALOHA.......................................................22 3.4.2 Effect of Bandwidth on efficiency of CSMA/CD..............................................................24 3.4.3 Effect of Number of stations on efficiency of CSMA/CD.................................................25

4 CONCLUSION................................................................................................................................27

4.1 THE SIMULATION TOOL .............................................................................................................28 4.1.1 Characterization of the model .........................................................................................28 4.1.2 The simulation language..................................................................................................29 4.1.3 The simulator design ........................................................................................................29

4.1.3.1 Classes.........................................................................................................................................29 4.1.4 Source Code......................................................................................................................32

Page 3: Aloha

Department of CSSE, Auburn University

3

Abstract The primary goal of any MAC protocol is to maximize utilization of the shared physical medium. In this project, we use simulation as an analysis tool to study the efficiencies of three different random access protocols namely, ALOHA, Slotted ALOHA and CSMA/CD with different network parameters. It has been proven theoretically that the performance of the two variants of Aloha, Pure Aloha and Slotted Aloha can not exceed 18.4% and 36.8% respectively. CSMA/CD can be close to 100% efficient under certain conditions. The observations from our simulation validate the theoretical results to a large extent.

1 Introduction The medium access control (MAC) is a sub layer of the OSI link layer. It has to organize and handle how different stations may access a shared medium (the wire). It is well known that the problems related to resource-sharing mostly involve strong formal models. Indeed, the issues related to resource-sharing are fairness, good-put improvement, scalability and algorithms complexity. In this report, we are presenting, simulating and analyzing a set of well known MAC protocols. The protocols we are studying are Pure Aloha and Slotted Aloha and CSMA/CD. Aloha is one of the first protocols to have been proposed as a solution to Multiple Access Control. The word Aloha stands for Hello in native Hawaiian language. The Aloha family protocols were proposed by a research team led by Abramson at Hawaii University. We will give a detailed description of Aloha algorithms in the next section. It has been proven that the highest attainable link efficiency is 18.4% for Pure Aloha and 36.8% for Slotted Aloha. CSMA/CD is a protocol that works contrary to ALOHA. A practical version of CSMA/CD is the 802.3 protocol that has been used as MAC for Ethernet. Theoretically efficiency of CSMA/CD can be close to 100%. Through this work we have designed a simulation tool that validates the theoretical results. We also discuss some extreme cases where the efficiency of Aloha goes beyond the theoretical maximum and some other cases where it is extremely low. This report is organized in the following fashion. Chapter 2 is a description of the different MAC algorithms. It also presents the theoretical analysis of each protocol’s efficiency including the statistical approaches used. In the 3rd Chapter we depict our simulation model for Aloha and explain the statistical approaches that we have adopted in the realization of our simulation tool. In the fourth and last part of this work we present the results of our simulations. We give an analysis and our interpretation of the results and conclude.

Page 4: Aloha

Department of CSSE, Auburn University

4

2 Theoretical Analysis This section discusses in detail the theoretical analysis for the performance of different MAC protocol that we analyze as part of the project. The results of the analysis form the basis of our simulation and acts as a verification model. Although it is a known fact from previous experiences that results of simulation could be different from theory, theoretical results provide a general idea about interpretation of the simulation results.

2.1 The Aloha Protocol

Aloha was proposed by Abramson in the late 1960’s to enable exchange of messages between remote terminals and the central computer at the University of Hawaii. The idea was to use low-cost ham radio-like systems to create a computer network linking the far-flung campuses of the University.

2.1.1 The Basic Concept

The basic concept of ALOHA is very simple. When a node has a packet to transmit, it transmits the packet right away. A simple strategy like this may lead to scenarios where multiple nodes try to send at the same time, which might cause several collisions. As a result, several packets get corrupted. If the presence of a collision is detected by the sender, it retransmits after some random wait time.

2.1.2 Theoretical Analysis of Pure Aloha

Assume all packets have the same fixed size Sp (Bytes), and let the bandwidth of the medium be Bw (Bytes/sec).

Let T be the frame transmission time, it is given by the following equation: T = Sp/Bw. The nodes population generates a traffic that is Poisson process with mean N frames per T. Since there are also retransmissions, the total traffic generated is a Poisson process with a mean of G frames per T.

Consider a new or retransmitted frame scheduled for transmission at some instant t. This frame can be successfully transmitted if there are no other frames scheduled for transmission between the instants t – T and t + T (this period of duration 2T is called the vulnerable period). Therefore, the probability Ps of successful transmission is the probability that no frame is transmitted in the interval of length 2T. We have:

Ps = P (no collision)

= P (no transmission in two packets time 2T)

= e-2G (2-2-1)

Since packets are transmitted at a rate of G packets per second with only a fraction Ps successful, the rate of successful transmission is GPs .If we define the throughput as the fraction of time during which the useful information is carried on the channel, we

Page 5: Aloha

Department of CSSE, Auburn University

5

get the throughput of pure ALOHA as

Gth GeS 2−= (2-2-2)

This equation gives the channel throughput as a fraction of the offered load. Using equation (2-2-2), we can find the maximum throughput Sth max by differentiating equation (2-2-2) with respect to G and equating to zero as.

02 22 =+−= −− GGth eGedGdS (2-2-3)

The equation (2-2-3) indicates that the maximum throughput Sth max occurs at the offered load of G = ½. Therefore, substituting G = ½ in equation (2-2-2), we have

184.021

max ≈=e

Sth (2-2-4)

From equation (2-2-4) we can conclude that the maximum throughput Sth max is about 18.4%.

2.1.3 Theoretical Analysis of Slotted ALOHA Slotted Aloha is an improvement of Pure Aloha. In Slotted ALOHA, the stations only transmit at the start of a slotted time which is equal to the transmission time T. A new or retransmitted frame can be successfully transmitted if there are no other frames scheduled for transmission in T. Therefore, the probability Ps of successful transmission is the probability that no frame is transmitted in the transmission time T. We have:

Ps = P (no collision)

= P (no transmission in one packets time T)

= Ge− (2-3-1)

Since packets are transmitted at a rate of G packets per second, the rate of successful transmission is G Ps .If we define the throughput as the fraction of time where the useful information is carried on the channel, we get the throughput of slotted ALOHA as

Gth GeS −= (2-3-2)

This equation gives the channel throughput as a fraction of the offered load. Using equation (2-3-2), we can find the maximum throughput Sth max by differentiating equation (2-3-2) with respect to G and equating to zero as.

0=+−= −GGth eGedGdS

(2-3-3)

Page 6: Aloha

Department of CSSE, Auburn University

6

The equation (2-3-3) indicates that the maximum throughput Sth max occurs at the offered load of G = 1. Therefore, substituting G = 1 in equation (2-3-2), we have

368.01max ≈=

eSth

(2-3-4)

From equation (2-3-4) we can conclude that the maximum throughput Sth max in Slotted Aloha is about 36.8%.

2.2 Carrier Sense Multiple Access with Collision Detection One of the main drawbacks of ALOHA protocols is that each competing station assumes the medium to be available for transmission irrespective of other participating stations. This may work efficiently when the number of participating stations is low, but does not scale efficiently for large number of participant stations. To avoid this, CSMA/CD forces stations to “listen” to the channel before sending (Carrier Sensing) in order to make sure that no other station on the wire is sending in the meanwhile. When the medium is not busy, the station that wants to send data can do so. The sender will then continue to listen, to make sure that sending the data didn’t cause a collision (Collision Detection). If a collision is heard, all of the colliding stations will stop sending immediately and execute a back-off algorithm to select a later point in time for retransmission.

2.2.1 Theoretical Analysis of CSMA/CD Assume that the access medium is partitioned into timeslots and that a packet takes k timeslots to be transmitted. Remember that the efficiency is the ratio of successfully used timeslots, that is, the efficiency is

xkkSth +

= (2-4-1)

where x is the expected number of unsuccessful timeslots (collision or empty). Let Y be a random variable denoting the number of slots until a success: P(Y = m) = β(1−β)m−1, where β is the probability of success for a single timeslot. If every of the N nodes transmits in a given timeslot with probability p: β = Np(1 − p)N−1. Y has a geometric distribution with mean

β1)( =YE (2-4-2)

Let X be a random variable denoting the number of consecutive wasted slots: X = Y − 1, and x its mean value:

1

1

)1()1(111)()( −

−−−

=−

=−== N

N

pNppNpYEXEx

ββ (2-4-3)

Substituting equation (2-4-3) in equation (2-4-1), we get

Page 7: Aloha

Department of CSSE, Auburn University

7

1

1

)1()1(1−

−−−

+=

+=

N

Nth

pNppNpk

kxk

kS (2-4-4)

Maximising the efficiency is equivalent to minimising x, which is equivalent to maximizing β. By differentiating β = Np(1 − p)N−1 with respect to p and equating to zero as

01

)1()1()1(1

1 =−

−−−−=

−−

pNpNppN

dpd N

Nβ (2-4-5)

The equation (2-4-5) indicates that the maximum β occurs at the p=1/N. By knowing

that 1)1

11( −

−− N

N approaches 1/e for N→∞ we can calculate the maximum

efficiency as

1−+=

ekkSth

Efficiency Sth approaches 1 when k→∞.

Page 8: Aloha

Department of CSSE, Auburn University

8

3 Simulation and Analysis

3.1 Problem Statement The goal of this project is to design and implement a simulation tool and use it to evaluate the performance of the random access protocols under different conditions, we also evaluate CSMA/CD using the Ns-2 simulator. This section describes in detail the experiments performed using the simulator tool and analyzes the results thus obtained. The main advantage of simulation is that it allows us to systematically experiment with a wide variety of workloads and statistical parameters. But the results obtained as part of the simulation must not be considered as a basis of the real situation. Following quote from S. Keshav (one of the pioneers in developing NS) summarizes the use of Simulation as an analysis tool. “…However for computer systems, where a single line of code can completely change the behavior of the system, one has to confront the fact that no simulation is ever going to be accurate… But, one has to realize that it is a coarse tool, and necessarily so. As long as you go in with your eyes open, simulations is a reasonable first step (but only the first step).”

The design and implementation details of our simulation tool itself will be presented in Appendix A.

3.2 Simulation and Analysis of Pure Aloha

3.2.1 Verification of maximum Link Efficiency of ALOHA

As stated in the Chapter 2, the theoretical analysis of Pure Aloha is based on the assumption that the frame arrival rate (the new generated frames and the retransmitted frames) is following a Poisson process with a mean of Lambda. Therefore, in order to verify the theoretical results, we use the same probability distribution.

The parameter Lambda of the Poisson process used will have to be determined as the value where the efficiency of the Pure Aloha reaches its maximum.

Parameters and Metrics

To perform experiments with the simulation tool, we consider a network comprising of N stations. The network is connected by shared medium with a bandwidth of Bw. Each station in the network will send data (Frames) at a certain rate. In order to simplify our analysis, we consider that all the stations are sending frames of fixed size Sp. Also we ensure that the total traffic generated by all the nodes in the network does not exceed the actual bandwidth of the network. This achieved by dividing the mean frame arrival rate equally among all the nodes of the network.

Following are the experimental values for the system parameters:

Number of stations N = 10

Size of each frame Sp = 10,000 Bytes

Page 9: Aloha

Department of CSSE, Auburn University

9

Bandwidth of the shared medium Bw = 56,000 bps

With these simulation parameters the experiment is performed for 100 values of Lambda. Figure 1 shows a graphical plot of efficiency of Pure Aloha in function of Lambda.

Link Efficiency

0

5

10

15

20

25

0.0

1

0.2

0.3

9

0.5

8

0.7

7

0.9

6

1.1

5

1.3

4

1.5

3

1.7

2

1.9

1

2.1

2.2

9

2.4

8

2.6

7

2.8

6

3.0

5

3.2

4

3.4

3

3.6

2

3.8

1

Arrival Rate(Lambda)

Lin

k Eff

icie

ncy

(%)

Link Efficiency

Figure 1: Finding the value of Lambda that gives a Maximum Efficiency

We see that the efficiency reaches its maximum when the value of Lambda is 0.5. We will use this value to generate the cumulative traffic in the network by all the stations for the rest of our simulation experiments.

Note that the arrival rate of 0.5 is cumulative of all the nodes in the network.

3.2.2 Experiments with the simulator

The experiments in section demonstrate the impact of each of these parameters on system performance. In order to evaluate the performance of our system, we will have to consider the following metrics:

• The Link Efficiency of Pure Aloha, which is computed as the amount of time spent on successful frame transmissions, as percentage of the overall simulation time.

• The collision fraction of time, which is the amount of time wasted on transmissions that caused collisions, as percentage of the overall simulation

Page 10: Aloha

Department of CSSE, Auburn University

10

time.

• The idle fraction of time, which is computed as the amount of time for which the medium was not utilized, as percentage of the overall simulation time.

Thus experiments are parameterized by N, Sp and Bw. Each experiment is performed by keeping the two of the parameters constant and studying the effect of the other parameter on Link Efficiency, Percentage Collision Time and Percentage Idle Time.

3.2.3 Variation of Parameters during simulation

The goal of this experiment is to observe the system metrics i.e. collision fraction, Idle fraction and efficiency during the course of simulation. Following values are chosen for the system parameters for the experiment.

• N = 10 Nodes • Sp = 10000 Bytes

• Bw = 56,000 bps

• Lambda = 0.5

The Figure 2 presents the link utilization efficiency over time. We conclude from the graph that the efficiency is in the range of 18.5% over the time. We also plot the collision fraction over the time and the idle fraction of time.

Metrics over Time

0

10

20

30

40

50

60

70

80

0.3

88

1096

2118

3260

4365

5521

6655

7876

9011

10123

11275

12396

13541

14653

15807

16945

18109

19249

20331

21384

Time in seconds

Perc

enta

ge

Link efficiency Collision Idle

Page 11: Aloha

Department of CSSE, Auburn University

11

Figure 2: The efficiency, collision fraction and idle fraction over time

3.2.4 Effect of Bandwidth on Link Efficiency

In order to understand what should be the effect of varying the bandwidth on the efficiency, we have set the parameters (N,Sp,Bw,Lambda) as follows:

N = 10 Nodes

Sp = 10000 Bytes

Lambda = 0.5

The Figure 3 represents the efficiency over the bandwidth.

Effect of Bnadwidth on Efficiency

0

20

40

60

80

100

120

1250

8125

15000

21875

28750

35625

42500

49375

56250

63125

70000

76875

83750

90625

97500

1E+05

1E+05

1E+05

1E+05

Bandwidth in bps

Perc

enta

ge (

%)

Link Efficiency Collision Duration IdleDuration

Figure 3: The effect of varying the bandwidth on the efficiency

From the Figure 3, we distinguish two sides of the plot: the first is when the efficiency is exponentially increasing until reaching the maximum efficiency which is around 18.8%. This scenario is because of the low bandwidth and the fixed arrival rate, which makes collisions to happen more often. While in the second side, as the bandwidth growth the efficiency decreases linearly. This means that the network has more idle time where no frame is sent. Figure 3 also illustrates the effect of varying the bandwidth on the collision fraction of time, and on the idle fraction of time. Indeed, when the bandwidth is very low the link experiences a high collision rate and a low idle time rate also.

Page 12: Aloha

Department of CSSE, Auburn University

12

3.2.5 Effect of Frame size on Link Efficiency

The frame size and the bandwidth have the inverse impact on the time needed to transmit a frame. Therefore, we expect that the impact of the frame size on the efficiency might be similar to the effect of the bandwidth. Indeed, Figure 4 illustrates the efficiency over the frame size.

3.3.3 Effect of Frame size on Link Efficiency

0

20

40

60

80

100

120

500

2000

3500

5000

6500

8000

9500

11000

12500

14000

15500

17000

18500

20000

21500

23000

24500

26000

27500

29000

FrameSize in bytes

Perc

enta

ge (

%)

Link Efficiency Collision Duration IdleDuration

Figure 4: The effect of varying the frame size on the efficiency

In Figure 4 we plot the effect of the frame size variation on the collision fraction of time and on the idle fraction of time.

3.2.6 Effect of Number of stations on Link Efficiency

The number of nodes in the system has a considerable impact on the metrics of Pure Aloha.

Page 13: Aloha

Department of CSSE, Auburn University

13

Effect of Number of stations on Link Efficiency

0

10

20

30

40

50

60

70

80

90

100

2 5 8 11 14 17 20 23 26 29 32 35 38

Number of stations

Perc

enta

ge (

%

Link Efficiency Collision Duration IdleDuration

Figure 5: The effect of varying the number of nodes on the efficiency

In Figure 5 we show the effect of varying the number of users on the collision fraction and the idle time fraction over the time. As far as we have simulated the behavior of Pure Aloha protocol under various situations, we have noticed that its efficiency is all the time very low around the theoretical value of 18.46%.

3.3 Simulation and Analysis of Slotted Aloha

3.3.1 Verification of maximum Link Efficiency of ALOHA

As stated in the Chapter 2, the theoretical analysis of Slotted Aloha is based on the assumption that the frame arrival rate (the new generated frames and the retransmitted frames) follows a Poisson process with a mean of Lambda. Therefore, in order to verify the theoretical results, we use the same probability distribution.

The parameter Lambda of the Poisson process used will have to be determined as the value where the efficiency of the Slotted Aloha reaches its maximum.

Parameters and Metrics

To perform experiments with the simulation tool, we consider a network comprising of N stations. The network is connected by shared medium with a bandwidth of Bw. Each station in the network will send data (Frames) at a certain rate. In order to simplify our analysis, we consider that all the stations are sending frames of fixed size

Page 14: Aloha

Department of CSSE, Auburn University

14

Sp. Also we ensure that the total traffic generated by all the nodes in the network does not exceed the actual bandwidth of the network. This achieved by dividing the mean frame arrival rate equally among all the nodes of the network.

Following are the chosen values for the system parameters:

Number of stations N = 10

Size of each frame Sp = 7 Kilo Bytes

Bandwidth of the shared medium Bw = 56 kbps

With these simulation parameters the experiment is performed multiple times increasing the value of lambda each time starting from a small value. Figure 1 shows a graphical plot of efficiency of Slotted Aloha in function of Lambda.

Effect of Network Load on Link Efficiency for Slotted Aloha

0

5

10

15

20

25

30

35

40

45

0.0

1

0.2

1

0.4

1

0.6

1

0.8

1

1.0

1

1.2

1

1.4

1

1.6

1

1.8

1

2.0

1

2.2

1

2.4

1

2.6

1

2.8

1

3.0

1

3.2

1

3.4

1

3.6

1

3.8

1

4.0

1

4.2

1

4.4

1

4.6

1

4.8

1

5.0

1

5.2

1

5.4

1

5.6

1

5.8

1

6.0

1

6.2

1

6.4

1

6.6

1

6.8

1

Network Load (Lambda)

Perc

enta

ge

Link Efficiency(%)

Figure 6: Finding the value of Lambda that gives a Maximum Efficiency

We see that the efficiency reaches its maximum when the value of Lambda is around 1.1. We will use this value to generate the cumulative traffic in the network by all the stations for the rest of our simulation experiments. Note that the arrival rate of 1.1 is cumulative of all the nodes in the network.

3.3.2 Experiments with the simulator

The experiments in section demonstrate the impact of each of these parameters on system performance. In order to evaluate the performance of our system, we will have to consider the following metrics:

• The Link Efficiency of Slotted Aloha, which is computed as the amount of

Page 15: Aloha

Department of CSSE, Auburn University

15

time spent on successful frame transmissions, as percentage of the overall simulation time.

• The collision fraction of time, which is the amount of time wasted on transmissions that caused collisions, as percentage of the overall simulation time.

• The idle fraction of time, which is computed as the amount of time for which the medium was not utilized, as percentage of the overall simulation time.

Thus experiments are parameterized by N, Sp and Bw. Each experiment is performed by keeping the two of the parameters constant and studying the effect of the other parameter on Link Efficiency, Percentage Collision duration and Percentage Idle duration.

3.3.3 Variation of Parameters during simulation

The goal of this experiment is to observe the system metrics i.e. collision fraction, Idle fraction and efficiency during the course of simulation. Following values are chosen for the system parameters for the experiment.

• N = 10 Nodes • Sp = 7 Kilo Bytes

• Bw = 56 kbps

• Lambda = 1.1

The Figure 2 presents the link utilization efficiency over time. We conclude from the graph that the efficiency is in the range of 37% over the time. We also plot the collision fraction over the time and the idle fraction of time.

Page 16: Aloha

Department of CSSE, Auburn University

16

Variation of Link Efficiency over time

0

10

20

30

40

50

60

1

642

1296

1875

2483

3132

3822

4465

5081

5730

6346

7016

7669

8313

8939

9571

10187

10819

11511

12124

12790

13461

14114

14741

15361

15967

16600

17268

17901

18523

19122

19776

20436

21083

21722

22386

23059

Time ( in seconds)

Perc

enta

ge (

%)

Link Efficiency Collision Duration Idle Duration

Figure 7: Variation of Link efficiency, collision fraction and idle fraction over time

Statistical observations

In this section, we statistically analyze the system metrics. We believe there is some information one may infer from observing the behavior of some metrics (i.e. efficiency, collision and idle fractions over time). We consider every metric as a random variable that takes values depending on the MAC protocol used. Our aim is to find the statistical relations that govern those metrics.

Correlation of collision fraction with the idle time fraction

From all the Figures of section 3, we notice that the shape of the collision fraction is varying in accordance with the shape of the idle time fraction. In order to determine how those two metrics are correlated, we compute the correlation coefficient of the two metrics. Let X be the random variable representing the collision fraction and Y be the idle time fraction. Using our simulator, we generate a population sample of X and Y. In order to study the variations of X in respect of the variations of Y, we compute first the covariance between X and Y. and then we compute the coefficient of correlation using the following equation:

yx

xyYXnCorrelatioσσ

σ 2

),( =

Variables X and Y are highly correlated since from the samples we have:

Page 17: Aloha

Department of CSSE, Auburn University

17

1985.0),( ≈=YXnCorrelatio With a correlation of almost 1, the collision fraction and the idle time fraction are considered highly correlated in other terms, when the collision fraction is varying the idle time fraction is varying also in accordance. From that result we may understand why the efficiency never changes hazardously. Indeed, the efficiency remains in a constant state.

3.3.4 Effect of Bandwidth on Link Efficiency

In order to understand what should be the effect of varying the bandwidth on the efficiency, we have set the parameters (N, Sp, Bw, Lambda) as follows:

N = 10 Nodes

Sp = 7 Kilo Bytes

Lambda = 1.1

The Figure 3 represents the efficiency over the bandwidth.

Effect of Bandwidth on performance of Slotted Aloha

0

20

40

60

80

100

120

640

4480

8320

12160

16000

19840

23680

27520

31360

35200

39040

42880

46720

50560

54400

58240

62080

65920

69760

73600

77440

81280

85120

88960

92800

96640

1E+05

1E+05

1E+05

1E+05

1E+05

1E+05

1E+05

1E+05

Bandwidth (in bps)

Perc

enta

ge

Link efficiency Collision Duration Idle Duration Figure 8: The effect of varying the bandwidth on the efficiency

From the Figure 8, we distinguish two sides of the plot: the first is when the efficiency is exponentially increasing until it reaches the maximum efficiency which is around 37%. It may seem that in Slotted Aloha the bandwidth has no effect on the link efficiency since the nodes transmit only at the beginning of each slot. However it has to be noted that whenever a packet arrives at the node for transmission, the node

Page 18: Aloha

Department of CSSE, Auburn University

18

blocks the transmission until the next time slot. This implies that if the slot is large then there is a chance that a larger number of stations are likely to transmit at the beginning of the next slot. This increases the chances of collision at the next slot. This is exactly what happens when the bandwidth is low. In such cases the transmission time is high. This increases the number of collisions occurring in the network

While in the second side, as the bandwidth growth the efficiency decreases linearly. This means that the network has more idle time where no frame is sent. Figure 3 also illustrates the effect of varying the bandwidth on the collision fraction of time, and on the idle fraction of time. Indeed, when the bandwidth is very low the link experiences a high collision rate and a low idle time rate also.

3.3.5 Effect of Frame size on Link Efficiency

The frame size and the bandwidth have inverse impact on the time needed to transmit a frame. It may seem that in Slotted Aloha the transmission time has no effect on the link efficiency since the nodes transmit only at the beginning of each slot. However it has to be noted that whenever a packet arrives at the node for transmission, the node blocks the transmission until the next time slot. This implies that if the slot is large then there is a chance that a larger number of stations are likely to transmit at the beginning of the next slot. This increases the chances of collision at the next slot.

Therefore, we expect that the impact of the frame size on the efficiency might be similar to the effect of the bandwidth. We plotted the effect of the frame size variation on the collision fraction of time and on the idle fraction of time as shown in Figure below. Indeed, the figure illustrates the dependency of efficiency over the frame size.

Effect of FrameSize on performance of Slotted Aloha

0

10

20

30

40

50

60

70

80

90

100

51215

3625

6035

8446

0856

3266

5676

8087

0497

28

1075

2

1177

6

1280

0

1382

4

1484

8

1587

2

1689

6

1792

0

1894

4

1996

8

2099

2

2201

6

2304

0

2406

4

2508

8

2611

2

2713

6

2816

0

2918

4

3020

8

FrameSize (in bits)

Perc

enta

ge

Link Effificency Collision Duration Idle Duration

Figure 9: The effect of varying the frame size on the efficiency

Page 19: Aloha

Department of CSSE, Auburn University

19

3.3.6 Effect of Number of stations on Link Efficiency

The number of nodes in the system has a considerable impact on the metrics of Slotted Aloha. Indeed, In Figure 5 we show that the link efficiency

Effect of number of stations on performance of Slotted Aloha

0

20

40

60

80

100

120

2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40

Number of stations

Perc

enta

ge

Link Efficiency Collision duration Idle Duration

Figure 10: The effect of varying the number of nodes on the efficiency

In Figure 5 we show the effect of varying the number of users on the collision fraction and the idle time fraction. As far as we have simulated the behavior of Slotted Aloha protocol under various situations, we have noticed that its efficiency is all the time very low around the theoretical value of 36.8%.

3.3.7 Experiment with different back off distributions

In all the experiments until now we assumed that the inter arrival time of packets to be sent over the network is exponentially distributed. We have also assumed that on occurrence of a collision the nodes involved in collision back off (wait) for a random amount of tie which is exponentially distributed. In the sections below we experiment with different distributions for the back off period.

3.3.7.1 Uniform back off distribution

In order to study the effect of the uniform back off algorithm on metrics of the system we fix the following parameters.

• N = 10 Nodes • Sp = 7 Kilo Bytes

Page 20: Aloha

Department of CSSE, Auburn University

20

• Bw = 56 kbps

• Lambda = 1.1

The aim of the experiment is to study the maximum possible value of Link Efficiency that can be obtained with Uniform back off distribution. It is also of interest to find out the values of the parameters of distribution for which the maximum value of Link Efficiency is obtained.

The back off time is a random variable (say X) distributed uniformly between two fixed values a and b which are the parameters of uniform distribution. Such a random number X has an expected value E(X) given by (a+b)/2.

By repeating the simulation experiment over a large duration it becomes more relevant to correlate the results obtained to a given value of E(X) than to the parameters a and b themselves. This is because for a given value of E(X) there could be many values of a and b for which a given value of E(X) can occur. In other words the value of E(X) is unique while the corresponding values of a and b are not.

Based on the above argument we perform the simulation experiment starting from a small value of average and repeatedly increasing it for subsequent trials. We then identify the value of the average for which the maximum value of Link Efficiency is obtained. Following graphs depict the results of our experiment.

Figure 11: Variation of Link Efficiency with Average uniform back-off time

From the above figure it can be seen that the maximum possible Link Efficiency that can be obtained using uniform back off algorithm is around 37% and the maximum

Page 21: Aloha

Department of CSSE, Auburn University

21

value is attained for the value 9 of the Average. Assuming the least possible value for the parameter a=0, the value of parameter b would be 2*9 = 18 i.e. the maximum efficiency is obtained for a=0 and b=18. In other words the Link efficiency is maximum when the number of slots chosen randomly is distributed uniformly over 18 time slots.

Following figure shows the variation of Efficiency, Collision duration and Link Efficiency during the course of simulation.

Figure 12: Variation of Link efficiency over time

3.4 Simulation and Analysis of CSMA/CD

In this section we present the simulation results for CSMA/CD

The Simulators

. The simulation has been done using both Ns2 and out own simulator. Although the parameters used for simulations with both the simulators are the essentially the same, we see that there are differences in the results thus obtained. The difference in results are mainly due to inherent differences in the underlying implementations of the simulators themselves. It important that however different they are, the results do not contradict each other.

The Back off Strategies

When ever collisions happen in CSMA/CD the colliding stations back-off before retransmitting at a later point in time. The default back-off strategy in Ethernet I the

Page 22: Aloha

Department of CSSE, Auburn University

22

“Binary Exponential” back off. The goal is to adapt retransmission attempts to the estimated current load. Since it is impossible to find out the number of participating stations in the collision, the current number of collisions N, that the station experienced is used as an indicator for N. When collision occurs first time a station choose a value K from {0,1}. Then it waits for a time K*{2*Tprop} before retransmitting the frame. After second collision: choose K from {0,1,2,3} and so on. After ten collisions, choose K from {0,1,2,3,4,…,1023}. Beyond this the station gives up contending for the medium. This is usually an indication that the network is overloaded.

The Optimal Back-off strategy

It is to be noted that the back-off strategy discussed earlier is not necessarily fair. Stations. A new node has initial m=0, but the other 100 nodes are in exponential back-off (i =5,6,7). In this case the new node usually grabs the channel first and nodes that have already collided end up giving up after 10 trials.

In order to over come this, we simulate an “Optimal” back off strategy which is fair to all the stations that are in collision currently with taking history into account. However it is with the assumption that each station somehow is able to determine the number of stations involved in collision. Considering that there are N such stations, we allow the each station to choose a random number X uniformly distributed between 0 and N. Then the station waits for a time X*(2*Tprop) before retransmitting.

The graphs below show that the efficiencies obtained for optimal back off strategy is definitely more than that for Binary-exponential back-off.

3.4.1 Verification of maximum Link Efficiency of ALOHA

Parameters and Metrics

To perform experiments with the simulation tool, we consider a network comprising of N stations. The network is connected by shared medium with a bandwidth of Bw. Each station in the network will send data (Frames) at a certain rate. In order to simplify our analysis, we consider that all the stations are sending frames of fixed size Sp. Also we ensure that the total traffic generated by all the nodes in the network does not exceed the actual bandwidth of the network. This achieved by dividing the mean frame arrival rate equally among all the nodes of the network.

Following are the experimental values for the system parameters: • Number of stations N = 10 • Size of each frame Sp = 1,000 bits • Bandwidth of the shared medium Bw = 10Mbps

Page 23: Aloha

Department of CSSE, Auburn University

23

• Propagation time τ = 5µs. This is based on the given data that cable length to be used is 1 Km. Assuming speed of transmission as 2/3rds the speed of light we get τ = 5µs.

The figure below shows a graphical plot of efficiency of CSMA/CD in function of Rate as obtained using our simulator. The dotted line represents the efficiency for Optimal CSMA/CD. We can observe that efficiency is about 94% for optimal and 91% for non-optimal..

Effect of Offered load on efficiency

50

55

60

65

70

75

80

85

90

95

100

0.1 0.4 0.7 1 1.3 1.6 1.9 2.2 2.5 2.8 3.1 3.4 3.7 4 4.3 4.6 4.9 5.2 5.5 5.8 6.1 6.4 6.7 7 7.3 7.6 7.9 8.2 8.5 8.8

Offered Load

Perc

enta

ge E

ffici

ency

Optimal Backoff Binary Backoff

Figure 13: Variation of Efficiency of CSMS/CD with Offered Load

The figure below depicts the results obtained using Ns2.

Page 24: Aloha

Department of CSSE, Auburn University

24

Variation of Efficiency With Offered Load

0

10

20

30

40

50

60

70

80

90

100

0.01

0.27

0.53

0.79

1.05

1.31

1.57

1.83

2.09

2.35

2.61

2.87

3.13

3.39

3.65

3.91

4.17

4.43

4.69

4.95

5.21

5.47

5.73

5.99

6.25

6.51

6.77

7.03

7.29

7.55

7.81

8.07

8.33

8.59

8.85

Offered Load

Effic

ienc

y

Efficiency

Figure 14: Variation of Efficiency of CSMS/CD using NS2 We see that the efficiency increases linearly until the Rate reaches about 2, and keeps about 94%.

3.4.2 Effect of Bandwidth on efficiency of CSMA/CD Bandwidth plays an important role in deciding the Transmission time required for each station. Higher the bandwidth the lesser the transmission time. We know from theory that the Efficiency of CSMA/CD is given by.

E ~ 1/(1+5a)

Where a = (Tprop/ Tr).

This implies that as ‘a’ increases efficiency decreases. In other words we can see that (from the above) as bandwidth increases efficiency decreases. The same is depicted in the figure below. Parameters:

• Number of stations N = 10 • Size of each frame Sp = 1,000 bits • Bandwidth of the shared medium Bw = Varies from 100Kbps to10Mbps • Propagation time τ = 5µs.

Page 25: Aloha

Department of CSSE, Auburn University

25

Effect of Bandwidth on Efficiency

0

10

20

30

40

50

60

70

80

90

100

0.01

1.41

2.81

4.21

5.61

7.01

8.41

9.81

11.2

12.6 14

15.4

16.8

18.2

19.6 21

22.4

23.8

25.2

26.6 28

29.4

30.8

32.2

33.6 35

36.4

37.8

39.2

40.6 42

43.4

44.8

46.2

47.6 49

Bandwidth (Mbps)

Perc

enta

ge E

ffici

ency

Optinal Backoff Binary Backoff NS2

Figure 15: Variation of Efficiency of CSMS/CD with Bandwidth Varying the frame size will have a similar effect on the efficiency of CSMA/CD. This is because as per the equations above both bandwidth and frame size eventually affect the value of ‘a’ upon which the efficiency depends.

3.4.3 Effect of Number of stations on efficiency of CSMA/CD Increasing the number of participating stations increases the overall load on the network increases. So in essence this experiment yields results similar to the experiment discussed in section 3.4.1 above. The graphs below depict the results obtained. Parameters:

• Number of stations N = Varies from 2 to100 • Size of each frame Sp = 1,000 bits • Bandwidth of the shared medium Bw = Varies from 100Kbps to10Mbps • Propagation time τ = 5µs.

Page 26: Aloha

Department of CSSE, Auburn University

26

Effect of Number of stations on Efficiency

0

10

20

30

40

50

60

70

80

90

100

2 5 8 11 14 17 20 23 26 29 32 35 38 41 44 47 50 53 56 59 62 65 68 71 74 77 80 83 86 89 92 95 98

Number of Stations

Perc

enta

ge E

ffici

ency

Optimal Backoff "Binary Backoff" NS2

Figure 16: Variation of Efficiency of CSMS/CD with number of Stations It is interesting to see that even though the number of stations in the LAN increases to a large value, the efficiency of the protocol is not drastically affected unlike in the case of ALOHA. This is mainly because of the Carrier Sensing mechanism. Even though there are packets in the link layer buffers, the protocol will not send frames on to a busy medium, thereby avoiding collisions. However the end to end throughput for higher layer protocols reduces due to the limited size of the buffers. This means that even though MAC layer scales well with the number of stations practical limitations exist due to fixed size network buffers.

Page 27: Aloha

Department of CSSE, Auburn University

27

4 Conclusion

In this work we have studied the behavior of different contention based MAC protocols under various network conditions. We have simulated the protocols for different values of the parameters N, Sp, Bw and Lambda (Offered Load) using our own simulator and Ns2 as well. Our simulation validates the theoretical results. Under similar conditions assumed in theoretical analysis, the simulation tool shows that the efficiency of Pure Aloha and Slotted Aloha are approximately equal to the corresponding theoretical values i.e. 18.4% and 36.8%. We demonstrated this by showing that the collision fraction of time is highly correlated to the idle time fraction over the time. In the end we also saw the effect of using uniform distribution for variation of the back off time in the case of collisions.

In the final part of the project we studied that the efficiency for CSMA/CD is significantly higher than the Aloha protocols. It varies anywhere between 80% and 95% for depending on the values of bandwidth. We have also proposed an optimal back off strategy which yields better results than the default binary exponential back off.

The difference in the results obtained using NS2,our simulator and theory can be mainly attributed to the following:

Efficiency of the Random number generator used.

Approximations in the calculations done by computer.

Approximations done as part of theoretical analysis.

Page 28: Aloha

Department of CSSE, Auburn University

28

Appendix A

4.1 The Simulation Tool

This section describes in detail, the simulation tool, implemented as part of this project for experimentation and analysis of ALOHA. The simulation model used in the simulator is a discrete event simulation model. As part of this model, following set of events can be identified:

• Transmission of a frame into the shared medium:

Nodes transmit frames at a certain rate. After each successful transmission, a Node waits for a randomly distributed time ‘Tg’ before sending a new frame. In the case where a frame has to be retransmitted, the node will have to wait a randomly distributed time Tw(Back off time) before retransmitting.

• Collision of frames in the shared medium:

In the case that a set of nodes send during one transmission time all the sending nodes will get involved in a collision. Therefore, all the nodes will have to back off for a random amount of time before transmitting the same frames again.

4.1.1 Characterization of the model

The simulation model realized in this project can be characterized as follows:

• Discrete-state-continuous-time model

Although the events happen only at discrete events of time, the state of the system (i.e. the state of the shared medium) is defined at all times right through the simulation. The channel is either busy with transmissions, collision or idle.

Probabilistic Model There is a certain degree of randomness in the way the nodes try to access the medium. The time interval between 2 successive frames sent by a Node follows certain random distribution. Further details about the distributions used to model this are mentioned in the next section

Open and Dynamic Model The simulation does not make an assumption about the number of frames. Indeed, each node in the network has an independent distribution of generating frames. Therefore, a node may send frames randomly and continuously into the network. [TBD]The state of the system being simulated varies over time.

Page 29: Aloha

Department of CSSE, Auburn University

29

4.1.2 The simulation language

The simulation is done using Java as a programming language. The main advantages with Java are:

It makes the simulation platform independent and portable.

It allows considerable flexibility in modeling the problem at hand.

It has rich set of data structures and packages for random number generation.

4.1.3 The simulator design

The simulator is designed in an object oriented manner. The setup for the simulation mainly consists of the nodes in the networks, which are in different states at different points of time. Since time is a variable in this setup. We need a mechanism to advance the time during simulation. We prefer to have a global variable indicating the current time in the simulation instead of relating it to the actual system time. This enables the simulation to perform better by using the CPU in a smarter fashion. A global variable in the simulation program is defined and incremented automatically by the time of the next earliest event, as an alternative of not to step through each time unit.

Following are the classes that are parts of the simulator.

4.1.3.1 Classes

Class Node

This class represents a single node in the ALOHA network. It specifically models the state of the node throughout the simulation.

Members

Member Variable Description

nextTransmitTime indicates the duration after which the next frame will be sent by this node.

State indicates the state of the current node i.e. Whether the current transmission from this node is a fresh transmission or a retransmission of the previous frame.

RandomTgGenerator This is the random generator class that is used to generate random time before the next transmission.

RandomBkGenerator This is the random generator class that is used to generate random time for backing off. This is used whenever a node collides.

Member Functions

Page 30: Aloha

Department of CSSE, Auburn University

30

getNextTransmitTime()

This function returns the current value of nextTransmitTime.

generateTg() [TBD: each distribution should have a separate function]

This function returns the next random amount of time after which the node will transmit the frame.

generateBackoff()

This function returns the next random amount of time after which the node will transmit the frame.

Class ALOHA

This class represents the protocol being simulated. It models the events that happen during the simulation.

Following are the types of events that can happen during the simulation:

Frame Transmission

Collision

Frame Re-Transmission

Members:

Following are the member variables of the ALOHA.

Member Variable Description

CurrentSimTime: This variable indicates the time at which the an event happened.

SharedMedium This is vector of Nodes and is used to iterate through the status of each node. The Nodes are ordered based on their next time of transmission. That always the Node at the beginning of the list always transmits next.

Bw This is the bandwidth (in bits per second) of the medium.

Sp This is the size of each frame in bits.

Page 31: Aloha

Department of CSSE, Auburn University

31

Member Variable Description

Tf indicates the transmission time for each node. This is the time duration for which the medium is used by the currently transmitting node. If any other node begins to transmit during this time interval a collision will occur. Tf is calculated as the ratio Sp/Bw and is expressed in units of time.

CollisionDuration Indicates the amount of time for which the medium was wasted in collision.

IdleTime Indicates the amount of time for which the medium was idle and was not utilized for transmission by any of the nodes.

SuccessCount Indicates the number of transmissions that were completed successfully without collision.

reTransmitCount Indicates the number of retransmissions that occurred during the simulation.

CollisionCount Indicates the number of collisions that occurred during the entire length of simulation

Member Functions:

GenerateSharedMedium()

This function initializes the system by creating all the nodes with initial transmission time.

BeginSimulation()

This function executes the simulation logic for given number of trials. Following is the algorithm for the function:

Function BeginSimulation

Begin

For trial (0: maxTrials)

Begin

currentNode = get the first node from the shared medium.

NextNode = get the nect node from the shared medium.

Increment CurrentSimulationTime to CurrentNode.Tg

Page 32: Aloha

Department of CSSE, Auburn University

32

if ( currentNode.Tg + Tf >= nextNode.Tg)

Increment collisions count.

Increment CurrentSimulationTime to nextNode.Tg

currentNode.Tg = currentNode.Tg + GenerateBackoff()

nextNode.Tg = nextNode.Tg + GenerateBackoff()

else

Increment success count.

currentNode.Tg = currentNode.Tg + GenerateBackoff()

End for

End Function

SortMedium() and InsertSorted()

This is a helper function for sorting all the nodes based on their next transmission time.

DisplayResults ()

This function displays the results of the simulation based on the final values of the different counters measured right through the simulation.

4.1.4 Source Code