Chào các bạn! Vì nhiều lý do từ nay Truyen2U chính thức đổi tên là Truyen247.Pro. Mong các bạn tiếp tục ủng hộ truy cập tên miền mới này nhé! Mãi yêu... ♥

NS2-phép tính

Tính độ trễ gói tin gửi từ nguồn n1 đến đích n3

BEGIN{ 

highest_packet_id=0; 

action=$1  

time=$2 

from=$3 

to=$4 

type=$5 

pktsize=$6 

flow_id=$8 

src=$9 

dst=$10 

seq_no=$11 

packet_id=$12 

if(packet_id>highest_packet_id) 

highest_packet_id=packet_id; 

if(start_time[packet_id]==0) 

start_time[packet_id]=time; 

if(flow_id==2&&action!="d") 

if(action=="r"){ 

end_time[packet_id]=time; 

}else{ 

End_time[packet_id]=-1; 

END { 

For(packet_id=0;packet_id<= highest_packet_id;packet_id++) 

start=start_time[packet_id]; 

end=end_time[packet_id]; 

packet_duration=end-start; 

if(start<end) printf("%f %

",start,packet_duration); 

Lấy thông tin từ file k6.tr vào file delay gõ lệnh

Awk -f delay.awk k6.tr>delay 

Vẽ đồ thị bằng xgraph

Xgraph delay 

Tính thông llượng giữa n2 và n3 cho luồng dữ liệu CBR : throughput.awk 

BEGIN{ 

init=0; 

i=0; 

Action=$1; 

Time=$2; 

from=$3; 

to=$4; 

type=$5; 

pktsize=$6; 

flow_id=$8; 

src=$9; 

dst=$10; 

seq_no=$11; 

packet_id=$12; 

if(action=="r" && from==2 && to==3 && flow_id==2) 

Pkt_byte_sum[i+1]=pkt_byte_sum[i]+pktsize; 

If(init==0) 

Start_time=time; 

init=1; 

end_time[i]=time; 

i=i+1; 

END { 

Printf("%.2f\t %.2f

",end_time[0],0) ; 

For(j=1;j<I;j++) 

Th=pkt_byte_sum[j]/(end_time[j] -start_time) * 8/1000; 

Printf("%.2f\t %.2f

",end_time[j],th) ; 

Printf("%.2f\t %.2f

",end_time[i-1,0) ; 

Lấy thông tin từ file k6.tr để lưu vào file thoughput gõ lệnh

Awk_ f throughput.awk k6.tr>throughput 

Vẽ đồ thị bằng  xgraph 

Xgraph throughput 

Tính số gói tin bị mất của luồng dl CBR(màu đỏ):loss.awt 

BEGIN{ 

fsDrops=0; 

numFs=0; 

Action=$1; 

Time=$2; 

from=$3; 

to=$4; 

type=$5; 

pktsize=$6; 

flow_id=$8; 

src=$9; 

dst=$10; 

seq_no=$11; 

packet_id=$12; 

if(from==1 && to==2& action=="+") 

numFs++; 

if(flow_id==2 && action=="d") 

fsDrops++; 

END { 

Printf("number of packet send: %d lost: %d

",numFs,fsDrops); 

lấy thông tin từ file k6.tr để lưu vào file loss gõ lệnh:

Awk_f loss.awk k6.tr>loss 

Bạn đang đọc truyện trên: Truyen247.Pro

Tags: #windy