Monitoring network usage excluding local traffic

前端 未结 8 2069
一整个雨季
一整个雨季 2020-12-29 13:14

I am working on an app that monitors network usage. However I noticed many ways to do this does not allow exclusion of local traffic (say, Time Machine).

I am lookin

8条回答
  •  盖世英雄少女心
    2020-12-29 14:02

    It depends on how you define "local", but a common definition would be to look at the network mask.

    For example, if your IP (ie the IP of the interface you monitor is

    10.33.52.123
    netmask 255.255.255.0
    

    that would mean every IP-packet with both source-IP and destination-IP 10.33.52.xx is local.

    I don't know cocoa or objective-c, but you can probably use some of these functions helping you extract the network from an IP-address: http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/inet_network.3.html

提交回复
热议问题