Professional Documents
Culture Documents
Shivam (2K18/EC/160) 1
EC316 WIRELESS SENSOR NETWORKS
INDEX
S.no Experiment Date Remarks
1 To become familiar with 12-01-21
Wireless Sensor Networks.
2 To understand the differences 18-01-21
between Ad Hoc network and
WSN.
4 To implementMACAW
protocol using MATLAB/SCI
11-02-21
LAB.
Shivam (2K18/EC/160) 2
EC316 WIRELESS SENSOR NETWORKS
EXPERIMENT 4
Aim: To Implement MACAW protocol using MATLAB/SCI LAB.
Tools Required: MATLAB/SCI LAB
Theory:
Multiple Access with Collision Avoidance for Wireless (MACAW) is a medium access
control (MAC) protocol broadly utilized in ad hoc network systems. Besides, it is the
establishment of numerous other MAC protocols utilized in wireless sensor systems (WSN).
The IEEE 802.11 RTS/CTS system is received from this protocol. It utilizes RTS-CTS-DS-
DATA-ACK frame succession for moving information, once in a while went before by a
RTS-RRTS frame arrangement, in view to give answer for the concealed node problem.
Although protocol dependent on MACAW, are S-MAC, MACAW doesn’t utilize carrier
sense.
Features :
The problem in MACA that if there are two sender and two receiver A, B, C and D
respectively.
If B has send RTS to C and D at the same time and but only send data upon receiving
CTS from C.
Now A wants to send data to D but will not able to send because it will sense that D is
currently busy and will increase the backoff counter (for how much time A will wait
before re-transmitting) value by twice because of which it will get stuck in a loop
until the D gets free.
Shivam (2K18/EC/160) 3
EC316 WIRELESS SENSOR NETWORKS
Blockage data trade between pairwise stations, prompting better clog control and
backoff approaches
Example :
A successful transmission in case of MACAW will look like :
Shivam (2K18/EC/160) 4
EC316 WIRELESS SENSOR NETWORKS
RTS from A to B
CTS from B to A
DS from A to B
DATA frame from A to B
ACK from B to A.
RRTS from B to A
RTS from A to B
CTS from B to A
DS from A to B
ACK from B to A.
Shivam (2K18/EC/160) 5
EC316 WIRELESS SENSOR NETWORKS
CODE:
N = input('enter number of nodes'); % Choose Number of NODES in range 1 to 200.
Packet_size = input('enter the packet size') * 8; % Choose Packet Size in Bytes.
T = input('enter the simulation time') * 10^-3; % Choose Simulation time.
total_time = 0;
count = 0;
good_time = 0;
data_rate = 6 * 10^6; % Data Rate of 6 Mbps.
packet_time = Packet_size / data_rate;
slot_size = 9 * (10^-6); % Slot Size of 9μs.
j = 1;
simulation_count = 0;
CW_min = 30; % Minimum Contention Window, for every collision we will reduce CW to
Cwmin.
CW = 30; % For every successful transmission we will double CW.
collision_flag = 0; % To check if collision occurred or not.
r = (randi([0,CW_min],N,1)) * 10^-6; % Counter for N Nodes.
for i = 1:N
if (M == r(i)) % To find the Node with Minimal Counter.
count = count + 1; % If there are multiple nodes with minimum counter that would cause
collision.
collision_index(j) =i;
j = j + 1;
end
end
end
if collision_flag ~= 1 % no collision
good_time = good_time + packet_time;
if CW < 1 % For the Node which transmitted first update CW and then choose new
counter.
CW = 1.5;
end
r(I) = (randi([0,CW],1,1)) * 10^-6;
else
CW=CW-1; % For every transmission reduce the contention window by 1.
end
for i = 1:N %For every nodes that collided ,first update CW and choose new counter
if (M == r(i))
r(i) = (randi([0,CW],1,1)) * 10^-6;
end
end
OUTPUT:
Shivam (2K18/EC/160) 7
EC316 WIRELESS SENSOR NETWORKS
Shivam (2K18/EC/160) 8
EC316 WIRELESS SENSOR NETWORKS
Shivam (2K18/EC/160) 9