function result=score(dbname,route,pktperlink)
%% This function calculate a score for multihop network based on the average PRR at
%% each network node, a typical example is a sensor network.
%% dbname is the database name to be qeried
%% route is the matrix containing all the routes eg[1 2 3 ;2 3 4 ] means
%% the network has two path (1->2->3) and (4->2->3)
%% pktperlink: This is the amount of packet transmitted on each link
%% The score is calculated based on the average PRR, PRR for a path
%% containing multiple hop is the product of the PRR on all the links in
%% the path. Since when no packets are lost the PRR will be 1, scale to 10
%% for consistency
endtoend=ones(1,size(route,2)-1);
scorematrix=zeros(size(route,1),size(route,2)-1);
for i=1:size(route,1)
for j=size(route,2):-1:2
endtoend(i)=endtoend(i)*prr_perlink(route(i,j-1),route(i,j),dbname,pktperlink);
scorematrix(i,j-1)=endtoend(i);
end
end
result=10*mean(mean(scorematrix,1));