Code covered by the BSD License  

Highlights from
TDMA basd MANET

image thumbnail

TDMA basd MANET

by

 

This file is used to analysis for TDMA based mobile ad-hoc network

tdmanet.m
% Writter: Pankaj Joshi India
%This Progame Use for defining Multicast Ad-hoc Network by finding cluster
%head and cluster id and members of cluster
clc;
clear all;
close all;
%%
%Define Network Parameters
num_node=input('Enter number of node for network=');
num_cluster=input('Enter number of cluster head required in network=');
xm=input('maximum x-lim for network land=');
ym=input('enter maximum y-lim for network land=');
zm=input('enter hight coordinate system or z-lim for network=');
[cluster_mems,cluster_id]=create_cluster(num_node,num_cluster,xm,ym,zm);

for k=1:num_cluster
    len(k)=length(find(cluster_mems(k,:))~=0);
end
num_reciv=input('Enter number of receivers=');
net_time=input('Define total time in sec for network analysis');
net_time=net_time/1000;
for m=1:num_reciv
    reciv_id(m)=randi(num_node,1,1);
end
%%
%Define data
data_len=64*net_time;%considering data generated by 64kbps
tot_data=data_len*num_cluster;
orig_data=rand(1,tot_data)>0.5;
h=commsrc.nrz('OutputLevels',[-2 2]);
tr_data=generate(h,orig_data');
plot(tr_data);
ylim([-2.2 2.2]);
title('transmitted data');
%% Defining Cluster Id and Cluster Members
for n=1:num_reciv
    [row(n),col(n)]=find(cluster_mems==reciv_id(n));
    clust_id(n)=row(n);
end
uni=unique(clust_id);
recv_per_cluster=histc(clust_id,uni);
for n=1:length(recv_per_cluster)
    if recv_per_cluster(n)>1
        time_slot_per_recv(n)=fix(100/recv_per_cluster(n));
    else
        time_slot_per_recv(n)=100;
    end
end
%% Find Out Time Slot in a Cluster 
time_slot_diff_cluster=time_slot_per_recv;
for k=1:num_cluster
    num_of_hop_per_cluster(k)=randi(len(k),1,1);
end
%% Calculation of Data Loss for network
avg_dist=xm*ym/num_node;
g_tx_ant=input('Enter the gain of transmitting antenna=');
g_rx_ant=input('Enter the gain of receiving antenna=');
rx_pwd=tr_data.*(g_tx_ant*g_rx_ant/4*pi*(avg_dist^2));
for k=1:num_cluster
    for l=1:num_of_hop_per_cluster(k)
        rx_pwd_db=20*log((g_tx_ant*g_rx_ant/4*pi*(avg_dist^2)));
    end
end
data_loss_wc=length(find(rx_pwd_db>3));
snr=(num_cluster/num_node)*1000;
rx_sig=awgn(tr_data,snr,'measured');
rx_sig_db=20*log(rx_sig./tr_data);
data_loss=length(find(rx_sig_db>3));

Contact us