intrig-unicamp / mininet-wifi

Emulator for Software-Defined Wireless Networks
https://mn-wifi.readthedocs.io/
Other
431 stars 239 forks source link

Can adhoc interfaces forward packet? #467

Closed hexiangdong0 closed 1 year ago

hexiangdong0 commented 1 year ago

I create a topology as following: adhoc_ap

ap1(ap1-wlan0) and ap2(ap2-wlan0) are APs. They are in an adhoc network at the same time(ap1-wlan1, ap2-wlan1). sta1 can ping ap1 and ap1 can ping ap2. However, sta1 can't ping ap2. I captured packets using wireshark and found that when sta1 ping ap2, ARP packets did arrive at ap1-wlan0, but ap1 didn't forward these broadcast ARP packets via ap1-wlan1(its adhoc interface). Is it because adhoc interfaces can't forward packets from other interface?

from mininet.log import setLogLevel, info
from mn_wifi.link import wmediumd, mesh, adhoc
from mn_wifi.cli import CLI
from mn_wifi.net import Mininet_wifi
from mn_wifi.wmediumdConnector import interference

def topology():
    "Create a network."
    net = Mininet_wifi(link=wmediumd, wmediumd_mode=interference)

    info("*** Creating nodes\n")
    sta1 = net.addStation('sta1', wlans=1, 
        mac='00:00:00:00:00:11', ip='192.168.1.3/24', position='-300,0,0')
    sta2 = net.addStation('sta2', wlans=1, 
        mac='00:00:00:00:00:12', ip='192.168.2.3/24', position='300,0,0')

    ap1 = net.addStation(f'ap1', wlans=2, position='-100,0,0', ip=f'192.168.1.1/24')
    ap2 = net.addStation(f'ap2', wlans=2, position='100,0,0', ip=f'192.168.2.1/24')

    c0 = net.addController('c0')

    info("*** Configuring wifi nodes\n")
    net.configureWifiNodes()

    info("*** Setting links\n")
    sta1.cmd('ip route add default dev sta1-wlan0')
    sta2.cmd('ip route add default dev sta2-wlan0')

    ap1.setMasterMode(intf=f'ap1-wlan0', ssid='ap1-ssid', channel=1, mode='g')
    ap1.cmd('ifconfig ap1-wlan1 192.168.1.2 netmask 255.255.0.0')
    ap1.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    net.addLink(ap1, intf='ap1-wlan1', cls=adhoc, ssid='adhoc-ssid', channel=5, proto='olsrd', proto_args='-hint 6')

    ap2.setMasterMode(intf=f'ap2-wlan0', ssid='ap2-ssid', channel=1, mode='g')
    ap2.cmd('ifconfig ap2-wlan1 192.168.2.2 netmask 255.255.0.0')
    ap2.cmd('echo 1 > /proc/sys/net/ipv4/ip_forward')
    net.addLink(ap2, intf='ap2-wlan1', cls=adhoc, ssid='adhoc-ssid', channel=5, proto='olsrd', proto_args='-hint 6')

    net.plotGraph(max_x=500, max_y=500, min_x=-500, min_y=-500)

    info("*** Starting network\n")
    net.build()
    c0.start()

    info("*** Running CLI\n")
    CLI(net)

    info("*** Stopping network\n")
    net.stop()

if __name__ == '__main__':
    setLogLevel('info')
    topology()
ramonfontes commented 1 year ago

This is not an issue at all :(. Please make sure you have an issue before opening one. This is about ip routing and I see no information about ip routing around here.

Please consider using the mailing list for questions like this.