function result=prr_perlink(sender,receiver,dbname,numofpkt) %% This script calculate packet reception rate (PRR) between a certain %% transmitter and receiver, given the database name to be queried and the %% total amount of packet transmitted on the link quote=''''; sqlitecmd=['sqlite3 ' dbname ' "select id from _senders where name=' quote 'sensor' int2str(receiver) quote ';"']; [temp temp2] = system(sqlitecmd); [temp3] = strread(temp2,'%d','delimiter','\n'); sensorID=temp3; sqlitecmd=['sqlite3 ' dbname ' "select ReportMsg_NA_r1_numberOfPacketsReceived from sf_sfdata_am80 where oml_sender_id=' int2str(sensorID) ' and ReportMsg_NA_r1_source=' quote int2str(sender) quote '"']; [temp temp2] = system(sqlitecmd);%fprintf(fid,[sqlitecmd '\n']); [temp3] = strread(temp2,'%d','delimiter','\n'); result=sum(temp3)/numofpkt;