element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum ad hoc Netzwerk mit Raspberry Pi Model B
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • Replies 17 replies
  • Subscribers 664 subscribers
  • Views 1937 views
  • Users 0 members are here
  • adhoc
  • raspberry
  • arp
  • routing
  • manet
Related

ad hoc Netzwerk mit Raspberry Pi Model B

Former Member
Former Member over 10 years ago

Hallo

 

Ich versuche ein Ad-hoc Meshnetz mittels 4 Raspberry Pi's Model B aufzubauen. Hier sind die Hardware Eigenschaften:

  • 4x Raspberry Pi Model B ( Raspbian Debian Wheezy 3.18)
  • 4x Edimax EW-7811Un USB WiFi Adapter (RTL8188cus)
  • 1x Laptop mit Win 8.1 um auf die RPi's über SSH (PuTTY) zuzugreifen

 

 

ich habe die RPi Netzwerkeinstellungen wie folgend konfiguriert:

/etc/network/interfaces

RPi1

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.1.21
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid RPiAdHocNetwork
  wireless-mode ad-hoc

 

RPi2

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.1.22
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid RPiAdHocNetwork
  wireless-mode ad-hoc

 

RPi3

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.1.23
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid RPiAdHocNetwork
  wireless-mode ad-hoc

 

RPi4

auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
  address 192.168.1.24
  netmask 255.255.255.0
  wireless-channel 1
  wireless-essid RPiAdHocNetwork
  wireless-mode ad-hoc

 

Laptop

IP: 192.168.1.20
Subnet: 255.255.255.0
Mode: Ad-hoc

 


Das pingen vom Laptop --> RPi's funktioniert

C:\> ping 192.168.1.21

Ping wird ausgeführt für 192.168.1.21 mit 32 Bytes Daten:
Antwort von 192.168.1.21: Bytes=32 Zeit=1ms TTL=64
Antwort von 192.168.1.21: Bytes=32 Zeit=1ms TTL=64
Antwort von 192.168.1.21: Bytes=32 Zeit=2ms TTL=64
Antwort von 192.168.1.21: Bytes=32 Zeit=1ms TTL=64

Ping-Statistik für 192.168.1.21:
    Pakete: Gesendet = 4, Empfangen = 4, Verloren = 0
    (0% Verlust),
Ca. Zeitangaben in Millisek.:
    Minimum = 1ms, Maximum = 2ms, Mittelwert = 1ms

 

das Pingen vom RPi --> Laptop funktioniert auch

pi@rpi1 ~ $ ping 192.168.1.20
PING 192.168.1.20 (192.168.1.20) 56(84) bytes of data.
64 bytes from 192.168.1.20: icmp_req=1 ttl=128 time=1.37 ms
64 bytes from 192.168.1.20: icmp_req=2 ttl=128 time=1.24 ms
64 bytes from 192.168.1.20: icmp_req=3 ttl=128 time=1.25 ms
64 bytes from 192.168.1.20: icmp_req=4 ttl=128 time=15.6 ms
64 bytes from 192.168.1.20: icmp_req=5 ttl=128 time=1.42 ms
64 bytes from 192.168.1.20: icmp_req=6 ttl=128 time=1.28 ms
^C
--- 192.168.1.20 ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5007ms
rtt min/avg/max/mdev = 1.242/3.710/15.683/5.354 ms

 

Das Problem ist, dass ich von einem RPi zum anderen nicht direkt pingen kann.

pi@rpi1 ~ $ ping 192.168.1.22
PING 192.168.1.22 (192.168.1.22) 56(84) bytes of data.
From 192.168.1.21 icmp_seq=1 Destination Host Unreachable
From 192.168.1.21 icmp_seq=2 Destination Host Unreachable
From 192.168.1.21 icmp_seq=3 Destination Host Unreachable
From 192.168.1.21 icmp_seq=4 Destination Host Unreachable
From 192.168.1.21 icmp_seq=5 Destination Host Unreachable
From 192.168.1.21 icmp_seq=6 Destination Host Unreachable
^C
--- 192.168.1.22 ping statistics ---
7 packets transmitted, 0 received, +6 errors, 100% packet loss, time 6004ms
pipe 3

 

Hat jemand vielleicht eine Idee wie ich die RPi's mit einander zu kommunizieren bringen könnte? vielen dank im voraus


Attachments:
image
  • Sign in to reply
  • Cancel
  • clem57
    clem57 over 10 years ago

    Add to each RPi:

    gateway: 192.168.1.20

    Now that will work.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to clem57

    I appreciate your suggestion. but what if I would ping a Pi with another Pi in the same subnet without a defult gateway? isn't that the main task of a an adhoc network ?

    my goal is to build a mesh network with RPi's and make them able to transport packets through each other ( same as in mobile adhoc mesh network MANET) by multihop.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to clem57

    The reason is routing in TCP/IP is two way and you are missing the return path because the Pi's do not know. Silly this is. But that is the rules of the protocol.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to clem57

    Sorry to ask again. Does that mean that it wouldn't be possible to get a MANET working with RPis ?

    what if I used a routing protocol (OLSR, B.A.T.M.A.N. or Babel) ?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • rew
    rew over 10 years ago

    If the raspberry pi ".21" says that ".22" is unreachable (your last ping listing) then it doesn't have the route to that raspberry pi.

     

    Your route should look something like this:

    # route -n

    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

    192.168.1.0   0.0.0.0         255.255.255.0   U     0      0        0 wlan0

     

    Somehow, it seems as if this is missing.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to rew

    this is the output of route -n

     

    root@rpi1:/# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    169.254.0.0     0.0.0.0         255.255.0.0     U     304    0        0 wlan0
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

     

    pi@rpi2 / $ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    169.254.0.0     0.0.0.0         255.255.0.0     U     303    0        0 wlan0
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

     

    pi@rpi3 ~ $ route -n
    Kernel-IP-Routentabelle
    Ziel            Router          Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

     

    pi@rpi4 ~ $ route -n
    Kernel-IP-Routentabelle
    Ziel            Router          Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 wlan0

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • rew
    rew over 10 years ago in reply to Former Member

    Yeah. That's what I expected, and that's what should work.

     

    So, when "pi1" has a packet for "pi2" it knows it should issue an "arp" broadcast on wlan0 asking for the MAC address of (the IP address of) pi2. Pi2 should answer, and then the packets for pi2 should be sent on "wlan0" directed at the proper MAC address.

     

    Next step would be to monitor "wlan0" on both pi1 and pi2 to see what's going on. Install tcpdump and issue: "sudo tcpdump -ni wlan0" in a separate console window on each pi. Make sure the output does not need to go over the wlan. Or if you're logged in over SSH from the laptop you could exclude traffic to and from the laptop by adding "not host laptop" (substituting the right IP for the laptop).

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to rew

    Ping from Pi2 --> Pi1

    root@rpi2:/# ping 192.168.1.21

     

    root@rpi1:/# tcpdump -i wlan0 not host 192.168.1.20
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on wlan0, link-type EN10MB (Ethernet), capture size 65535 bytes
    15:39:05.201599 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 74:da:38:28:a9:39 (oui Unknown), length 343
    15:39:05.310423 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 0.0.0.0.in-addr.arpa. (38)
    15:39:06.311936 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 0.0.0.0.in-addr.arpa. (38)
    15:39:08.312679 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 0.0.0.0.in-addr.arpa. (38)
    15:39:10.314170 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 255.255.255.255.in-addr.arpa. (46)
    15:39:11.315891 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 255.255.255.255.in-addr.arpa. (46)
    15:39:13.317622 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 255.255.255.255.in-addr.arpa. (46)
    15:39:15.323472 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 251.0.0.224.in-addr.arpa. (42)
    15:39:16.325150 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 251.0.0.224.in-addr.arpa. (42)
    15:39:18.327283 IP rpi1.local.mdns > 224.0.0.251.mdns: 0 PTR (QM)? 251.0.0.224.in-addr.arpa. (42)
    15:40:10.089396 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 74:da:38:28:a9:39 (oui Unknown), length 343
    15:41:14.490669 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 74:da:38:28:a9:39 (oui Unknown), length 343

    at Line 15. it stopped for about 3 Minutes ....

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • rew
    rew over 10 years ago in reply to Former Member

    If pi2 is still pinging and saying " no route to host" then you are very unlikely to see anything happening on pi1. So what is the tcpdump on pi2? (/while/ it is ping-ing).

     

    Wait... Someone on your network is doing DHCP. Ifconfig on most machines will show you the mac address. Who'se mac address is 74:da:....

     

    Also, you seem to have left out the '-n" option on TCPDUMP. If you leave it out, tcpdump will try to resolve all IP addresses to names, and that often causes more traffic and delays while the lookup is happening. So often with these "basic networking" problems you don't want the convenience of the lookups.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to rew

    here are the results.

    the 74:da:38:28:a9:39  is from Pi1

    the 74:da:38:28:a9:75 is Pi2

     

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube