Wannengrat:Alix boardFrom SwissExperimentAlix board
Building a 3G access pointAs the 3G modem needs access to ppp, we couldn't use the commercial routing software from Mikrotik and instead went back to first principles. This is good as we can now describe how to build a 3G access point from scratch.
SystemThe system chosen was Voyage Linux, which is a minimalistic debian linux distribution, aimed at low power embedded computing. This is a free download from their website. The version used was v.0.6.5. System ImageThe system is an archive that has to be unpacked on any Linux partition. It is then possible to browse through the system image, and to make some changes (or customizations) if desired. The flash memory that is going to be used for storing the system must then be connected to the computer where the system image has been unpacked. Preparing the flash memoryThe partition table might be tweaked using the Linux fdisk utility (here, assuming that the flash memory is seen as /dev/sdb): fdisk /dev/sdb The minimum size for the system partition is 128 MB. But keep in mind that installing extra utilities such as gcc takes a lot of space! Formatting the partitions is done using the mke2fs utility: mke2fs /dev/sdb1 tune2fs -c 0 /dev/sdb1 The first line creates an Ext2 filesystem on the flash while the second tunes it by turning of automatic maintenance filesysetm checks. Installing the system imageThe system image is then installed on the flash memory by running the script ./usr/local/sbin/voyage.update from the Voyage Linux root directory. It asks a series of (easy and straightforward) questions about what to do before performing the requested actions. Network ConfigurationThe network configuration is stored in /etc/network/interfaces. Our file looked as follows:
auto lo
iface lo inet loopback
# eth0 for maintenance
auto eth0
iface eth0 inet static
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
auto ath0
iface ath0 inet static
address 192.168.2.1
netmask 255.255.255.0
broadcast 192.168.2.255
madwifi-base wifi0
wireless-mode Master
up iwpriv ath0 mode 3
up iwconfig ath0 channel 6
up iwconfig ath0 mode Master
up iwconfig ath0 essid Hydrosys
up iwconfig ath0 txpower auto
up iwconfig ath0 enc off
up iwconfig ath0 rate auto
up nat.sh ath0 ppp0 "192.168.2.0/24"
Note that here we have the wifi (ath0) mode as Master to configure the wifi as an access point. The final line (up nat.sh......) uses a script packaged with voyage linux to put a NAT on the wifi, enabling it to communicate with the outside world over the 3G modem. Note: you cannot bridge between the wifi and the 3G modem as the ppp (used for the 3G modem) functions on a different software layer. You also do not need to do this as the NAT, combined with a default route to the 3G modem (which is assigned automatically) does everything that you need it to. If you want to use the wifi at 5GHz, you need to change the channel number. DHCPNow you have set up your access point, but you need to add DHCP so that you can easily connect to it. Voyage Linux, by default, ships with dnsmasq to act as DHCP. This seemed too complicated, so we added the DHCPD package (see below). To get this to work however, you have to disable dnsmasq by commenting out the contents of /etc/dnsmasq.more.conf. (info found here). Download and install dhcpd from ftp://ftp.isc.org/isc/dhcp/ All the info that we needed for dhcp server setup was found here, but essentially, you need to set up the /etc/dhcpd.conf as follows:
# /etc/dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.2.255;
option routers 192.168.2.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.10 192.168.2.100;
range 192.168.2.150 192.168.2.200;
}
Then add a few lines to rc.local as detailed further on to start the server on boot. Adding the GPRS/3G modemYou can use any GPRS modem, but the one that we used was a Sierra Wireless Compass 885 as we got it free from Swisscom. The first thing to note with this modem is the USB port used. This is detailed here i.e. USB4 for our modem. There are 3 files to change, the settings for which were found on the Sierra Wireless link above: /etc/ppp/peers/swisscom -detach lcp-echo-failure 0 /dev/ttyUSB4 115200 debug defaultroute usepeerdns #ipcp-no-address #ipcp-no-addresses ipcp-max-failure 4 ipcp-accept-local ipcp-accept-remote # AUTHENTICATION # If noauth works, use that, otherwise you have to pass # the user name and password. This is an example of a # standard Cingular user/pw combo noauth #user ISPDA@CINGULARGPRS.COM #password CINGULAR1 crtscts lock connect '/usr/sbin/chat -v -t6 -f /etc/ppp/peers/swisscom_chat' /etc/ppp/peers/swisscom_chat # Connection script for Sierra Wireless GSM/UMTS modems # Note: This demo script is setup to work on the Cingular EDGE network # SAY 'Starting Sierra Wireless GSM connect script...\n' SAY '\n' ####################################### SAY 'Setting the abort string\n' SAY '\n' # Abort String ------------------------------ ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT 'NO CARRIER' ABORT DELAYED ####################################### SAY 'Initializing modem\n' # Modem Initialization '' AT OK ATZ ####################################### SAY '\n' SAY 'Setting APN\n' # Access Point Name (APN) # Incorrect APN or CGDCONT can often cause errors in connection. # Below are a bunch of different popular APNs #REG:\s1 AT+cgdcont=1,"IP","proxy" #OK 'AT+CGDCONT=0,"IP","proxy"' #OK 'AT+CGDCONT=1,"IP","proxy"' #OK 'AT+CGDCONT=2,"IP","proxy"' #OK 'AT+CGDCONT=0,"IP","ISP.CINGULAR"' OK 'AT+CGDCONT=1,"IP","gprs.swisscom.ch"' #OK 'AT+CGDCONT=2,"IP","ISP.CINGULAR"' ####################################### SAY '\n' SAY 'Dialing...\n' # Dial the ISP, this is the common Cingular dial string OK ATD*99# CONNECT '' The GPRS parameters for various countries can be found here. /etc/ppp/peers/gprs_disconnect_chat #!/bin/sh # # File: # gprs-disconnect-chat # # send break exec /usr/sbin/chat -V -s -S \ ABORT "BUSY" \ ABORT "ERROR" \ ABORT "NO DIALTONE" \ SAY "\nSending break to the modem\n" \ "" "\K" \ "" "+++ATH" \ SAY "\nPDP context detached\n"</code> The startup fileFinally, you need to add some settings to /etc/rc.local to start the DHCP and modem up on boot. This file is used as it executes after all other systems have started. First, we made sure that the wifi was up and running. We then added a route as detailed in the DHCP instruction site that we read (apparently some clients need this line) We then make sure that the leases file exists (touch /var/db/dhcpd.leases). Note: you need to create this path if it doesn't already exist. Finally, /usr/sbin/dhcpd ath0 starts the DHCP The next section is to start the GPRS modem: First, there is a work-around as the resolve.conf (which contains the DNS server addresses) is overwritten on every boot, so we copy what we want into this file from a separate file with the correct addresses (in our case resolv.conf.thegoodone). nb. Do not delete or copy over this file as suggested by some websites. In my case, this eventually corrupted the file. pon swisscom is the command to start the modem. #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. # Turn on wifi and add dhcp ifconfig ath0 down ifconfig ath0 up route add -host 255.255.255.255 dev ath0 touch /var/db/dhcpd.leases /usr/sbin/dhcpd ath0 #Adjust DNS cat /etc/resolv.conf.thegoodone >> /etc/resolv.conf # Turn on Swisscom modem pon swisscom exit 0 RoutingRouting is handled by the default route added when the GPRS modem starts and by the NAT added to the wifi. No other routing is required. Making sure you stay connectedIn /etc/ppp/options there is the option 'persist'. If you uncomment this, the modem will try to reconnect when it gets disconnected.
Other useful infoAlix boardsThe Alix 3 board, from PCengines has two usb ports, one rs232 port, three ethernet ports, a mini-pci slot and a compact flash slot. Additional extensions can be soldered, like an IDE port (which replaces the compact flash slot), or an LPC connector for digital I/Os. The wiring of the COM1 and I2C (with no header soldered by default) is the following:
Configuration for long distance linkA few parameters of the 802.11 stack need to be adjusted for long distance link (timeout values, etc). This is explained here. To cut a long story short - use the following command line: athctrl -d XXXX where XXXX is the distance in meters. This is a command specific for the madwifi driver and it sets the timeouts, etc to the correct values for a given distance. Various info on GPRS modemsIf the connection is very slow, it can come from a low baudrate between the modem and the computer. This is set up with the AT command AT+IPR=115200 for example (a screen connection to the modem is a way to submit AT commands to the modem: screen /dev/ttyUSB0 115200). The GPRS parameters for various countries can be found here, some explanations on how to use a GPRS modem ar found here. At first, a A Siemens MC35i gprs modem was used. This was eventually changed for something newer and simpler. First, the modem must be brought out of sleep mode, which is done by connecting the yellow wire of its power line to +V for more than a second (+V is the input voltage, that can be between 8 and 30 volts). It can be kept connected if needed. Some debugging info on using this modem is found here.
|
