Android下的两个文件系统:proc和sys(二)

来源:互联网 发布:数据产品经理面试题目 编辑:程序博客网 时间:2024/05/22 14:40

本文讲一讲proc/net下包含的文件的信息:

arp:IP地址对应的硬件地址

dev:网络设备状态信息,包括接受和发送的包的数量,出错等。ifconfig命令使用这个文件

igmp:Internet Group Management Protocol

rarp:和arp反过来的信息

raw:和原始套接字有关(raw socket)

snmp:snmp agent有关的信息,其他协议需要的一些ASCII码


tcp:(这里摘录一下手册中的原文)

Holds a dump of the TCP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local_address" is the local address and port number pair. The "rem_address" is the remote address and port number pair (if connected). "St" is the internal status of the socket. The "tx_queue" and "rx_queue" are the outgoing and incoming data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields hold internal information of the kernel socket state and are only useful for debugging. The "uid" field holds the effective UID of the creator of the socket.

大概是这么一个样子,包括了建立的socket链接的收发地址+端口号+uid,所以读这个包就能知道发包的进程是哪一个

sl  local_address     rem_address      st   tx_queue     rx_queue tr    tm->when  retrnsmt       uid      timeout inode
0: 0100007F:08A0 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7321 1 ffff81002f449980 3000 0 0 2 -1                     
1: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 6656 1 ffff81003a30c080 3000 0 0 2 -1                     
2: 00000000:0272 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 6733 1 ffff81003a30c6c0 3000 0 0 2 -1                     
3: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7411 1 ffff81002f448d00 3000 0 0 2 -1                     
4: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7520 1 ffff81002f4486c0 3000 0 0 2 -1                     
5: 0100007F:089F 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0        0 7339 1 ffff81002f449340 3000 0 0 2 -1           
6: 0100007F:E753 0100007F:0016 01 00000000:00000000 02:000AFA92 00000000   500        0 18198 2 ffff81002f448080 204 40 20 2 -1                   
7: 0100007F:E752 0100007F:0016 06 00000000:00000000 03:000005EC 00000000     0        0 0 2 ffff81000805dc00   

例如那个st,可以参考linux的源代码:./include/net/tcp_states.h    


udp:和上面的tcp文件是类似的。

unix:unix domain socket  ,NIX Domain Socket是在socket架构上发展起来的用于同一台主机的进程间通讯(IPC),它不需要经过网络协议栈,不需要打包拆包、计算校验和、维护序号和应答等,只是将应用层数据从一个进程拷贝到另一个进程。因为应用于IPC,所以UNIXDomain socket不需要IP和端口,取而代之的是文件路径来表示“网络地址”。似乎可以通过这个文件知道进程间的通信情况。不是很了解,可以再看一下。总觉得有点文章可做。


接下来说一说[pid]/net,即每个进程下的net文件里的内容

dev:里面也是记录了各个网络接口收发的字节数,包数目等,

eth0: ethernet的简写,一般用于以太网接口。
wlan0:wifi是无线局域网,因此wifi0一般指无线网络接口。
ath0: Atheros的简写,一般指Atheros芯片所包含的无线网络接口。
lo: local的简写,一般指本地环回接口。这点体现在下面两个方面。

这里的lo是本地回环,随便打开一个进程,发现这个lo的数据还挺高的,虚拟网络接口并不真实地从外界接收和发送数据包,而是在系统内部接收和发送数据包,因此虚拟网络接口不需要驱动程序。这个似乎和前面提到的IPC通信有关,具体还得看看其他资料。


 netlick: PF_NETLINK sockets,主要用于和内核通信吧,不是很懂这一部分的内容。不过记得有一个攻击内核获取root权限的就是从这里入手的,链接地址是http://hi.baidu.com/0soul/item/83bbd4de297c73cb1b72b41b


iptables主要和防火墙有关:

ip_tables_matches iptables支持的过滤模式 
ip_tables_names iptables规则表名字 
ip_tables_targets iptables规则链目标 
ip_conntrack iptables状态检测跟踪表      


packet:链路层原始套接字的信息可通过/proc/net/packet进行查看。可以查看到创建时指定的协议类型、是否绑定网口、已使用的接收缓存大小等信息。主要有这么几个域:sk refcnt type proto iface r rmem user inode。


fib_tire:路由表单词查找树trie。如何查询路由信息。

原创粉丝点击