End-to-end... and everything in between
Dan McDonald's Sun blog, covering IPsec, general networking goodness, and other stuff too.

Thursday June 18, 2009
Endian-independence -- NOT just for kernel hackers
Yesterday on Facebook, OpenSolaris community member Stephen Lau said:
thought i was done caring about endianness when i left kernel programming... oops
I quickly replied:
You put bits on a {network,disk} that transcend architectures, you worry about byte-order.
I've often wondered why people with apps for Solaris on SPARC are often concerned about getting it to work on Solaris for x86 and vice-versa. Seeing Stephen equate byte-order-sensitivity to kernel-hacking suddenly made me realize the problem: byte-order sensitivity is everyone's problem.
Any time your program puts a multi-byte value in a network packet, or a disk block, it is highly likely another program on a different byte-order platform will attempt to read that packet or disk block. Never mind the historical holy wars about byte-order, even today, there are enough different platforms that run both big and little-endian byte orders out there.
It's really not tough to write endian-independent code. The first thing you need to decide is how to encode your disk/network data. Most Internet apps use a canonical format (which is big-endian for things in RFCs). There have been some schemes to have a universally-encoded format (XDR or ASN.1), but these can often be big-and-bulky. OS research in the early 90s proposed a scheme of "receiver makes right", where a producer tags the whole data with an encoding scheme, and it is then up to the receiver to normalize the data to its native representation.
Regardless of encoding scheme, if you are reading data from network or disk, the first step is to normalize the data. Different architectures have different aids to help here. x86 has bswap instructions to swap big endian to x86-native little endian. SPARC has an alternate space identifier load instruction. A predefine alternate space (0x88) is the little-endian space, which means if you utter "lduwa [address-reg] 0x88, [dst-reg]" the word pointed to by [address-reg] will be swapped into [dst-reg]. The sun4u version of MD5 exploits this instruction to overcome MD5's little-endian bias, for example. Compilers and system header files should provide the higher-level abstractions for these operations, for example the hton{s,l,ll}() functions that Internet apps often use. After manipulating data, encoding should follow the same steps as decoding. Also, in some cases (e.g. TCP or UDP port numbers), the number can often just be used without manipulation
Some have called for compiler writers to step up and provide clean language-level abstractions for byte-ordering. I'm no language lawyer, but I've heard the next revision of Standard C may include endian keywords:
/*
* Imagine a UDP header with language support!
*/
typedef struct udph_s {
big uint16_t uh_sport; /* Source port */
big uint16_t uh_dport; /* Destination port */
big uint16_t uh_ulen; /* Datagram length */
big uint16_t uh_sum; /* Checksum */
} udph_t;
Today, these fields need htons() or ntohs() calls wrapping references to them. Of course, there would be a lot of (otherwise correctly-written) existing code that would need to be rewritten, but such a type-enforced scheme would reduce errors.
Finally, one other cause of non-portable code is doing stupid tricks based on how multi-byte integers are stored. For example, on little-endian boxes:
/* This won't work on big-endian boxes. */
uint32_t value = 3;
uint32_t *ptr32 = &value;
uint8_t *ptr8 = (uint8_t *)&value;
assert(value == *ptr8); /* Barfs on big-endian... */
People micro-optimize based on such behavior, which limits such code to little-endian platforms only. A compiler can exploit the native platform's representation to make such optimizations redundant, and any compiler guys in the half-dozen readers can correct or confirm my assertion.
(2009-06-18 10:52:45.0)
Permalink

Tuesday February 03, 2009
Dear Santa... Steve... Tim Cook - A 64GB iPhone, please? Waiting for three test boxes to install never helps one's concentration.
So tell me -- when are flash chips going to shrink small enough to allow a 64GB iPhone? Yes, I said it: "64GB iPhone." Not, "64GB iPod Touch," but, "64GB iPhone." I understand that the Touch has two slots for flash, where as the iPhone only has one (the Phone chips take up the Touch's other slot space). But quite honestly, I own a working phone (RAZRv3c, GSM) and a half-full 80GB iPod, and would jump at the opportunity to reduce these two devices into one. It's probably just a matter of time (and money, at least initially), but since... yep, all three machines are still installing, I'm going to vent to the half-dozen or so readers.
And while I'm at it, perhaps any iPhone fan{,atic}s in the audience can confirm or deny:
- With the advent of the App Store, is there a working voice-dial app that I can use with an existing (cheap Motorola) bluetooth headset? Preferably where I only need to touch said headset and shout to make a call?
- How painful are rolling your own ringtones?
- (For Bonus points)Is there an non-jailbreak way of getting a terminal program running?
I suspect the answers are, "Sorta", "Annoying-but-doable", and "Yeah, right", respectively. I've done a little googling already, but the more clues I have, the merrier.
Any clues are, as always, welcome. Looks like one of those test boxes is finishing up. Time for test setup...
(2009-02-03 14:17:11.0)
Permalink

Sunday May 18, 2008
How to rescue data from an iBook with thermal problems My wife Wendy has had her iBook G4 for not-quite four years now. We had to return it once before via AppleCare due to thermal problems. Well, the thermal problems are back, and this time, there's no AppleCare for us to invoke. I managed to get the machine to behave itself only after leaving it powered off for a bit, but then it would lock again. I'd heard stories about putting computers in refrigerators to keep them cool enough to run. I never thought I'd try it myself.
We do, however, have a freezer in the basement. So check this out:
I managed to get Wendy's home-directory off, and that's what mattered. I'm heading off to the Apple Store to get a new MacBook (thank goodness for the just-arrived George-and-Nancy "Will you be my friend with this stimulus?" check). I hope to do the frozen data transfer one more time to bootstrap the new MacBook.
(2008-05-18 06:54:44.0)
Permalink

Monday April 21, 2008
Can't let this one slip by I'm not sure if this picture represents extreme stupidity in the protestor, or if it's merely a clever use of Photoshop to make a joke. If the latter, it's pretty funny. If the former... I have NO idea what to say.
Thanks to Fake Steve Jobs for bringing this to my attention.
BTW, for folks who need a quick history lesson - click here and follow your favorite search hit.
(2008-04-21 10:13:54.0)
Permalink

Monday March 03, 2008
Kebe's Home Data Center (or f''(Bart's new home server)) A little over a year ago, Bart Smaalders blogged about his new home server. Subsequently Bill built a similarly-configured one. (I thought that he had blogged about his too, but he hadn't.)
I'd been toying with the idea of following in Bill's and Bart's footsteps for some time. A recent influx allowed me to upgrade lots of home technology (including a new Penryn-powered MacBook Pro), and finally allowed me to build out what I like to think of as my home data center. I mention f''(Bart's...) because this box really is the second-derivative of Bart's original box (with Bill's being the first-derivative).
And the starting lineup for this box is:
- An AMD Opteron Model 185 - I was lucky enough to stumble across one of these. 2 cores of 2.6GHz AMD64 goodness.
- A Tyan S2866 - I bought the one with two Ethernet ports - one nVidia (nge) and one Broadcom (bge). It has audio too, but I haven't tested it as I've my Macs for such things. It has all of the goodies Bart mentioned, but I *think* that the SATA might be native now. (Please comment if you know.)
- 2GB ECC RAM - with room for two more if need be.
- A two-port old Intel Pro Ethernet 10/100 - good thing the driver (iprb) for this is now open-source. I'll explain why I need four Ethernet ports in a bit.
- Two Western Digitial "green" 750GB SATA drives Each drive has 32GB root partitions (yes that's large, until Indiana matures, though, I'll stick with UFS roots), 4 GB swap (for core dumps), and the remaining large areas combine to make one mirrored ZFS pool with ~700 decimal GB of storage.
- A cheap MSI nVidia 8400GS - It's more than enough to drive my 1920x1200 display.
- An overkill Antec 850W power supply - obtained for only $100 from the carcass of CompUSA.
- A Lian Li U60 case - My brother-in-law, who has years in the trenches of PC care, feeding, and repair, recommended Lian Li to me. It has all the space I need and more for drives, and its fan layout is pretty comprehensive. Since this box lives in my office, noise isn't that much of an issue.
- OpenSolaris build 83 - While I'm pumped about what's going on with Indiana it's still under development, and I want something a bit more stable.
So why four ethernet ports (covering three drivers)? Well, like Indiana, Crossbow is exciting, but not yet integrated into the main OpenSolaris tree. I do, however, very much like the idea of Virtual Network Machines and I'll be using these four ports to build three such machines on this server using prerequisite-to-Crossbow IP Instances. Two ports will form the router zone. The router will also be a firewall, and maybe an IPsec remote-access server too. With Tunnel Reform in place, I can let my or my wife's notebook Macs access our internal home network from any location. One port will be the public web server, and assuming Comcast doesn't screw things up too badly on their business-class install, the new home of www.kebe.com. The last port will be the internal-server and global-zone/administrative station. All of that ZFS space needs to be accessible from somewhere, right?
I'd like to thank Bart and Bill for the hardware inspiration, and to my friends in OpenSolaris networking for offering up something I can exploit immediately to create my three machines in one OpenSolaris install. I'll keep y'all informed about how things are going.
(2008-03-03 08:21:22.0)
Permalink

Wednesday September 26, 2007
Go Blue! Recruiting at Michigan (day 2) Oh my am I exhausted! I hoped to have most of the text of this completed
before my flight got back to Manchester last night, but that didn't happen.
I keep telling people I know that Michigan is a hardware school (in spite of
having some great software people - see my post from Monday). We
Solaris developers at the Sun table were brutally reminded of this yesterday.
Lots of EE's with Verilog and/or VHDL experience. Many of them asking about
architecture and/or verification, but a surprising number who have never
heard of SPARC, the UltraSPARC T1
(aka. Niagara), or that they can see the entire source for the Niagara with
OpenSPARC. Almost every business card of mine I handed out to
folks had the word, "OpenSPARC" on the back so they could Google it later.
We also tried to make sure everyone had OpenSolaris disks. There are four
binary distributions of OpenSolaris on that set of disks: Solaris Express Community Edition (see the previous link) - Sun's current OpenSolaris vehicle, Nexenta - which is probably going to be one of the more comfortable ones for Ubuntu Linux users to land in, Belenix - which is optimized for Live CD use, and Schillix, which was the first non-Sun distribution of OpenSolaris, by Joerg Schilling of "cdrecord" fame. I hope
some of the students went home and had success playing with OpenSolaris. You
all should visit opensolaris.org and
engage the community discussions with your feedback and questions.
I mentioned Monday about how much like a geezer I felt. I had more of
that yesterday not only saying, "Class of '91" a few times, but also when Professor Quentin Stout visited our table. My only
graduate-level class I took at U. of M. was his Parallel Algorithms class in
the fall of 1990 (during Football/Marching Band season). Back in the day
it was all theory - we discussed how to partition problems using the abstract
PRAM (Parallel Random Access Machine). It was the ONLY parallel
ANYTHING class offered when I had an available slot. This was when
shared-memory multiprocessors were experiments or startups (anyone remember
the BBN Butterfly, the Sequent Balance, or the Encore Multimax?). I
mentioned to Prof. Stout I took his class back then. He then proceeded to
tell me how the class is far more practical now. He told me all about stuff
like OpenMP, and other high-level constructs that as a systems' programmer I
just don't get to use all that much. I still, however, felt pretty smart for
seeing the future back in 1990. I hope I have as good luck 17 years later.
Anyway, I had a great time in Ann Arbor, and I hope to get back there sooner rather than later. If anyone who visited our table is reading this, leave a comment, and don't be afraid to be honest. :)
(2007-09-26 10:51:38.0)
Permalink

Monday September 24, 2007
Go Blue! Recruiting at Michigan (day 1) I mentioned I was going to be at the University of Michigan's Engineering career fair, and here I am!
I got in yesterday (Sunday) afternoon, and did some things to re-orient myself. I visited my fraternity house first, and
quickly, because rush began that night. In some ways things hadn't changed a
bit - the house is still there and the rooms have the same names (my old room with a skylight window is still called Lighthouse). In other ways, they had - the TV is bigger and flatter, half of 'em had laptops, and the basement was being seriously renovated. The guys were pretty mellow, probably because
of all of the post-beating-of-Penn-State celebrations. I then wandered around
campus, eating dinner at Krazy Jim's Blimpyburger, where they give you
burgers made of small, ground-that-day, patties. Yum!
When I flew in, the woman next to me on the plane explained the phenomenon
she experienced when taking one of her kids to her alma mater. It all felt
intimately familiar to her, even modulo some new buildings, but then she
suddenly realized she was an old fart wandering campus. My kids aren't old
enough to be shopping colleges yet, but I definitely felt the combination of
familiarity and age. I saw buildings with new names, old names on new buildings, and just plain new buildings (esp. at North Campus). 20 years ago I was a freshman, now I'm literally old enough to be a father to a student in the incoming class of 2011.
This morning, I tagged along with Kais
Belgaied as he visted some Computer Science faculty and grad students
here. Our first visit was with Professor Z. Morley Mao, who's a new professor here. She has a lot of great ideas on how to exploit the Crossbow
project for aiding intrusion detection (and mitigation), among other interesting ideas. We then talked to two other professors, Atul Prakash and Thomas Wenisch, and a few students as well. I remember Prof. Prakash from my time at Michigan (1987-1991), but the other two are new Assistant Professors. I'm confident from what I saw that U. of M.'s CSE division of EECS is going to be strong for a continuing number of years.
[Edit from Wednesday]Shoot! I forgot I also visited my old theory professor, Kevin Compton. He's a very good teacher, and helps even the most clueless undergrads (hem hem). He told me he's teaching a very popular undergraduate cryptography class, which is just too-cool, IMHO.
This evening several of us (Kais, Eric Kustarz, Bill and Sherry Moore, and I) gave a breezy tech talk about various goodies in OpenSolaris that we work on. We also had very yummy Pizza House pizza. Pizza House was "established 1986", which means it wasn't all that old when I was there, but it was good enough to have our host recommend it.
I'm now back in my hotel, squeezing packets over a flaky, but free, wifi. Tomorrow we will be spending the whole day at the table, taking resumes and answering questions. If one of you four readers of this blog is a U. of M. student, you don't have to wear a suit when visiting us. :)
(2007-09-24 18:40:21.0)
Permalink

Friday September 21, 2007
More ZFS Love - Rapid Recovery I recently scragged my laptop's primary root partition such that I needed to install-from-scratch again. I had a bootable secondary root, but since it was running an experimental BFUed build, this partition could not be upgraded.
Let's quickly look at how I configure my 100-decimal-GB laptop disk (&*%$% disk vendors):
- c0d0s0 --> Primary root, approx 8GB (and I mean GB the way software geeks mean it, 8 * 1024^3).
- c0d0s1 --> Secondary root, same size.
- c0d0s3 --> swap, 3GB, same as main memory size (useful for system dumps).
- c0d0s7 --> ZFS pool "tank", with 5 ZFS filesystems (tank, CSW, spro, local, and danmcd).
Before I shut it down for upgrade, I simply uttered this:
That's it!
Then I plugged in my laptop to a local netinstall network, and PXE-booted to a Nevada build 73 install (which includes detangled NAT-Traversal) and started it up. I used the old Solaris installer because I know how to tell it to preserve disk slices. I told it to preserver the secondary root and the zpool.
One install later, I get root, and to recover my miscellaneous backups, CSW software, compilers, local binaires, and home directory, I just did:
And again, that's it! All of my filesystems got mounted properly, no tables to edit, NOTHING.
I'll be at the University of Michigan Engineering Career Fair this coming Tuesday, and will be wandering campus on Monday. If you're one of the four people who read this blog and are there, drop by the Sun table - and see the very laptop I'm talking about. :)
(2007-09-21 11:39:31.0)
Permalink

Wednesday April 27, 2005
No hard-drive wipe needed for Solaris x64 support! Someone sent me this link about the new 64-bit Windows XP. There's some interesting text on that page I would like to quote here (assuming the link doesn't change...):
I can tell you with confidence that if you go from Solaris 9 on x86 to Solaris 10 with both x86 and x64, you will NOT have to erase your hard drive (assuming you've enough room for the new x64-native binaries, and you probably do already if you're in possession of an x64-capable box).
(2005-04-27 07:15:00.0)
Permalink

Tuesday November 30, 2004
Hello, world!
Welcome to my Sun blog. I was encouraged by certain people (who appear on my list of other Sun blogs) to set up one of these, and so I have.
The title of this blog comes from one of the fundamental principles of the Internet architecture -- The End to End Argument. Anyone who claims to do networking for a living should at least know about this paper, if not be able to explain it to you. Basically, the end to end argument states that only the application(s) at the two endpoints of communication know exactly what's going on. The network should not get involved, unless it can provide a useful performance enhancement.
That's all for now. I will be back as time permits. Thanks!
(2004-11-30 07:57:29.0)
Permalink
|
Calendar
| « October 2009 | | Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|
| | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | | | | Today |
RSS Feeds
All
/Entertainment
/IPsec
/Miscellany
/Networking
Search
Links
Navigation
Referers
Today's Page Hits: 81
|