In the code, I will create a hexagon centered at (0,0) with radius R. The snipplets can be used in mobile capacity predicts and general systems level simulation of cellular networks.

N = 40; %Number of users

R = 10; %Radius of Hexagon

Define the vertexes of the hexagon. They for angles 0, 60, 120, 180, 240 and 300 withe origin.

%Vertexes

v_x = R * cos((0:6)*pi/3);

v_y = R * sin((0:6)*pi/3);

The method used here is to generate many points in a square and choose N points that fall within the hexagon

%Generate 3N random points with square that is 2R by 2R

c_x = R – rand(1, 3*N)*2*R;

c_y = R – rand(1, 3*N)*2*R;

There is a command in MATLAB inploygon.

The command finds points within a polygon region.

%get the points within the polygon

IN = inpolygon(c_x, c_y, v_x, v_y);

%drop nodes outside the hexagon

c_x = c_x(IN);

c_y = c_y(IN);

%choose only N points

idx = randperm(length(c_x));

c_x = c_x(idx(1:N));

c_y = c_y(idx(1:N));

plot(c_x, c_y, ‘r*’)

hold on

plot(v_x,v_y)

axis square

hold off

The arrival rate is and the service time is .

The utilization

The interarrival times and the services times are exponentially distributed. A vector of exponentially distributed interarrival and service times are generated.

To generate exponential random vector, a transformation on uniform random variables can be used. To generate an exponentially distributed random variable with parameter , we need to convert the expression

.

.

This is equivalent to , since is uniformly distributed between 0 and 1

%generate two vector of random numbers with uniformly distribution

seed1 = RandStream.create(‘mcg16807′,’Seed’,5);

U1 = rand(seed1, 1, NSamples);

seed2 = RandStream.create(‘mcg16807′,’Seed’,6);

U2 = rand(seed2, 1, NSamples);

% service time vector

S = -1/mu*log(u1) * 1E3;

% inter-arrival time vector

tau = -1/lambda*log(u2) * 1E3;

Arrival and Departure Times

The arrival time is Poisson distributed and it is the sums of cumulative sum of the exponential random variables.

The Departure time for the first customer is

The departure times for subsequent customers is

The expected delay is

% the arrival time vector

T = cumsum(tau);

% the departure time vector

D = zeros(NSamples, 1);

D(1) = S(1) + tau(1);

% the waiting time vector

W = zeros(NSamples, 1);

W(1) = 0;

for i = 2:NSamples

D(i) = max(T(i), D(i-1)) + S(i);

W(i) = max(D(i-1)-T(i), 0);

end

% the delay time vector – in–queue wait time and service time

Delay_Time = zeros(NSamples, 1);

for i = 1:NSamples,

Delay_Time(i) = W(i) + S(i);

end

W is a vector that contains the waiting time.

Delay_Time is a vector that contains the time spent by a packet in the system

For more on MM1 and queuing systems in general check

- BERTSEKAS, D. P., & GALLAGER, R. G. (1992).
*Data networks*. Englewood Cliffs, N.J., Prentice Hall. - LEON-GARCIA, A., & LEON-GARCIA, A. (2008).
*Probability, statistics, and random processes for electrical engineering*. Upper Saddle River, NJ, Pearson/Prentice Hall.