Raspberry Pi as a Wireless Router

  • Published on
    30-Aug-2014

  • View
    22.311

  • Download
    8

DESCRIPTION

 

Transcript

  • Raspberry Pi - Oct 28, 2013/Raspberry Pi #1
  • Raspberry Pi - Raspberry Pi - GPIO
  • Raspberry Pi ? http://www.flickr.com/photos/fotero/7697063016/
  • Raspberry Pi (Model B) SoC Broadcom BCM2835 CPU: ARM11 family, 700 MHz GPU: Broadcom VideoCore IV, OpenGL ES 2.0, 1080p30 H.264/MPEG-4 AVC decoder Memory: 512 Mb SDRAM Video outputs: Composite, HDMI Audio outputs: 3.5 mm jack, HDMI Onboard storage: SD, MMC, SDIO card slot Onboard 10/100 Ethernet RJ45
  • + OS http://www.raspberrypi-tutorials.co.uk/starting-up-your-raspberry-pi-device/set-raspberry-pi/
  • Raspberry Pi ?
  • Raspberry Pi ?
  • Raspberry Pi
  • Raspberry Pi -
  • - wikipedia : + Linux+Driver+
  • & &
  • (wireless) + (router)
  • http://www.techiestate.com/how-to-set-up-a-wireless-router/
  • http://www.techiestate.com/how-to-set-up-a-wireless-router/
  • = /
  • 3. 2. / 1. 5. 4. http://www.techiestate.com/how-to-set-up-a-wireless-router/
  • 3. 2. / 1. 5. + 4. http://www.techiestate.com/how-to-set-up-a-wireless-router/
  • &
  • / DHCP/Wireless Access Point CGI Python
  • 1 -
  • x86, ARM, MIPS, PowerPC ? ? ? 80386 PS2 Power Macintoshes ARM ARMv1, ARMv2..., ARMv8 ARM v6: Raspberry Pi Broadcom BCM2835
  • Porting( ) ( ) addressing space little endian/big endian alignment ( )
  • Toolchain + library Compiler Linker Assembler Debugger Libraries ... http://www.aboutdebian.com/compile.htm
  • Cross Compile Ex: x86 ARM gcc foo.c -o foo arm-linux-gnueabi-gcc foo.c -o foo
  • autotools ./configure --build --host --target --host: the architecture that you want the file to run on --build: the architecture of the build machine --target: the machine that GCC will produce code for build , host target Ex: ./configure --build=i686-pc-linux-gnu --host=arm-linux --target=mips-linux
  • cross-compiling Raspberry Pi toolchain https://github.com/raspberrypi/tools arm-bcm2708-linux-gnueabi arm-bcm2708hardfp-linux-gnueabi gcc-linaro-arm-linux-gnueabihf-raspbian( ) echo 'export PATH=$PATH:/path/to/toolchain' >> ~/.bashrc
  • 2 -
  • iptables & ip forwarding
  • iptables
  • Linux netfilter( ) iptables( )
  • http://linux.vbird.org/linux_server/0250simple_firewall.php
  • iptables http://linux.vbird.org/linux_server/0250simple_firewall.php
  • NAT Table NAT = Network Address Translation IP port POSTROUTING SNAT/MASQUERADE
  • iptables -A INPUT -i wlan0 -j ACCEPT iptables -t nat -A POSTROUTING -s 192.168.77.0/24 -o eth0 -j MASQUERADE sysctl net.ipv4.ip_forward=1
  • iptables & ip forwarding AP mode
  • Station (STA) infrastructure mode AccessPoint (AP) infrastructure mode Monitor (MON) mode Ad-Hoc (IBSS) mode Wireless Distribution System (WDS) mode Mesh http://wireless.kernel.org/en/users/Documentation/modes
  • AP AP(Master) mode Ralink rt2400 / rt2500 Broadcom 43xx Realtek RTL8180 Texas Instruments ACX100/ACX111 Intel PRO/Wireless (ipwXXXX) series ZyDAS ZD1211 ... https://help.ubuntu.com/community/WifiDocs/MasterMode
  • hostapd User space daemon for access point Support IEEE 802.1X/WPA/WPA2/EAP + http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html
  • Cross Compile hostapd hostapd(RTL8188CUS) configure CC=arm-linux-gnueabihf-gcc ./configure --host=armlinux --prefix=/path/to/install make && make install http://bit.ly/t0HWH1
  • iptables & ip forwarding AP mode dhcp daemon
  • DHCP Daemon IP, isc-dhcp-server http://linux.vbird.org/linux_server/0340dhcp.php
  • Cross Compile dhcpd dhcpd configure wget ftp://ftp.isc.org/isc/dhcp/4.1-ESV-R8/dhcp-4.1-ESV-R8.tar.gz CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux --prefix=/path/to/install make && make install
  • iptables & ip forwarding AP mode dhcp daemon
  • 3 UI
  • App ? Application GUI-ToolKit Framebuffer Hardware
  • Native App vs. Browser Based App /dev/fb driver SoC
  • Native App 1. toolkit ap 2. 3. IPC /dev/fb driver SoC
  • Browser Based App 1. HTML5 CSS3 2. 3. plugin /dev/fb driver SoC
  • Browser based = web server +
  • 80/8080 port HTTP CGI module Apache, Nginx, Boa http://www.resultantsys.com/index.php/general/what-is-a-web-application-server/
  • Boa Web Server (~2005) , 25 C 6899 access control(authentication) chroot SSL GPLv2 License
  • Cross Compile Boa boa configure wget http://www.boa.org/boa-0.94.13.tar.gz CC=arm-linux-gnueabihf-gcc ./configure --host=armlinux make && make install
  • web server
  • Python Raspberry Pi Script web server CGI ,
  • CGI CGI = Common Gateway Interface web server C, Perl, Python, PHP... / Python CGI
  • 4 -
  • Python (GPIO) shell command AJAX
  • General Purpose Input Output(GPIO) A generic pin on an IC http://raspberrypihobbyist.blogspot.tw/2012/09/so-many-inputs-so-few-gpio-pins.html
  • Raspberry Pi GPIO SPI / I2C / UART / PWM http://elinux.org/RPi_Low-level_peripherals
  • Python Code Flow Import module Define pin numbering Setup up a channel Input/Output Cleanup
  • Python Code Example green = 26 , red = 24 # Define pin numbering try: import RPi.GPIO as GPIO # Import module except RuntimeError: print ("import RPi.GPIO error!!") GPIO.setmode(GPIO.BOARD) # Setup up a channel cmd = "sudo sysctl net.ipv4.ip_forward=1" result = commands.getstatusoutput(cmd) GPIO.output(green, GPIO.HIGH) # Input/Output GPIO.output(red, GPIO.LOW) # # Input/Output
  • DEMO
  • iptables ( ) hostapd( ) isc-dhcp-server( ) UI Boa( ) Python( ) , Python (GPIO)
  • Raspberry Pi Rocks the World Thanks