フィルターのクリア

How to implement the following task in MATLAB ?

3 ビュー (過去 30 日間)
charu shree
charu shree 2023 年 5 月 10 日
回答済み: Shubham Dhanda 2023 年 6 月 22 日
Hello all, I am trying to code the following part in MATLAB. It is related to the queue length of a node which depenfds upon packet arrival and packet departure at the nodes and is mentioned as:
Queue length at a node in time slot 't+1' = Queue length at a node in time slot 't' + number of packet arrived in time slot 't' - number of packet departed in time slot 't'.
Note : Packet arrival follows binomial distribution and Packet departure is based on status of the link between the nodes (if status is 1 then packet is departed else not). The packet departed is calculated as: data rate * total time.
Following are my efforts:
sr = [1,2,2,2,3,3,3,4,5]; % various possible source
ta = [2,3,6,8,6,4,7,6,6]; % various possible targets
G = graph(sr,ta); % models the Graph
% Initial queue length
q_len = zeros(nodes,T); % Queue length
% assume 10 initially
q_len(:,1) = 10;
n = 10; % number of packets
p = 0.2; % probability of successful arrival of packets
pack_arr = binornd(n,p,[nodes,T]); % number of packets arrival
nodes = 8;
status = [1 2 2 1 2 2 2 1 1 ];
data_ rate = [0.399, 1.918 ,1.259, 1.289, 2.228, 1.099, 1.736, 1.469, 0.131]; % Total Time
T = 100;
%% Queue length of each nodes
for t = 1:T-1
for i = 1:nodes
q_len(i,t+1) = q_len(i,t)+pack_arr(i,t);
end
end
My query is that, I am unable to code for packet departed part in above for loop. Any help in this regard will be highly appreciated.
  2 件のコメント
Torsten
Torsten 2023 年 5 月 10 日
Don't you think it would be better first to read a book on queuing theory before starting to simulate such processes in MATLAB ?
charu shree
charu shree 2023 年 5 月 10 日
Thank u sir for ur response...But I think I had written correct code ...

サインインしてコメントする。

回答 (1 件)

Shubham Dhanda
Shubham Dhanda 2023 年 6 月 22 日
Hi,
I understand that you want to find the number of packets departed at the nodes. Packets departed depend on status value and is given by data rate* total time
Below is the MATLAB code implementation of the problem:
sr = [1,2,2,2,3,3,3,4,5]; % various possible source
ta = [2,3,6,8,6,4,7,6,6]; % various possible targets
G = graph(sr,ta); % models the Graph
nodes = 8;
status = [1 2 2 1 2 2 2 1 1 ];
data_rate = [0.399, 1.918 ,1.259, 1.289, 2.228, 1.099, 1.736, 1.469, 0.131]; % Total Time
T = 100;
% Initial queue length
q_len = zeros(nodes,T); % Queue length
% assume 10 initially
q_len(:,1) = 10;
n = 10; % number of packets
p = 0.2; % probability of successful arrival of packets
pack_arr = binornd(n,p,[nodes,T]); % number of packets arrival
%% Queue length of each nodes
for t = 1:T-1
for i = 1:nodes
% Calculate number of packets departed
if status(i) == 1 % link is available
pack_dep = round(data_rate(i)*T); % round to nearest integer
else
pack_dep = 0; % no packets depart
end
% Update queue length
q_len(i,t+1) = q_len(i,t) + pack_arr(i,t) - pack_dep;
end
end
Hope this helps.

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by