1,准备工作
两台电脑无线网卡均配置成adhoc模式,选择信道6,ESSID为long. (信道6是我电脑旁边无线路由器所在的信道,不清楚它是否会对无线路由信号产生干扰,当然目前我把无线路由器电源拔了。)
A主机网卡配置为:IP=192.168.1.14,NETMASK=255.255.255.0,GATEWAY=192.168.1.1
B主机网卡配置为:IP=192.168.1.11,NETMASK=255.255.255.0,GATEWAY=192.168.1.1
此时在A主机上ping 192.168.1.11能ping通.
当然如果用无线路由器连接的话,跟有线一样的,很简单,实际上无线路由器会把连接它的有线还是无线的都分配到一个子网。
2,改变下B主机的网卡设置
B主机网卡配置为:IP=192.168.2.11,NETMASK=255.255.255.0,GATEWAY=192.168.2.1
此时在A主机上ping 192.168.2.11 ping不通
2,分别在两台主机上运行aodv无线路由协议,B主机终端显示如下:
19:51:20.754 main: In wait on reboot for 15000 milliseconds. Disable with "-D".
19:51:20.754 hello_start: Starting to send HELLOs!
19:51:35.757 wait_on_reboot_timeout: Wait on reboot over!!
19:51:45.725 rt_table_insert: Inserting 192.168.1.14 (bucket 0) next hop 192.168.1.14
19:51:45.726 nl_send_add_route_msg: ADD/UPDATE: 192.168.1.14:192.168.1.14 ifindex=3
19:51:45.726 rt_table_insert: New timer for 192.168.1.14, life=2100
19:51:45.726 hello_process: 192.168.1.14 new NEIGHBOR!
19:52:30.988 hello_timeout: LINK/HELLO FAILURE 192.168.1.14 last HELLO: 2051
19:52:30.988 neighbor_link_break: Link 192.168.1.14 down!
19:52:30.989 nl_send_del_route_msg: Send DEL_ROUTE to kernel: 192.168.1.14
19:52:30.989 rt_table_invalidate: 192.168.1.14 removed in 15000 msecs
19:52:30.997 nl_send_add_route_msg: ADD/UPDATE: 192.168.1.14:192.168.1.14 ifindex=3
19:52:54.682 hello_timeout: LINK/HELLO FAILURE 192.168.1.14 last HELLO: 2053
19:52:54.682 neighbor_link_break: Link 192.168.1.14 down!
19:52:54.682 nl_send_del_route_msg: Send DEL_ROUTE to kernel: 192.168.1.14
19:52:54.682 rt_table_invalidate: 192.168.1.14 removed in 15000 msecs
19:52:54.721 nl_send_add_route_msg: ADD/UPDATE: 192.168.1.14:192.168.1.14 ifindex=3
在B主机中 ping 192.168.1.14 发现能ping 通,结果如下:
[root@localhost ~]# ping 192.168.1.14 -R
PING 192.168.1.14 (192.168.1.14) 56(124) bytes of data.
64 bytes from 192.168.1.14: icmp_seq=0 ttl=64 time=2.17 ms
RR: 192.168.2.11
192.168.1.14
192.168.1.14
192.168.2.11
64 bytes from 192.168.1.14: icmp_seq=1 ttl=64 time=4.15 ms (same route)
64 bytes from 192.168.1.14: icmp_seq=2 ttl=64 time=2.19 ms (same route)
64 bytes from 192.168.1.14: icmp_seq=3 ttl=64 time=2.23 ms (same route)
64 bytes from 192.168.1.14: icmp_seq=4 ttl=64 time=5.62 ms (same route)
64 bytes from 192.168.1.14: icmp_seq=5 ttl=64 time=2.20 ms (same route)
^C
--- 192.168.1.14 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5020ms
在上述过程中,我通过开启与关闭无线路由器,观察到数据传输没有受到其影响.
分析:
刚开始时,两台电脑组成了一个局域网,且IP地址在同一网段内,所以能ping通.当改变B主机IP地址后,就不能ping通了.
运行aodv路由协议后,能ping通了,证明aodv无线路由协议能让两个网络中的主机A,B进行通信