söndag, november 27, 2011

TP-LINK 3420 + OpenWRT + Huawei E398 = 3G WiFi AP

Update on 2012-03-17: the latest firmware supports this out of the box, no need for manual modeswitching and such.

Here is the path that I followed to get my wireless access point up and running. So far I havn't got more throughput than ~7Mbit and this is probably due to the serial interface, there is supposedly a network interface available on the E398 but that is another story.

Edit: when running a throughput test on my laptop I got ~15Mbit compared to the lower number that I recieved on my IPad. Which means I won't bother to tune any parameters performance wise.

  1. Install OpenWRT on the router, I used the upgrade function which works great.
  2. Use telnet to log in to the router, set a root password. Disable firewall to be able to log in through WAN port on router (as you need internet access from the router as well as administration access through SSH from your computer).
    /etc/init.d/firewall stop
    /etc/init.d/firewall disable
  3. Make sure the router has internet access, I used internet sharing on my internet connected laptop and the WAN port of the router.
  4. Find the IP address of the router (which in my case is distributed from my laptop), I used PowerShell.
    1..255 | foreach-object { (new-object System.Net.Networkinformation.Ping).Send("192.168.137.$_", 10) } | where-object { $_.Status -eq "Success" } | select $_.Address.Address
  5. Connect to the router using Putty or some other SSH client. Install the following packages through the opkg tool; comgt (3g scripts), usb-modeswitch (used to switch the mode on the modem from storage to modem), kmod-usb-serial (to be able to use the modem as a serial device).
    opkg install comgt
    opkg install usb-modeswitch
    opkg install kmod-usb-serial
  6. Add the usb-modeswitch command to be run on startup through /etc/rc.local. Add the following line:
    usb_modeswitch -v 12d1 -p 1505 -M "55534243123456780000000000000011062000000100000000000000000000"
  7. Make sure the device that pops up on modeswitch is recognized as a serial device, add the following line to /etc/modules.d/60-usb-serial
    usbserial vendor=0x12d1 product=0x1506
  8. Last but not least create an interface configuration for this new connection by adding the following to /etc/config/network
    config interface wan
            option ifname   'ppp0'
            option proto    '3g'
            option device   '/dev/ttyUSB0'
            option apn      '4g.tele2.se'
            option pincode  0000
            option auto     1
  9. If you wan't this connection to start on boot the auto flag is NOT enough, you can work arround this bug by adding the following script /etc/init.d/network3g
    #!/bin/sh /etc/rc.common
    
    START=41
    STOP=91
    
    start()
    {
        include /lib/network
        scan_interfaces
        for ifc in $interfaces; do
            config_get ifproto "$ifc" proto
            config_get ifauto "$ifc" auto
            [ "$ifproto" = "3g" ] && {
            case "$ifauto" in
                    1|on|enabled) ifup $ifc;;
            esac
            }
        done 
    }
    
    stop()
    {
        include /lib/network
        scan_interfaces
        for ifc in $interfaces; do
            config_get ifproto "$ifc" proto
            [ "$ifproto" = "3g" ] && {
                ifdown $ifc 
            }
        done 
    }
  10. Then configure WIFI etc. Remember to enable the firewall...

I rather like this little setup. The router cost me about 30€ and the mobile plan, including modem, is 17€. Big thanks goes to:

onsdag, november 23, 2011

Bredbandsuppgradering del 2

Än så länge ser det bra ut. Jag har lite problem att få igång routern men det ska nog ordna sig bara jag inaktiverar PIN koden.

lördag, november 12, 2011

En lyckad dag på Skansen

Ännu ett lyckat besök på Skansen. Jag är lite förundrad över vilken hög lägstanivå mina besök på Skansen har, aldrig har jag blivit missnöjd och de jag varit där med ha alltid varit nöjda. Nu var vi där med min syster och hennes familj samt min bror med fru och som vanligt åt vi lunch på restaurang Solliden -som är väldigt populär även bland andra småbarnsfamiljer vad det verkar.

Kungens konung (eller drottning) såg lite bedrövad ut i sin inhägnad. Vad finns det att fundera på hela dagarna, planera en flykt månne?

Hur många björnar kan bo ihop utan att bita huvudet av varandra? Minst fem iallafall vad jag kunde räkna till. De gillar tydligen äpplen som snacks.

Den som lyckas inkorporera snickarglädje i en timmerkåk tycker jag lyckats väldigt bra. Tiden har väl iochförsig gjort sitt till?

Dagen avslutades med middag ifrån Thaikiosken hemma i Täby kyrkby. Klockan åtta är jag redo att gå och sova...

fredag, november 11, 2011

TSQL Challenge 51

Ibland känns det kul att göra något mer eller mindre opassande för att testa hur långt åt fel håll man kan driva tekniken. I det här fallet var utmaningen att bygga en parser för binär representation av decimaltal, lösningen skulle bestå av endast en query vilket helt utesluter någon form av imperativ for loop. I Microsofts SQL dialekt har man istället tillgång till något som kallas CTE eller common table expression som låter en arbeta rekursivt med ett bassteg som bearbetar det första tecknet som följs av ett steg för n + 1 och i det här fallet slutligen ett steg som springer igenom alla resultat och multiplicerar med 2 (binärt). Sedan kan man summera resultatet för att få ut decimaltalet. Ett möjligt problem man kan springa på här är att ett exempeltal i pusslet är 36000000000000000001 vilket inte går att räkna fram med POW funktionen, annars kunde man använt den. Nu får man istället kvadrera själv vilket är lite roligare men ganska mycket bökigare.

  • Beskrivning av pusslet hos Beyond Relational - TC51
;WITH parse (Seq, Calc, Pow, DecimalValue, BinaryStringToBeParsed, Step)
AS
(
 SELECT
 Seq
 , CONVERT(INT,1)
 , CONVERT(INT,0)
 , CONVERT(DECIMAL(38,0),RIGHT(BinaryValue,1))
 , LEFT(BinaryValue, LEN(BinaryValue) - 1)
 , 'A'
 FROM TC51

 UNION ALL
 
 SELECT
 Seq
 , Calc + 1
 , Pow + 1
 , CONVERT(INT,RIGHT(BinaryStringToBeParsed,1))
 , LEFT(BinaryStringToBeParsed, LEN(BinaryStringToBeParsed) - 1)
 , 'B'
 FROM parse
 WHERE LEN(BinaryStringToBeParsed) > 0
 
 UNION ALL
 
 SELECT
 Seq
 , Calc
 , Pow - 1
 , CONVERT(DECIMAL(38,0),(2 * DecimalValue))
 , ''
 , 'C'
 FROM parse
 WHERE Pow > 0
)
SELECT
Seq
, sum(DecimalValue) [DecimalValue]
FROM parse
WHERE Pow = 0
GROUP BY Seq
ORDER BY SUM(DecimalValue), Seq
OPTION (MAXRECURSION 200)