Monday, February 21, 2005

02 20 2005, Sunday

It's been a while. For the last week I haven't been as active as normal doing tech stuff, but I made up for it today (Sunday, as I'm writing).

Umm, let's see... to catch up:

Still no luck getting the iPod to work. I ran into difficulties installing Window$ Service Packs and once I finally figured out how to resolve my problem (with my brother's help) and get SP1 installed (because I was offline and no longer had SP2 downloaded), Windows refuses to boot. It gets to the "Windows was not properly shut down" screen where I can choose Safe Mode, Last Known Good, etc and none work -- all cause an immediate reboot. There's a BSOD for a fraction of a second, not long enough to read. I'm actually not too concerned about this, since I'm sure I can get things working again with a boot disk. I haven't even looked for one yet because I've been so busy with linux stuff.

On to that -- I had to fight tooth and nail to get get a new version of glib installed on onyx. I had 1.2.10 and 2.2.2 installed, and gtkpod (linux ipod software; supposedly works with the Shuffle) required gtk+ 2.4 or better. Well, gtk+ required glib 2.4 and pango and atk, but glib had to be installed before pango and atk.... etc. It was a big mess of software, and none of it installed right on first attempt. The problem was that the default install location when building glib from source is /usr/local, but my original Slackware installation came with glib installed to /usr. So even though glib installed just fine, gtkpod and the other programs kept giving errors that my glib was out of date, because they were finding the original glib in /usr. I tried to change where pkg-config looked for glib which fooled most of the ./configures but wouldn't actually work. I also tried to screw with my /etc/ld.so.conf, my $LD_LIBRARY_PATH, etc. Nothing worked, and I couldn't at first figure out why. Finally I randomly realized what was happening, 'make uninstall'ed and 'make clean'ed all the attempted installs and tried again with ./configure --prefix=/usr and it all worked.

...to no avail with gtkpod. Oh, it configured, made, and installed, but because the iPod isn't formatted yet gtkpod doesn't know where to put/how to store songs on it so I can play them. At least the program can see the Shuffle and move files to it. I'm optimistic that once I (FINALLY!) format it, I'll be able to use the iPod Shuffle with linux.

I thought that once I gave up on the iPod for a while I'd be done fscking with glib. This wasn't the case. In a bit of downtime this morning while I was waiting on ethereal to recompile (more on that later), I hacked the xmms source to add a function I've always wanted. Back in the day when Napster was young and desirable (not like now...), I used WinAmp for all my mp3 playing needs. WinAmp had a feature where you could press "Ctrl + V" which would stop playback at the end of the current track. I used to use it all the time (eg) as I was leaving my apartment so I wouldn't have to kill it midsong but I wouldn't have to leave it playing the whole time I was gone or modify my playlist manually. But xmms didn't (before now) have that capability.

Ctrl + V is already bound in xmms, to Visualizations. But Shift + V isn't -- in the source it's commented out but it's supposed to be a 'stop with fade' function. I spent half an hour or so in the source (input.c, input.h, main.c, playlist.c, and plugin.h) and added the "stopnext" capability. I modeled it mostly on the input_pause() function and variables. I had to add a variable to InputPluginData which I wanted to avoid, but it's the Best Way of doing what I want to do. I suppose I could use a thread and sleep for the rest of the current track or wait for the next track to play(), but I don't know how to code that really at all. So this should work.

I went to compile it and got a fscking glib error, saying it needs glib 1.2.2 or newer. I have 1.2.10 and 2.4.8, but in all my hacking around I hosed or buried my glib 1.2.10. I've been too busy with IAX and ethereal all day to try to sort it out. Perhaps tomorrow...

Besides my half-hour jaunt into xmms-land (which was interesting -- all the "real" C I've read has been Mark Spencer's, and this wasn't. I definitely noticed differences in coding styles.), today was an IAX day. I re-configured all 3 of my machines (sigma, onyx, wrt) to each have 2 unique IAX friends -- the other 2 machines. Before I had the same iax username:password for all 3 machines, and that just wasn't working. I couldn't tell who was doing what easily. So now onyx registers to sigma as onyx-sigma:ospass and to wrt as onyx-wrt:owpass, sigma registers to onyx as sigma-onyx:sopass and to wrt as sigma-wrt:swpass, and wrt registers as wrt-onyx:wopass and wrt-sigma:wspass. This makes my life far easier.

I have some funniness going on with the wrt. It doesn't register or allow registrations from either sigma or onyx. Not sure what that's about, as other traffic (web, ssh, icmp) works fine. I looked at the openwrt documentation I have cached on onyx and finally figured out how to permanently configure the essid (I was embarrassed to ever be running an access point with an essid of "linksys"). So now it's one everyone at school would recognize. : ) I think the registration difficulties may result from the preconfigured firewall on the wrt, which I haven't yet analyzed. I'll get there.

I now feel I've got a pretty good handle on the basics of IAX implementation. I looked at several ethereal dumps of IAX calls and noticed right away that the ethereal dissectors are quite out of date. After all, they are almost 6 months old -- that's an eternity in asterisk-land. : ) They're actually so out of date that ethereal-0.10.8 segfaults on me whenever I try to look at an IAX2 packet of type NEW. None of the other packets I looked at caused segfaults, but not all of them were right. About 25 Information Elements (IEs) are new since July 2004, when the dissector was written. And several of them are now basic to any IAX call. I first noticed that ethereal was misreporting the IE for the HANGUP packet, saying it was unknown when it should have specified what the CAUSECODE was. The old method of reporting the hangup cause was as a string in IE_CAUSE; nowadays there's a lookup list in include/asterisk/causes.h and IE_CAUSECODE is used. So I hacked ethereal's dissector (packet-iax2.c and .h) to include the causes list in the header and to handle it appropriately in the code. I was pretty excited when it worked on my first attempt -- again, this was working in non-markster code and it was harder for me to parse.

Later on I went back through and added code for all the "new" information elements. There are several of them that I have never seen in use and I didn't know what possible values would be for the ones of type string, so the updated dissector isn't as fleshed out as it could be. But it at least reports all the IEs I see properly. I'm going to look online when next I can to see if there's a newer version of ethereal, and if it includes a newer iax2 dissector. If it doesn't, perhaps I'll submit what I have for inclusion in the next release.

I'll definitely submit it if I can fix the segfault when parsing NEW packets. I used gdb for the first time tonight to try to debug ethereal to locate the segfault. I found it at once after I figured out how to invoke and run gdb. I'm impressed by this program -- I wish I would have started using it sooner.

I fired up ethereal in -X (hex + ascii) mode and literally hand parsed a few NEW packets to see in practice instead of in code what IEs they contain. That was a worthwhile and educational exercise. In just the half hour or so I was doing that I got to the point where I no longer had to reference notes or configs to read exactly what each packet said. I never thought I'd actually be able to "read" packets so quickly.

I had decided last night that the best use of my time in learning IAX right now would be to shift from just reading code to watching calls on the wire (or air, as the case may be) and diagramming each step of call setup, registration, etc. I got an email from BC this morning saying that he wanted someone to help him create IAX call flow diagrams -- exactly what I had started working on 12 hours previously. So I spent a few hours today making a thorough and pretty (for ASCII...) CFD for an IAX setup. It's not quite as generic as I'd like it to be because I include the specific authentication packets I use, which aren't the only possible ones. But that's easily changed, when I get around to it. I also made a complete iax registration CFD. Both will hopefully be online soon.

***Later...

I got ethereal to parse and display NEW packets without segfaulting, merely by commenting some AST_DATAFORMAT stuff in packet-iax2.c. There's no such thing as AST_DATAFORMAT anymore so I don't think I'm breaking anything by doing this.

Tuesday, February 15, 2005

02 10 2005, Thursday

This was written on 02 10 2005, but not posted until 02 15 2005.

Thus begins my first (likely of many) off-line blogging attempt. I'm on sigma in my dorm room in Charleston.

I just got back from the computer lab here where I caught up on bugs and list posts. I already feel like I'm falling behind on asterisk current events because I can't check for updates more than once a day. : /

I'm continuing to try to setup a VOIP solution for a friend studying abroad in England. She is enthralled by the idea of calling her family (in the same town as my college and the production asterisk server I have access to) over the Internet without having to pay the expensive inter national telephone rates. I think she's all setup now. I have her using iaxcomm 1.0 (or maybe .99pre11, if she didn't download the new release when I told her to) and dialing into the asterisk server at school. She has her own iax user and password, and the user's context field in the dialplan is such that she can only dial local calls on the Zap channels. I feel it's a pretty solid setup for her. Though I just now thought of something -- the dialplan only matches the dialout key followed by the local exchanges. It would be a simple matter to enable a "4-digit dial" setup for her by just prepending the dialout/exchange numbers to her input (I expect all the numbers she dials to be on just one exchange). While I'm at it, I could also add lines to properly handle the case when someone dials the area code before the 7 digit phone number, which it currently won't process.

She has yet to make a successful call to the PSTN through iaxcomm. I've spoken with her via iax, but in TN where packet loss made my call quality unuseable. Today she couldn't get it to work because she was dialing the wrong number. A miscommunication between us made her think she had to dial "1 digit dialout + 3 digit exchange + 3 digit exchange + 4 digit rest of number" (she was dialing the exchange twice). It was an honest mistake, since she's new to dialplans and asterisk in general. I think it's hard for people at first to accept that they can dial the same exact "phone number" from a VOIP system to connect to a PSTN phone line. Anyway, the call passed on the Zap channel to the PSTN when she was dialing before was "exchange + exchange + last 4" (I forget what the last 4 digits of a phone number is called). She was getting a "call disconnected by remote" error, which was probably occurring after the PSTN hung up on her. For fun I dialed that same number on my cell tonight on the walk back from the computer lab (first prepending the area code in my case, so I would essentially be dialing the "same number"). I got an automated telco recording saying, "The number or code you've dialed is incorrect. Please check the number or code and try again. Message 266 7." The system said this twice and then hung up on me. I can't be certain if the disconnect she was notified of occurred after this message was played or right after the Zap channel was created. I don't think she heard any audio (eg from the telco recording) but I'm not positive of that. I also don't remember how long the CDR said her call attempts lasted (the recording is 30 seconds long). I wish I could watch the CLI as she made one of these calls!!

Out of curiosity I also dialed "area code + 3 digit exchange + 3 digit exchange + 1st digit of last 4" to make a completely valid 10 digit call. I don't know enough about public telephony to know how extra digits are processed -- was my first call sent to this number with the extra d igits passed to the callee, or did the telco recognize that my dialstring was too long and immediately go to an error recording? After this test, I'm guessing the latter: I got ahold of a real person when dialing the "exch + exch + 1" number. I apologized for dialing a wrong number and hung up. So I know the recording wasn't reached because the "root number" was out of service. Interesting stuff. It's way funner to play with this stuff hands on before looking up the mechanics of it all online. I'm sure I could have googled to find out how a typical telco treats this case, but it's cooler to just try it and see. : )

I thought of an interesting question Capouch could pose to his students currently studying voip. The dialplan on the asterisk server at SJC is configured such that pretty much any voip phone can dial out to the PSTN using the Zap hardware in the machine. Blake (or Tony, or someone) has a VRU setup so that on the non-voip Audix phone network on campus, anyone can dial a particular extension and get into the asterisk server to dial on the voip network. With the addition of a single line in the appropriate context, I could allow an Audix caller into the voiop network to be able to dial out via Zap onto the PSTN. With me so far? Now what if an Audix user dialed the VOIP network and then dialed out on the Zap line... back to the college's PSTN number into the audix line? One could dial from audix to voip to pstn to audix to voip... making a circle. For how many iterations could the circle run? (I know, but don't want to say yet because I think this is a good question for a class to see if they can reason it out. Not that anyone from that class likely reads this...). As a variation, one wouldn't have to use the localout PSTN to do this...really any point of egress from our asterisk server (fwd, sixtel, nufone, etc) to the world could call back in. But using zaptel and the local PSTN is free. : )

I wonder what call quality would be like if one called (eg) from audix->SJC voip->fwd->SJC audix->SJC voip->sixtel->SJC audix->SJC voip->nufone->SJC audix->SJC voip->Zap localout->SJC audix. That would certainly be an interesting way to generate lots of load on one server. And I wonder how changing codecs would affect the whole setup (eg, if sixtel is configured for gsm but fwd and nufone are configured for ilbc there are already 2 translations being done on the audio). I'd love to try this and watch the CLI while doing so!!

Alright, enough dialplan fun.

I started browsing the iax channel driver last night and decided after 30 minutes or so that I really need to have more of a handle on the ast_frame struct and functions before getting too deep into iax. So that's now next on the agenda.

I've begun making a list of words I think should be included in an 'asterisk glossary'. I haven't found the wiki very effective in defining asterisk terms and instead of one at a time trying to add my own definitions of words to it, I hope to write a glossary of some of the terms I find most important. I'm coming at it from more of a developer (or at least administrator) point of view than a user POV. IE, I'm including words like trunk, bridge, frame, etc. that aren't of interest to an everyday user of asterisk. I think this is something that would be useful to the community, so I hope I don't get too sidetracked from it. It may also be helpful for BC's textbook, though that's a question for down the road that is independent of the original idea I had.

I found 2 tiny typos/bugs in channel.c today, from working in the CLI. The function `help show channeltypes` returns the usage string for the function, and the string doesn't end with a newline. "registered" is also spelled "registred". Tiny tiny fixes, but perhaps another opportunity for me to say "Hey! Look at me!" and show people that I'm actively working with asterisk source. I'll patch it the next time I'm online. I could write it now, but I'd have to then worry about moving files around and re-diff'ing with updated CVS to get proper line numbers, etc. I'll just `cvs co asterisk` on "my" machine at school and write it then. The whole process should take just a few minutes.

In other news, I'm really excited about google's new mapping capability. It's quite impressive, and seems easier to use than mapquest. I read part of a slashdot article tonight about someone's analysis of how it works, which was interesting. I also had fun with it myself, asking it to map "hell" for me. I wasn't aware of it, but apparently hell is somewhere near the Kansas/Oklahoma border. Who knew? : )

Tuesday, February 08, 2005

02 08 2005, Tuesday

Subtitle: Eww. Windows.

I'm back in Charleston. I've figured out a way to get my machines connected to the Internet here, but I don't think I'm technically supposed to. I haven't asked because I don't want to hear "no". Plausible deniability, anybody? Anyway, I don't *need* them on for much of anything, so I'm not at that much of a loss. Once a week getting new asterisk CVS should suffice for awhile.

What's new?

I got my toys. The iPod Shuffle won't format on my WinXP laptop, which may be because it has a low-power low-speed USB port. I've ordered a USB 2.0 PC card from eBay which will hopefully fix the problem. Otherwise the Shuffle's going back to Apple.

I also got the WRT Capouch/Blake sent. It's cool, but there isn't a whole lot I can really do with it. I don't have any hardphones and only onyx has a working soundcard (and can thus use a softphone). So I can really only make calls to the builtin asterisk demo context or using channel type local. Neither of those are all that exciting. But still... it's something. : )

I got my "new" battery for onyx. It charged just fine but I haven't had a chance to take it off AC and see how long the battery lasts yet. I expect it to last a lot longer in Linux now than my last battery did because I have ACPI (more or less) working. At least, the components are all there. I don't have any alarm events set because I haven't learned the syntax yet. But if nothing else I could write a trivial perl script in 2 minutes to check the state of the battery and if it's lower than X to step the processor down. No worries.

I finished reading through ~/asterisk/include/asterisk/channel.h which is mostly implemented by ~/asterisk/channel.c. I wouldn't say I 100% understand the ins and outs of every single function, but I definitely get the gist of all of it. I can say with some confidence that I understand how a channel works now. Reading code like that is fun because it affords numerous opportunities for new insights. I believe I'll be moving on to chan_iax2.c next, though I haven't decided for sure.

Yesterday I called Sprint to have them activate the Vision service on my Samsung A500 phone. It's free for 2 months then $15 a month after. I don't consider that cheap, but for what it allows me to do I decided it's worth it. I already have gmail configured to auto-forward a copy of all mail to my Sprint PCS email address. So I can read any email sent to kshumard@gmail.com more or less instantly on my cell phone. Pretty sweet.

Today I explored online to find information about my phone. I found some really cool things. First I found an old forum page with random posts about my phone, and some links. From there I found another site that gives some of the non-disclosed functions of the phone, eg error reports, browser info, and something called the 'field service menu'. That site also tells how to make the phone enter 'test mode' to try various phone functions. Perhaps the coolest, though, is the menu which displays the phone's actual public IP address. Unsurprisingly, it's not pingable. WHOIS tells me the address is Sprint owned and traceroute stops reporting 5 hops after the DNS entries include "sprintlink.net". Cool!! Something I'm curious about is if all Sprint phones have a unique IP or if NATting or other fancy network stuff allows multiple phones to have the same IPs. I expect each phone gets its own, otherwise they'd use private IPs. But why don't they use private address space anyway? Maybe I should call and harrass Sprint tech support to see if I can get anything out of them. : )

With a bit further research, I see that what I'm looking at on the phone isn't *my* IP address -- it's the address of the NGG or Next Generation Gateway. It's apparently the standard one, as many posts on cell phone forums online list the same IP I have. I still wonder why it's not a private address, though.

One final interesting tidbit on the phone is that I can access the 'vocoder set' menu. It tells me that the current setting is 13K, but I can't change that without a 'service code' (password). I guess I've been curious in the back of my mind what codec(s) cell phones use to move voice... I've never bothered to actually look. Turns out the 'GSM' for 'Global System for Mobile communication' of cell phones is the same as the GSM codec I'm used to using in asterisk. Cool! I found a useful link of gsm information. Also very helpful in learning more about how cell phones work was the howstuffworks.com cell phone article.

So if I'm currently using GSM on my cell phone... I wonder if I could use speex or ilbc or some other codec? I wonder what other codecs are pre-installed. ??

I'm off to play with asterisk some more.

Friday, February 04, 2005

02 03 2005, Thursday

When abbreviated to 2 digits each, today's date is the sequence of the first 3 prime numbers.

Same story as the last few days: more progress in channel.c, but not a whole lot and not much else. I should be able to do a lot tomorrow because I'll be in a car for 8 hours and sigma's laptop will hold out for quite awhile.

I listed that skydiving rig on eBay for mom.

I suspended the mailing of (digium) list digests to my gmail since it sends probably ~30 *digests* a day and that would be absolutely too much to handle after more than a day or two off of email. I stayed on -cvs since its output is less frequent (really it's -users that is so verbose) and more directly applicable to my endeavors.

I got new CVS on both sigma and asterisk late tonight, since it's the last time I'll be able to get it for quite some time. I've been trying to figure out if there's an easy way to run CVS to a floppy that contains a list of the files/versions of my release, download the updated files to the floppy, and carry the floppy back to my off-net machines and patch that way. I don't think it's very feasible, unforch.

I downloaded about 25 .ipk packages for the wrt, and another current CVS snapshot. BC says I only need (or he only uses) about 6 packages but they're all small so I got anything I could find that sounded mildly interesting or applicable.

I got back from work today to find a random personal email from a CLEC in California looking to employ an asterisk/VOIP guru. They got my email from google hitting my blog. I was pretty excited to be approached cold about a job. I responded explaining my AmeriCorps commitments and forwarding a current copy of my resume.

Shortly after that I read the 20+ asterisk list mails that had accumulated throughout the day, and found that the same company posted the job to the list. It sounds like they'll need a full-time on-site type person, so it's not really possible for me right now. But it's still cool to have been "found" for my abilities. : )

I exported my bookmarks and saved them to some webspace I have. I also put my resume up on a website.

I was being an idiot about my C switch/case/break question the other day. BC reminded me that you actually don't have to break a case at all; in fact a clever use of the language can be used to have multiple cases true. The break in the particular line of code I looked at is what Capouch calls "defensive programming" -- in case the return is ever changed to something else, the coder doesn't have to remember to add the break because it's already there.

I won't be posting regularly for a while. It's been fun while it's lasted..... we'll see what the future holds.

Thursday, February 03, 2005

02 02 2005, Wednesday

I built 2 kernels today to get ACPI running on onyx. The first worked, but with everything as a module. And I somehow still didn't have the right (orinoco_cs) driver built. It should all work now, with shiny new kernel acpi plus orinoco_cs features. I haven't tested it yet cuz I just haven't gotten around to rebooting yet.

I did some product research on eBay because a friend of my mother's wants me to sell his skydiving gear for him. I wrote up the listing and sent it to her to run it by him and offer advice/input on it before I actually list it.

My Shuffle is waiting for me in Charleston. Hopefully we'll get back Friday in time for me to get it then. Otherwise I might have to wait til Monday (Nooooo!!!!!). : ) Value on eBay has already come down. I *may* be able to get $200 out of it, but that's not a large enough profit margin for it to be worth it to me. So I'll play with it and if I don't like it I can still sell it and prolly get 100% of my cash back.

Since I built this 2.6 kernel a couple weeks ago to use my mouse as a native USB device (previously I was using a PS/2-USB adapter), my cursor "dances" on the screen sometimes. Or I'm tripping.

Either gaim or aim now fail on me about once an hour. Maybe it's this network and it's awful connection, or maybe it's a bug in gaim somewhere. I suspect the network, but I dunno.

People are talking about overhauling voicemail in asterisk again. I'll believe it when I see it -- people have been talking for a long time about it. But I'm also a little bitter because I know how awesome that functionality would be, and it was posted as a "new feature" -- and when it's opened it's just a dialog about how to do it. Nobody's done it yet. Oh well.

I went through more channel stuff today. Learning more and more as I go... again I didn't have much time to work on it and didn't make any really amazing leaps. No worries, though.

I had an idea for a (relatively) simple asterisk documentation effort that would have lots of value -- a glossary. There are many terms in asterisk that are either just not straightforward at all or that on the surface may *seem* straightforward but really aren't. And even the straightforward terms could be included. Definitely I would included "channel", "frame", "native bridge", "trunk", "masquerade", etc on there.

I helped Chris at SJC set up his IAXy today. That was really cool -- I've never played with an IAXy but I was able to guide him through the installation and configuration process for it on his wrt -- which I've also never laid eyes on. I got him up and running with relatively few problems. He can't do much useful yet because he has a fresh dialplan and doesn't know how to configure it, but I couldn't afford to spend more time helping him with that tonight. Kinda cool that had he been a "customer" I contracted with, I could have made $100-$200 tonight. : )

I'm now downloading a bunch of .ipk files for the wrt before I go to bed.

~K

Tuesday, February 01, 2005

02 01 2005, Tuesday

Not much at all to report today. I did more reading of channel.c, but I didn't have a whole lot of time to play so I only got through another 5 or 10 functions. I'm getting there, though.

I'm spending more and more time browsing ("processing" is closer) asterisk list mail. Not sure if that's good or bad, considering the time I have online, the sheer volume of mail, and how little of it actually applies/means anything to me.

I played a little bit this evening with a forum system Blake setup. I'm too fried from work today to focus on coding or anything.

Oh, I did find something this morning I'd like to try out. Some website I found through google has a different festival voice than the standard ones you can download from the festival developers. I wanna give it a shot eventually, but I'm not sure I'll get the chance before I'm "dark" (offnet) again. : /

*** Later ...

So apparently I'm not going to bed as early as I had hoped/intended. Oh well -- I found some cool stuff.

Skype released versions for MacOS and linux today. I've downloaded but not installed; I doubt I'll be able to use it here but it may be nice to have. You never know. It's just a binary, not open source. Not surprising, but I'm still disappointed.

I checked out that linke I have above for more festival voices. It referred me to festvox.org, where you can hear speech synthesized by several different voices. You get to input the speech, too.

The voices I liked best were bdl_arctic_hts and slt_arctic_hts. I haven't installed either yet, but I downloaded them and maybe I'll get to play tomorrow. These voices sound much better than what I have; they're far less robotic-sounding.

I googled for power management when running linux on a Presario 700 (onyx). I've never used apm or acpi on this machine because there has traditionally been no/poor support for it. 2.6 is supposed to be better; I'll recompile a kernel before I go dark (hopefully!!) and see how it works. I don't have any links; google turned up what I needed while I was on a windows computer so I didn't bother saving them. I can regoogle them.

I wrote a simple C program tonight to test something I've been wondering about. At some point (perhaps ast_answer) of channel.c, there's a switch statement with an interesting bit of code. One of the cases has a break; statement immediately following a return statement. Obviously the break statement will never be reached, so I wasn't sure why it was there. My guess was that whiny/stupid compilers required every case: to end with a break; statement, even if they have another terminating command. So I coded a simple program to see. I won't tell you what I found, do it yourself if you want to know. Or ask me. But I won't spoil it for anyone truly curious.

I will say that I still hold my theory that whiny or stupid compilers require it. The gcc version on the machine I compiled on is 3.3.4. Behavior was the same when compiled with gcc 3.2.3.

~K