School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,035 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,264 people online right now. Registration is fast and FREE... Join Now!




Matlab: red algorithm for network

 

Matlab: red algorithm for network

malikahaki

4 Jul, 2009 - 12:54 AM
Post #1

New D.I.C Head
*

Joined: 28 Jun, 2009
Posts: 3

i implement red algorithm with matlab but it dosen't work perfectly and it accept all the packet that arrived is there anybody to help me soon?
CODE

function [k] = red(n)
%
%
%
min_th=5;
max_th=15;
maxp=1/50;
w_q=0.2;
q=40;
time=2;
q_time=15;
k=0;
count=-1;   %  packets since last marked packet
avg=0;%average queue size
for i=1:n
    if (q~=0)%   q :current queue size
    avg=avg + w_q*(q-avg) %  w_q:queue weight
    else
        m=(time - q_times)/s %   time: current time,q_time:start of the queu idle time,s:transmission time for a small packet
        avag=(1-w(q))^m * avg
    end

if(avg>=min_th && avg<max_th)
    count=count+1;
    p_b=maxp*(avg-min_th)/(max_th-min_th)
    p_a=(p_b/(1-count*p_b))
    R=rand(1,1)
    if(R<p_a)
        disp('drop the arriving packet')
        count =0;
        k=k+1;
    else
       disp('accept arriving packet')
    end
    if (avg>=max_th)
        disp('drop the arriving packet')
        count=0;
        k=k+1
    else count=-1;
    end
end
plot(k,q);
end

end


User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 08:43AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month