printf("Get %s Speed");
ret = get_if_speed(&ndev);
if(ret < 0)
printf("\t\t\t[Fail]\n");
else
printf("\t\t\t[OK]\n");
float ispeed ,ospeed;
while(1){
ispeed = ndev.ifs_ispeed * 1.0/(ndev.ifs_us/1000 * 0.001);
ospeed = ndev.ifs_ospeed * 1.0/(ndev.ifs_us/1000 * 0.001);
printf("%s: Up Speed: %f MB/s || Down Speed: %f MB/s \r",
ndev.ifs_name,ispeed/(1024.0*1024.0),ospeed/(1024.0*1024.0));
get_if_speed(&ndev);
}
return 0;
} /* ----- End of main() ----- */
可能你有更好的获取网速的办法,求留言指点!