All posts by admin

Looking at ns-3 packet traces

The ns-3 tutorial indicates that you can inspect the pcap files generated by simulations using two different tools: tcpdump and Wireshark (see section 5.3.2 Pcap Tracing).

Since tcpdump is a Unix tool that you’re most likely to find in your installation, let’s start there (tcpdump normally lives in /usr/sbin).  The tutorial recommends you to open your pcap files using the following command line:

 tcpdump -nn -tt -r filename.pcap

Where filename.pcap is obviously the name of a pcap file generated by some experiment. A quick look at the man page for tcpdump will tell you that the command line flags used above have the following meaning (quoted directly from Mac OS 10.5.8):

  • -n “Don’t convert addresses (i.e., host addresses, port numbers, etc.) to names.” This is the ideal choice in viewing simulation output because real world names won’t mean anything in the analysis of your experiment, where you address nodes by internal ns-3 identifiers or IP addresses. I haven’t been able to discover if there’s a difference between -nn and -n; both work the same way for me.
  • -r “Read packets from file (which was created with the -w option). Standard input is used if file is “-”.” Another obvious choice, since what you’re looking at is a packet trace that’s been recorded to a file.
  • -tt “Print an unformatted timestamp on each dump line.” The alternatives here are -t, which shows no timestamp on each line, or -ttt, which shows a time increment relative for the preceding line, or yet -tttt, which would precede timestamp by a date (the canonical Jan. 1st, 1970) that is meaningless to your experiment.

Bottom line: use the recommended flags. Running this on a pcap file generated by an ns-3 simulation would give you output such as:

1.008192 arp who-has (Broadcast) tell
1.016602 arp reply is-at 00:00:00:00:00:03
1.016602 IP > UDP, length 512
1.017515 IP > UDP, length 512

While tcpdump might suffice for many use cases, using Wireshark gives more detail through a very usable GUI. If you have it in your system, give it a spin, if not, it’s easily available for Windows and Unix systems (you can get binaries for Mac OS X >= 10.5.5, otherwise you need to use MacPorts). It’s a great application to capture packets on a live network, but also to analyze pre-recorded pcap traces. The added value in using Wireshark on ns-3 pcap traces is that you can inspect those nested protocol data units in all their glorious details. The screenshot provided here should give you a taste of it.

This is all fine and dandy, you say, but the question is: how can I make my simulation run generate a packet trace? The honest answer is that simulation runs don’t generate the pcap traces by default (remember that I/O has a performance cost?) At the same time, it’s nearly trivial to make it happen. Say that you have created an instance of a helper for the device in your network model. All you’d have to do is use this instance to call methods like EnablePcap or EnablePcapAll before starting the simulation run. For more details, you should check out the documentation for the ns3:PcapHelperForDevice class, which in inherited by the various device helper classes. If you want to see examples of code that enable pcap trace generation, change directory to the root of your ns-3 installation and run:

grep -r "EnablePcap" examples/

Pricing Strategy

The other day I wrote about being excited that there was good music to be had legally and fair prices from (Fair Enough). Yes, there are many good albums for $5 and less, which you can download instantly and that is the good news.

The not so great news is that’s pricing strategy doesn’t always make a whole lot of sense. For instance, today, August 17, 2010, two items cost you the same whether you purchase physical media or the download:

  • Vapor Trails, Rush –  $7.98
  • Counterparts, Rush – $9.98

And this is when their pricing strategy stops making sense to me. You can get free shipping for orders of $25 and above – that is, it’s free to you, but it costs someone money (in this case, Amazon, obviously). Why wouldn’t they factor their shipping expense out of the cost of the physical media? Perhaps they assume that most people will be stupid enough to not pad their orders to $25 so that they can get free shipping, or that most people will have bought Amazon Prime membership. That would drive people to opt for downloading at exactly the same price. (Well, they have the hard data to make a judgement, so I am quite possibly wrong here.) Not to mention that if you buy the media, you have to wait a few days to get your music, which is anathema to our entitlement and instant gratification culture.

My hypothesis is that they price media and download equally because they assume people would be more likely to buy single items this way. Perhaps this works wonderfully well in times of economic downturn.  Several hypotheses, no conclusion for me except that in a case like this, I’ll opt to buy the media, with the old fashioned paper insert and the physical sense of ownership. I may be in the minority, but the small wait doesn’t bother me at all. Amazon could have saved a couple of bucks in shipping and handling…

It’s even more interesting that as soon as I place the order for physical media, Amazon send me email to say that I earned $1 to apply toward the purchase of music downloads! This only adds to the nonsense that I had already observed and gets me more confused. I should have studied marketing or game theory.

As to why I’m buying four Rush albums in the same week (downloaded one at $5 and ordered a third CD that cost me $2 more than the download), that’s something to be discussed in another post.

Geeky Soundtrack for Coding Inspiration

If you don’t know this yet, geek and nerd mean very different things. I’ll let you do a web search and talk to your friends about it, but here are a few thoughts.

  1. By definition a nerd can’t be cool, but there’s no one to say that geeks can’t be cool. Actually, geeks are the coolest.
  2. Geeks don’t have to be anti-social, dress funny, or be the prey of bullies. They just are better at science, math, and technology than the average person.
  3. People are jealous of the geek’s skills and self-confidence. They try to hide it by saying “you are such a geek!”, particularly when the geek shows knowledge that trumps that of the first person.

But… enough about the nerd versus geek debate; let’s get this playlist started. I invite you to add to it!


  • Love and Mathematics, Broken Social Scene
  • Mathematics of Chaos, Killing Joke
  • My Mathematical Mind, Spoon
  • Music is Math, Boards of Canada
  • Black Math, The White Stripes
  • Any song by Math and Physics Club

Science and Technology

  • She Blinded Me with Science, Thomas Dolby
  • Anything from The Sounds of Science, The Beastie Boys
  • Natural Science, Rush
  • Weird Science, Oingo Boingo
  • Atom Dream, William Orbit
  • Anything from Better Living Through Chemistry, Fatboy Slim
  • Life is a Gas, from Electric Warrior, T.Rex
  • Life on Mars, David Bowie
  • Space Oddity, David Bowie
  • I Took a Trip on a Gemini Spaceship, David Bowie
  • Here on Earth, Love and Rockets
  • Holiday on the Moon, Love and Rockets
  • Time, Pink Floyd
  • Astronomy Domine, Pink Floyd
  • Chemistry Class, Elvis Costello & The Attractions
  • Rest My Chemistry, Interpol
  • Surrealchemist, Stereolab
  • President Gas, The Psychedelic Furs
  • I’ve Got a Miniature Secret Camera, Peter Murphy
  • Computerworld, Kraftwerk
  • It’s More Fun to Compute, Kraftwerk again
  • Computer Love, Kraftwerk one more time… (maybe they’re simply the geekiest band ever)
  • Future in Computer Hell, Junkie XL
  • Computer Blue, Prince
  • Paranoid Android,  or anything from OK Computer, Radiohead
  • Technologic, Daft Punk
  • Any song by Electronic
  • The Electric Co., U2
  • Ultraviolet, U2
  • Atmosphere, Joy Division
  • Invisible Sun, The Police
  • Body Electric, The Sisters of Mercy
  • Anything from Electric, The Cult
  • Electricityscape, The Strokes
  • Electrified, and anything else by Electric Boys
  • Electricity, Suede
  • Electricity, Spiritualized
  • Electric Alice, Grinderman (You know Alice the programming language, don’t you? This one scores double.)
  • Are Friends Electric?, Gary Numan
  • Electric Requiem, Queensrÿche
  • Electric Feel, MGMT
  • Electric Funeral, Black Sabbath
  • She’s Electric, Oasis
  • Radar Love, Golden Earring (although the Ministry version sounds better)
  • Shooting Star, Lou Reed
  • Atari Baby, Sigue Sigue Sputnik

Fair enough

Thinking back to 1992, the average price of a music CD was somewhere between $12 and $13. As time went on, prices rose steadily until they hit an average of $15 to $16, with individual discs costing about as much as three dollars more for those who didn’t known where to shop.

At some point in the 90s, the music industry was accused of having formed a cartel. I remember some federal investigation, some verdict or settlement, and even something about money being owned to customers, the color of which I never saw. And I had bought a lot of music for many years. Parenthesis: “Hi, I’m Luiz Felipe and I’m addicted to music and no, I don’t want to get into your 12 step program for that.” End of parenthesis.

In the meantime, both the Tower Records-types of stores (remember?) and the independent ones were starting to suffer with the advent of online businesses like CD Now (bought by and CD Universe. The competition was enough to give consumer a bit of a break in prices and I was moderately happy with the situation. (Truth be told, I’ve always been a bargain shopper and often raided bargain bins and used CD shelves with great success, so I rarely paid full retail prices).

Then, around the turn of the millennium, what followed was Napster, KaZaA, Emule, and other shady means of “acquisition” of music, but who would have wanted to risk their neck in an RIAA lawsuit? It turns out a lot of people did. It was easy, it was free, and only a small percentage of people were getting caught. There was much more to this “rush to download” than people trying to get away with stealing. People are mostly good, people have consciences (most of them), and most often, people want to do the right thing.

There were years of marked up prices, there was widespread belief that of the CD price only a small fraction was getting to the artists, there was a bit of a Robin Hood feeling of retribution going on. Teaching CSCI 240 Computers and Society, a class focused on computer ethics, I got to have many discussions with young people who said they didn’t feel that massive file sharing and music downloading equated to theft. Certainly a great point for in-class debate.

Young people are informed consumers. They know well that in the $17 they’d pay for a CD today (that is, if they were still buying that kind of media), only a small fraction would go to support the artists, pay for production and distribution costs, for the media, etc. Perhaps it is the sense of having been robbed in the first place what justifies them going after Prince John.

An indication that people would pay if charged a what was considered a “fair price” came with the .ru sites such as Mediaservices Inc.’s People could pay to download by the bit, not by the song, and not at iTunes’ $0.99 a song, but they were paying and that made consciences feel better than just downloading. There was a catch, though, as widely documented, which I quote here:

“Mediaservices argues that it is a legal company because it pays royalties to the Russian Organization for Multimedia and Digital Systems (ROMS) which is basically the Russian version of SoundExchange in the United States. The problem is that the major labels don’t recognize ROMS and have refused to accept any payment from the organization.” was shut down, but just like a zombie, it came back and seems to have multiplied. At the same time, the status quo has changed a lot and I feel that we have reached a point where excuses for not doing the right thing won’t cut it anymore. has been offering mp3 downloads are very fair prices, what has been bad for my addiction “problem” (if you can call being passionate for music a problem).

For instance, this weekend they sold me Arcade Fire’s “The Suburbs” at $3.99, which compared to iTunes’ $9.99 is a really great deal. That’s more than a 50% discount, if you’re lazy to do the math. MGMT’s “Oracular Spectacular” (which I loved) cost me $5.00 about two weeks ago. Amazon is showing that it is possible to sell digital music at fair prices by creating the right opportunities. The catch is that the special offers are fleeting opportunities and if you miss the boat, that might be it. While  I used to drive around to scavenge for the right CD bargains, I can reach the same result from my computer by visiting MP3 Special Deals once a week. You might not get exactly what you want, when you want it, and at the price you want it, but come on, tone down that sense of entitlement. If you want that cake and want to eat it too,  just pay the regular download price or go shop at a Virgin Megastore (I actually love them, but their prices are insane). Alternatively, you can be patient and money-savvy, and enjoy discovering great music in the over 1,000 titles that come around as special deals.

I recently bought some great music at fair enough prices from

  • Rodrigo Y Gabriela: 11:11
  • Paula Morelembaum: Berimbaum
  • Stan Getz: Jazz Samba Encore!
  • João Gilberto: Getz/Gilberto
  • Celso Fonseca: Natural
  • Arcade Fire: The Suburbs
  • Spoon: Ga Ga Ga Ga Ga, Gimme Fiction
  • MGMT: Oracular Spectacular

Fear of the big hammer

Power tools are dangerous. Be afraid of power tools. For instance “rm”, in a MacPorts installation is a power tool that can easily mutilate your set up.

I was annoyed at the amount of junk that got thrown into my system by a MacPorts install poorly done two years ago. So, I started removing packages (ports) here and there. At one point, Zeus knows why, I ended up at /opt/local/lib and noticed that I had a few “flavors” of libiconv. Like a n00b, I thought that the one with a number “2” in the file name was a file too many; maybe it had been left behind from the installation of a previous version. So, I did the unthinkable and “rm”-ed it.

It just so happened that that file was the newer version of the library, which was required by ns-3. What followed were almost two hours of irritation, as I tried to reinstall the libiconv port. It couldn’t be removed because of a large number of dependencies, so I tried “upgrade” and “build” and a few other port commands, but no luck: libiconv.2.dylib wasn’t being rebuilt. The next great idea I had was to try to remove all the dependents on libiconv, so that I could remove the library package and succeed at rebuilding from a fresh install. Considering that many of these dependents were involved in other long dependency chains, it turned out to be a bad proposition.

There was only one option left: the BIG hammer, the power-power-tool: do a port -f uninstall and assume that I could reinstall libiconv before any of its dependents would notice. The -f should scare any one once bitten. If I had been foolish enough to remove the libiconv.2.dylib in the broader of my Mac OS X installation, I’d gave gone up the proverbial creek. This was only MacPorts, though, so I thought it would be worth the risk. It was. I followed the uninstall with port clean libiconv, then with port install libiconv and voilà, I was back in business. ns-3 running happily again.

A post that was helpful in this venture can be found here – it taught me about otool(1) and reminded me of file(1), two commands that self-respecting hackers should keep in mind for the future. I have so much faith that this is good knowledge that I wrote this post out of selfishness first and foremost. Wanting to share it with you was only a side effect; sorry!

Not everything is as smooth as butter

I had a couple of freak out moments with the use of WordPress. I haven’t been able to discover what caused one of them and I’m a bit annoyed at the other (even though bugs happen and you have to deal.)

The first one was related to the database: all of a sudden, I ceased to be able to authenticate with phpMyAdmin, which I needed for making a backup. You see, when I started out, I grabbed just any old database for what I thought was going to be just a learning dry run. It turned out that I got too excited and developed the whole site using this old database. What happened next is that I had to move all that data to a production database. In all honesty, I don’t know who to blame for the problem: WordPress, phpMyAdmin, or yet some server set up. The fact is that I could authenticate successfully using mysql from the command line, but not through phpMyAdmin. I gave up on this for a while and move on with things only to discover two days later that things were working normally again. Hmmm…

The other issue had to do with permalinks. I changed the setting in the WordPress menu so that the site would use permalinks with full dates (including numerical day of the months). I use the awesome Atahualpa theme version 3.4.3, which I think was majorly unhappy with my spanking new WordPress 3.0.1. What happened next was befuddlement, as my entire site stopped loading giving me 403/404 errors. I went around checking folder permissions, poking around the web for help in discussion forums (ok, I know the correct plural is ‘fora’, don’t be a snob), but no dice. Gave up on everything after one hour of feeling stupid and watched a movie (Almodovar’s Broken Embraces, which I didn’t think was his best). Came back and opened the browser only to find the site up again! (Well, I guess it’s time to update my Atahualpa theme to a version that overcomes these incompatibilities with WP 3.0.1.)

Although I was happy to be in business again, I had to tweak a few things in my site. When the new permalink syntax took effect, I ended up with URL name clashes, which WordPress kindly ‘solved’ by appending integers to the conflicting file names (actually, directories in my site.)

And, I have yet to complete my swap of databases for this site, but I expect there will be data *in there* to update, so I’m getting instructed on the dangers before taking the leap.

I’m digging WordPress

This is the first site I’ve made with WordPress. In the past, I used straight HTML, HTML with CSS, Seamonkey (and its previous incarnations), iWeb, a little of Dreamweaver, and Ingeniux. All had their annoyances, some positives, but mostly, shortcomings.

My main gripe is that I don’t want to spend lots of time on crafting webpages (even though I love a spiffy page!) and also that I have low tolerance for buggy behavior. Since gold ol’ Bryan Ward pointed out WordPress to me, about three days ago, I’ve been impressed with WordPress as it solves my problems easily. I can use great looking themes, but I can also hack them if I need it and throw in custom code. Best of both worlds. And best of all, I can update my pages from a standard browser, even from my iPad sitting in an airport, if I must.

I took a quick look at Drupal and Joomla, but then system requirements for WordPress seemed to be less stringent. I gave it a try and in a few minutes, I was cooking up a nice site. This is definitely the way to go for me.

My next task is to hack my theme so that my pages cannot be viewed at all with Microsoft’s Internet Explorer (IE). Yes, I want to make exactly that kind of statement.