tag:blogger.com,1999:blog-346207582013-12-02T15:06:03.242-08:00Fun Of MathJohn Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.comBlogger35125tag:blogger.com,1999:blog-34620758.post-59260428878741782142013-12-02T15:06:00.001-08:002013-12-02T15:06:03.250-08:00This blog has moved<br /> This blog is now located at http://funofmathblog.blogspot.com/.<br /> You will be automatically redirected in 30 seconds, or you may click <a href='http://funofmathblog.blogspot.com/'>here</a>.<br /><br /> For feed subscribers, please update your feed subscriptions to<br /> http://funofmathblog.blogspot.com/feeds/posts/default.<br /> John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-79443875156250763412009-01-31T12:35:00.000-08:002009-01-31T12:55:29.096-08:00DD-WRT for Airlink101 AR430WThe <a href="http://www.dd-wrt.com/">DD-WRT</a> open source WiFi firmware works just great on the inexpensive---I have picked up a few of these routers for $15 on sale at Fry's---Airlink101 AR430W Wireless G router, but the <a href="http://www.dd-wrt.com/dd-wrtv2/downloads/v24-sp1/Consumer/Airlink%20101/AR430W/flashing.txt">standard instructions</a> for flashing the DD-WRT firmware are slightly incorrect. <a href="http://www.funofmath.com/AirLink101/AR430W/DD-WRT_AR430W_Flashing.txt">Here is a corrected version.</a>John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com2tag:blogger.com,1999:blog-34620758.post-64643102251232553522009-01-01T19:48:00.000-08:002009-01-01T20:28:07.777-08:00Simple Example of the Lenz EffectSomeone posted a <a href="http://www.reddit.com/r/science/comments/7mscy/video_of_a_couple_of_guys_tipping_over_a_block_of/">YouTube video</a> to Reddit Science of the <a href="http://en.wikipedia.org/wiki/Lenz%27s_law">Lenz effect (or Lenz's law)</a> on block of aluminum in an MRI machine that was intriguing. Since I do not have an MRI machine or any other superconducting magnets, I followed the advice of another poster that the effect is observable with hard drive magnets and sheet aluminum. It worked. The magnets are from a dead DeskStar hard drive that failed with the <a href="http://en.wikipedia.org/wiki/Click_of_death#Hard_disk">"click of death"</a>, and the aluminum strips are from a soda can. Contrast the way a piece of cardboard falls between the magnets with the way the aluminum strip falls through.<br /><br /><object width="560" height="345"><param name="movie" value="http://www.youtube.com/v/KndJDGnSmgQ&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/KndJDGnSmgQ&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="345"></embed></object><br /><br />Be sure to click on the video and then click the "watch in high quality" link below the video. It's much clearer.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1tag:blogger.com,1999:blog-34620758.post-33208651172859106992008-09-11T22:19:00.000-07:002008-09-11T22:28:35.939-07:00The (non)Partisan Truth<a href="http://www.factcheck.org">Factcheck.org</a> has fairly analyzed all of the popular claims by both major parties in this election and recent elections. Is Obama really against nuclear energy as McCain boldly proclaimed? <a href="http://www.factcheck.org/elections-2008/factchecking_mccain.html">Find out.</a> Is the picture of Sarah Palin in a bikini holding a rifle real? <a href="http://www.factcheck.org/askfactcheck/">No.</a><br /><br />Some partisan fun: <a href="http://vetmccain.com">vet McCain</a> and <a href="http://vetpalin.com">vet Palin</a> I suspect Factcheck.org does a better job of getting the full story.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1tag:blogger.com,1999:blog-34620758.post-44499251234072173542008-09-11T20:36:00.000-07:002008-09-11T22:18:58.155-07:00Faith in the ElectionWhile there is something to admire about each of the candidates in the Presidential race, and I am sure all four of them believe they are doing the right things for the right reasons since only comic book villains commit evil for its own sake<a href="#mitchell"><sup>1</sup></a>. I cannot find myself supporting a position based primarily on fear of our enemies and how we can overpower them. All of the candidates should subscribe to the notion that we should not repay evil with evil but overcome evil with good. I assume this because they all report to be Christians, and <a href="http://www.usccb.org/nab/bible/romans/romans12.htm#v21">Romans 12:21</a> is not controversial to my knowledge. It is not in the Gospels, but it does corroborate the admonitions against the use of power. I am pretty certain that "good" does not mean "good bombs", and if we want to be a shining beacon of goodness and power in the world, we have to give up our tendency to abuse that power. Our purpose is not the redemption of just ourselves but of those with whom we live, and our nation's purpose is not just the redemption of those fortunate to be protected as citizens but of those who despise us as well. This is the hallmark of the non-violent opposition. Evil must be overcome with good, and if the means are not good, the evil we fight will not be overcome but simply displaced. The result of that is either a never ending fight against ever more enemies or the conversion of ourselves into our own enemies.<br /><br />How can we overcome evil with good? First we have to know that good does not come from fear. Concern is not fear. Preparedness is not fear. Fear is the animal response that we must hold onto those things that are precious to us. As <a href="http://en.wikipedia.org/wiki/Litany_against_fear">Frank Herbert writes</a>, "Fear is the mind-killer." What I call faith is the alternative to fear. The only certitude needed for this faith is this: Be not afraid. The good comes from faith, hope, and charity. At first this looks like the fear<------->love continuum ridiculed in "Donnie Darko", but I am not talking about a solution to bed wetting. I am talking about the basic position from which we approach other people. What about power? If I relate to others by means of my power versus their power, is that not something other than fear or love? Maybe. What is the purpose of relating by my power against their power? Is it desire to hold onto what is precious to me? Does it let me love that person? Charitable love is giving rather than taking, but only to the extent that it is not done intentionally to build up my own power in some version of "enlightened self-interest." If faith, hope, and charity are to govern our relationships, then the use of power, which takes from others, is contrary to our ability to love---not just those like us, but also those of the wrong religion and those we consider our enemies.<br /><br />Overcoming evil with good requires us to give to our enemies, but what can we give them? We could give them money, but that is likely only to worsen the situation if we have not gotten past violence. What we must give them first is dignity. As human beings we are obligated to do that much. Calling them evil does as much good as flipping off a thunderstorm, and it does a lot of harm. They call us evil, too, and both of us get an ego boost of righteous indignation since we can each point to the horrible things that they have done to us, and they have, or at least somebody has, and we naturally like to reinforce our stereotypes, so we just stick to a simple "they". This indignation is the worst possible thing. I used to live on it though. I would think, "If only so-and-so would do this-and-that, we would not have this problem." "Thank goodness I am not like that wretch." Indignation leads to righteous anger, which I am told is the worst poison of the soul, and I believe that. Once I succumb to righteous anger, I can scapegoat anyone I want because everyone has done something wrong. I can cause trouble to anyone to "raise awareness" for my cause while saying "look what those people made me do (to you)". It is a huge self-deception, but we fall for it when we succumb. In order to give our enemies dignity, we have to give up our righteous anger and indignation. We have to act out of love rather than fear. To be the shining example, we act not because we expect them to repay us in kind(for even the tax collectors do that), but because it is the right thing to do.<br /><br />We have to give them faith, hope, and charity because that is the only way we can redeem them and redeem ourselves.<br /><br /><a name="mitchell">1.</a> Richard Mitchell, <a href="http://www.sourcetext.com/grammarian/gift-of-fire/index.html"><i>The Gift of Fire</i></a>. A wonderful book available free online though I much prefer reading it in book form.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-55354978672059656402008-05-17T14:49:00.000-07:002008-05-17T16:07:12.369-07:00Carolina Anoles<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2008/Anole3.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px;" src="http://www.funofmath.com/pics/2008/Anole3.jpg" border="0" alt="" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2008/Anole2.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px;" src="http://www.funofmath.com/pics/2008/Anole2.jpg" border="0" alt="" /></a><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2008/Anole1.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;width: 200px;" src="http://www.funofmath.com/pics/2008/Anole1.jpg" border="0" alt="" /></a><br />There are plenty of bugs in our yard providing enough food to support several anoles. My older brother used to have one of these as a pet "chameleon". Here's the best I could get holding my Olympus C700 a couple feet away from this Carolina anole, <a href="http://en.wikipedia.org/wiki/Carolina_Anole"><i>Anolis carolinensis</i></a>.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-55378173733575709262008-03-21T17:26:00.000-07:002008-03-25T06:49:01.235-07:00An Implementation of Pessimistic Locking with JPAI've worked with a Java application for several years that has relied upon pessimistic since before I was hired back in 1999. This was a time before Hibernate and certainly the newer Java Persistence Architecture. I have rewritten the data layer for some of our transactional processing a few times since then as the application changed from a dot-com to a B2B dot-com to a startup with a successful business, and now, to a department acquired by a large company. The data layer that existed when I joined was an <span style="font-style:italic;">interesting</span> XML object database stored in SQL Server 7. All who touched it will not forget the powerful lesson we learned, so I will not talk anymore of <span style="font-style:italic;">that</span> here. Actually I do need to mention that it used pessimistic locking for doing transaction processing on those XML clobs. That is the last mention of it. At some point we got a bit smarter and decided that we ought to be using our relational database to store records structured in tables defined by a schema.<br /><br />After moving to a more typical object-relational mapping in Java, our system still depended upon pessimistic locking to implement transaction processing. This was accomplished in SQL Server 7, and later SQL Server 2000, using REPEATABLE_READ isolation for read-only connections and READ COMMITTED isolation for read-write connections. In a read-only connection the REPEATABLE_READ isolation ensured that shared locks in the database were held for the duration of a database transaction. Read-write connections relied on doing an UPDATE on rows before reading them to get an exclusive lock that was held for the duration of the database transaction. This effectively allowed concurrent reads, but did not allow writes to be concurrent with reads or other writes. This provides consistent reading of a header object and its line items by locking the header row with a read-only shared lock (REPEATABLE READ and a SELECT) or an exclusive write lock (READ COMMITTED with an UPDATE). It worked, but it meant that locks are held on data that is only being read.<br /><br />SQL Server 2005 provides a feature called row level versioning that is similar to multiversion row concurrency (MVCC) in PostgreSQL and other databases. The SNAPSHOT isolation and READ COMMITTED isolation with row-level versioning are features of SQL Server 2005 that allow reading that does not take any locks. The SNAPSHOT isolation ensures that all of the data read in the transaction is unaffected by updates that occur during the read-only transaction. This means we do not need to take a read lock in REPEATABLE READ isolation in order to have consistency. When writing we still just need to do an UPDATE in order to get an exclusive lock on the database row.<br /><br />Microsoft has a lot of <a href="http://msdn2.microsoft.com/en-us/library/ms189050.aspx">information</a> on the row version concurrency new in SQL Server 2005. When reading in SNAPSHOT isolation the database reads "all data that was committed before the start of each transaction." Updates are a little more complex:<br /><blockquote>Uses row versions to select rows to update. Tries to acquire an exclusive lock on the actual data row to be modified, and if the data has been modified by another transaction, an update conflict occurs and the snapshot transaction is terminated.</blockquote> This is just what the we want. (In <a href="http://www.postgresql.org/docs/8.3/interactive/transaction-iso.html">PostgreSQL</a> the SERIALIZABLE isolation is nearly identical to SNAPSHOT isolation of SQL Server. The READ COMMITTED isolation of PostgreSQL is also nearly identical to that of SQL Server when the READ_COMMITTED_SNAPSHOT setting of SQL Server is turned on.) It may not be obvious even if you read the Microsoft link that this SNAPSHOT mode of SQL Server is server-side optimistic locking on the database server. The JPA specification (section 3.4.3) requires these behaviors of optimistic locking:<br /><blockquote><br />If transaction T1 calls lock(entity, LockModeType.READ) on a versioned object, the entity<br />manager must ensure that neither of the following phenomena can occur:<br /><ul><br /><li>P1 (Dirty read): Transaction T1 modifies a row. Another transaction T2 then reads that row and obtains the modified value, before T1 has committed or rolled back. Transaction T2 eventually commits successfully; it does not matter whether T1 commits or rolls back and whether it does so before or after T2 commits.</li><br /><li>P2 (Non-repeatable read): Transaction T1 reads a row. Another transaction T2 then modifies or deletes that row, before T1 has committed. Both transactions eventually commit successfully.</li><br /></ul><br /></blockquote><br />Now I shall explain pessimistic locking using these tools and the Java Persistence Architecture (JPA), which is really pretty simple. The JPA does not specify direct support for this. It has separate find() and lock() methods of the <a href="http://java.sun.com/javaee/5/docs/api/index.html?javax/persistence/EntityManager.html">EntityManager</a>. One could do this:<br /><pre>public Object findAndLock(EntityManager em, Class c, Object key) {<br /> Object e = em.find(c, key);<br /> em.lock(e);<br /> return e;<br />}</pre><br />This is pretty good, but it's only approximation of an atomic find-and-lock method. In a system with high concurrency, we <span style="font-style:italic;">will</span> encounter JPA OptimisticLockExceptions. Let us presume we have an application with a legacy data layer (not JPA) that has this high concurrency, and let us also presume that we cannot remove all of this concurrency. (Often I find the <a href="http://en.wikipedia.org/wiki/Serenity_Prayer">serenity prayer</a> is useful for constrained design.) The problem above is that the find() loads the row before we lock() it. If another thread also tries to find() and then lock(), only one can succeed, and the other will fail, either from the JPA locking rules defined in the JPA specification, or from the rules defined for SNAPSHOT isolation. The result of the failure is an exception, and the application code would have to retry the entire transaction, but that is one of the things we must accept we cannot change---not immediately anyway.<br /><br />There is something we can do to avoid this race condition. We just have to do the lock() first rather than find() first. The lock() method takes an entity as a parameter, but we have a way out of the catch-22 because the entity need not be read from the database yet. The <a href="http://java.sun.com/javaee/5/docs/api/javax/persistence/EntityManager.html#getReference(java.lang.Class,%20java.lang.Object)">EntityManager.getReference()</a> method gives us an object that looks like the entity we would get from find(), but the EntityManager.getReference() method can give us "an instance, whose state may be lazily fetched." So we use this code:<br /><pre>public Object findAndLock(EntityManager em, Class c, Object key) {<br /> Object e = em.getReference(c, key);<br /> em.lock(e);<br /> return e;<br />}</pre><br />The reference returned is a proxy instance created with <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/reflect/Proxy.html#newProxyInstance(java.lang.ClassLoader,%20java.lang.Class[],%20java.lang.reflect.InvocationHandler)">java.lang.reflect.Proxy.newProxyInstance()</a>. The proxy instance can return just the primary key from the entity reference that would have been passed to getReference(). That way the lock() method can get the entity key and lock the row for the entity without first loading it. This removes the race possibility and gives us true pessimistic locking.<br /><br />I hope that some JPA implementations will offer a solution for pessimistic locking without requiring special API extensions. This solution is one that I've implemented in my own partial JPA implementation, and it works very well. I have not used any other JPA implementations or even Hiberrnate, so there may be a better way to do this. I have only see references to changing the transaction isolation level, and I hope what I have written explains why that is not a solution.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com4tag:blogger.com,1999:blog-34620758.post-40391787383365052242008-02-13T13:04:00.000-08:002008-02-13T13:15:49.090-08:00Consider the SourceIt has been told to me many times. "Don't believe everything you read." Sometimes I still believe stuff that I simply should not. For instance, I've been trying to figure out why the javax.print.attribute.standard.MediaSize.findMedia() method starts doing strange stuff after my application has been running. According to the documentation for <a href="http://java.sun.com/j2se/1.5.0/docs/api/javax/print/attribute/standard/MediaSize.html#findMedia(float,%20float,%20int)">findMedia()</a>, it tries to find the best match of the "standard" media sizes:<br /><blockquote>The specified dimensions are used to locate a matching MediaSize instance from amongst all the standard MediaSize instances. If there is no exact match, the closest match is used.</blockquote><br />Indeed it seems to work when I try it, so I accept what I've read, until someone complains that the application starts failing to find the right media size. It seems that the definition of "standard MediaSize instances" changes after the application has been running for a while. I solve this by changing my code not to rely on MediaSize.findMedia(), and I'm happy that the bug is fixed, but what was really going on to cause the problem?<br /><br />Fortunately, Sun has always (or least as far as I can remember) released source code for the standard library of Java, and I as a Java developer of course have a copy of their source code installed on my system, so I can <a href="http://www.java2s.com/Open-Source/Java-Document/JDK-Core/print/javax/print/attribute/standard/MediaSize.java.htm">take a look at what my call to MediaSize.findMedia() is really doing</a>. The findMedia(float x, float y, int units) simply loops through a list of MediaSize entries, and looks for the one that is closest to the given dimensions. It then returns the "name" of the closest fit. Where this contradictions my assumptions is that the definition of "standard MediaSize instances" is the entire set of MediaSize instances <b>EVER INSTANTIATED</b>! This means that every time I call new MediaSize(x,y,units), I'm adding a new entry to the "standard" set of instances, and those do not have names on them, so findMedia(), which returns the name of the closest match, which start returning null, the name of one of my instances. Okay, now I know why my code was failing, but after looking at the code a bit more, I see a couple curious things. First I notice that the code was written by former C programmers because of the style. Then I notice that it's unnecessarily using some local variables of type double when it just needs float. Neither of these two things matter, but I notice such things.<br /><br />However, when I think about things a little more, I realize that the "standard" list of media sizes is a java.util.Vector that gets an entry for every instance of MediaSize ever made. This list is never, ever cleared, and that means it's a memory leak, and one that is encountered every time the users of the site do a particular task. It is a good thing that memory is cheap and that I do not create these things in a loop that would allocate a lot of them that never get garbage collected. It does mean that I need to remove all calls to instantiate MediaSize objects as part of a user initiated action.<br /><br />At least I feel I can can trust the source code.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-19126813742042730482008-02-12T05:44:00.000-08:002008-02-12T05:53:00.686-08:00War with IranWe need to get more oil, so we can build our military, so we can be more powerful, so we can get more oil, so we can build our military, so we can be more powerful. . .<br /><br />I don't have time to make a video like the old anti-cocaine public message.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1tag:blogger.com,1999:blog-34620758.post-35298417247282200212008-01-17T12:52:00.000-08:002008-01-17T13:13:53.366-08:00iPod touch and false assumptionsThis Monday my iPod touch arrived. It's pretty neat, but it's got a couple things that could be improved. First, it cannot be used as a USB disk, and accessing anything on it from Linux requires breaking the silly restrictions by exploiting a security bug in the older firmware. That's not so big, and I half expected that. Second the features on it are still pretty compelling. Missing features like Mail and Notes, already present on the iPhone, would surely be available soon since those applications already existed, and I was content to wait for them since nobody could conceivably charge for two dinky applications that were mysteriously missing. I assumed the delay was just for a little more quality assurance testing, and that may be part of what it was.<br /><br />However, when Apple announced that the applications obviously missing on the iPod touch would cost $20 for existing users to acquire, I just had to shake my head. This is my first Apple product, and already I know that I cannot expect Apple to "do the right thing" by its early adopters, which would be to provide the missing applications free of charge. Apple sent a marketting email:<br /><blockquote><br />On Jan 17, 2008 2:24 PM, Apple <News@insideapple.apple.com> wrote:<br /> The multi-touch iPod with Wi-Fi web browsing, music downloading, and stunning video just got even better. Find your location and everything around it with Maps. Get the best email you've ever seen on a handheld device. Check the weather. Pull up stock quotes. Jot down some notes. Make Web Clips from your favorite websites and place them anywhere on the new, customizable Home screen.</blockquote><br />I responded, though I doubt anyone there will read it:<br /><blockquote>Thank you for adding the new features to the iPod Touch.<br /><br />I am disappointed in the additional $20 cost for "missing" applications such as Mail and Notes for the iPod touch I bought just this week, and I am not planning to pay more for applications that I wrongly assumed were simply being held back for quality assurance testing since they have been provided free to iPhone customers. If you had not kept this information from your customers who were buying iPod touch, I would not feel tricked, but by witholding the fact that there would be a surcharge for applications that seem like they should have been present in the original release, you have shown that your eager customers have to take a back seat to immediate revenue, and keeping your position of power through private knowledge by letting us give you the benefit of the doubt is more important than promoting a community of happy customers. Apple products are very much about feeling a sense of pride of ownership, but that is quashed by making us feel like suckers.<br /><br />I hope you reconsider the $20 surcharge for the the iPod Touch software update for existing users.<br /><br />Sincerely,<br />John Paul</blockquote>John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-57492015852736869922008-01-06T13:24:00.000-08:002008-01-06T13:52:37.326-08:00Finding Darwin's GodKen Miller's book will probably be my next book to read. In the mean time, here's a YouTube video of a talk he gave: <a href="http://uk.youtube.com/watch?v=JVRsWAjvQSg">Ken Miller on Intelligent Design</a>. He is a Roman Catholic biologist who describes why Intelligent Design is not a scientific theory.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-16313240217472076272007-11-14T18:36:00.000-08:002007-11-14T18:53:39.530-08:00Why I won't stay with Virgin Mobile<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/weblog/uploaded_images/sslice-754823.jpg"><img style="float:right; margin:0 0 10px 10px;cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/uploaded_images/sslice-754819.jpg" border="0" alt="" /></a><br />I signed up with Virgin Mobile because a rarely use my cell phone, and paying $30 per month for my little bit of use was wasteful. I initially bought the SE-47 Slider phone, and with a data cable I added a few simple MIDI ring tones and some wallpapers images. When the antenna broke on my slider, I decided to shop for a replacement. Target has some, and I chose the Super Slice because it has a USB port, and I thought this would allow me to put the couple things on the phone that I want. I might even be able to add my contacts list without entering it on the phone.<br /><br />However, the UTStarcom Super Slice phone for Virgin Mobile has a USB port that is deliberately disabled, and I found this out only after I bought it. I never thought a manufacturer would be so inconsiderate as to deliberately disable the USB port, but I guess Virgin Mobile wants me to pay $2.49 for their ring tones, all of which are unappealing (kids these days!), so they feel they just cannot let me do what I want to do with my own phone since I would then not be paying them for ridiculous stuff like ring tones and fake calls from celebrities to impress my friends (really!). The device will appear momentarily on the USB bus before it is immediately disconnected. I can watch this happen in /var/log/syslog<br /><br /><pre><br />Nov 12 20:04:40 localhost kernel: [17444684.280000] usb 2-2: new full speed USB device using uhci_hcd and address 6<br />Nov 12 20:04:41 localhost kernel: [17444684.472000] cdc_acm 2-2:1.0: ttyACM0: USB ACM device<br />Nov 12 20:04:41 localhost kernel: [17444684.472000] usbcore: registered new driver cdc_acm<br />Nov 12 20:04:41 localhost kernel: [17444684.472000] drivers/usb/class/cdc-acm.c: v0.23:USB Abstract Control Model driver for USB modems and ISDN adapters<br />Nov 12 20:04:43 localhost kernel: [17444686.560000] usb 2-2: USB disconnect, address 6<br /></pre><br /><br /> and in /proc/bus/usb/devices (only momentarily)<br /><br /><pre><br />T: Bus=03 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0<br />D: Ver= 1.10 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1<br />P: Vendor=0d08 ProdID=0300 Rev= 0.00<br />S: Manufacturer=UTStarcom, Incorporated<br />S: Product=UTStarcom CDM1450<br />C:* #Ifs= 3 Cfg#= 1 Atr=a0 MxPwr=500mA<br />I: If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=01 Driver=cdc_acm<br />E: Ad=81(I) Atr=03(Int.) MxPS= 64 Ivl=32ms<br />I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm<br />E: Ad=82(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms<br />E: Ad=02(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms<br />I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)<br />E: Ad=84(I) Atr=02(Bulk) MxPS= 64 Ivl=0ms<br />E: Ad=04(O) Atr=02(Bulk) MxPS= 64 Ivl=0ms<br /></pre><br /><br />Searching for help on the Internet only confirms what I have experienced. The phone is deliberately disabled for some reason. Now I'm stuck with a phone that I don't really want because it is more trouble than I want to deal with by reentering all of my contacts, and it has no redeeming features because of its disability. <b>Target will not take back a phone that has been activated. Virgin mobile will not take back a phone purchased from Target unless the phone is defective and is being replaced with the same model.</b><br /><br />I suppose I will deal with the phone just long enough for me to validate that T-Mobile is what I want to use. GSM phones and SIM cards mean that I won't have to be locked into a single phone. My advice to you is not to buy the UTStarcom Super Slice for Virgin Mobile because it will just be an semi-expensive annoyance.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com3tag:blogger.com,1999:blog-34620758.post-79868514760432420662007-11-01T21:37:00.000-07:002007-11-03T17:15:20.545-07:00On Daddy's WatchMy child is sleeping now, but the evening was long. On the way home a clichéd advertisement sprang to mind. One dime swallowed by a two-year-old: ten cents. Visit to an ER for X-ray: $250. Sleeping, safe child, well, we all know the cliché. I was planning to post about something else tonight, but life intervenes.<br /><br />I learned tonight that the clinic near my house closes at 8:00 P.M, and I was thirty minutes too late. I learned that you can't get stitches on a wound if it has been more than eight hours since the injury due to an increased risk of infection. I learned, too late, that Urgent Care Plus, which is also nearby, closes at 9:00 P.M. We learned that lots of kids swallow objects, but even sharp objects are not as dangerous as disc and button batteries. I learned that the doctor in the ER wears exactly the same model of Seiko Kinetic watch I wear, and I learned that people can fracture their wrists in interesting and "unusual" ways trying to play follow-the-leader on their motorcycles.<br /><br />update: The dime's out.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1tag:blogger.com,1999:blog-34620758.post-74843552685513599112007-08-09T11:01:00.000-07:002007-08-09T12:24:13.430-07:00Update on Diet FoodsTime has published a new article, <a href="http://www.time.com/time/health/article/0,8599,1650860,00.html?T">"Do Diet Foods Lead to Weight Gain?"</a>, on an experiment using rats who are fed diet foods that is related to a <a href="http://www.webmd.com/diet/news/20050613/drink-more-diet-soda-gain-more-weight">previous story I linked</a> about diet sodas being linked to obesity. When rats ate diet foods and non-diet foods that tasted the same, this tricked their bodies into not being able to eat the right amount of food to get the calories they needed.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1tag:blogger.com,1999:blog-34620758.post-51669413152664586062007-07-02T08:23:00.000-07:002007-07-02T08:26:04.252-07:00Weblog feedsSometimes I notice a missing negative in a weblog post after I publish. What is worse is when Googlebot grabs the initial, incorrect version that doesn't present what I mean to write. Reader beware, or at least check the website if you think I've written some nonsense.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-9301442700881994522007-07-02T07:25:00.000-07:002007-07-02T17:28:43.033-07:00What I think science is notI read <a href="http://www.physorg.com/news102516861.html">this article</a>, which is about an interesting model of the universe before and after the Big Bang, or Big Bounce as is the case in the model, and then I read the comments. The comment below struck me as being from someone who does not understand the philosophy of science and who thinks "the scientific community" is supposed to come up with dogma that everyone is supposed to accept. I think it's an easy notion to hold only as long as one does not have a grasp that science should make theories based the evidence, and science is not about making determinations about the physical world from a lack of evidence. It reflects the same desire for certitude whose ridiculousness is exhibited in the "Creationism Museum" to the extent that one is willing even to contradict physical evidence to satisfy this desire: (image from <a href="http://arstechnica.com/articles/culture/ars-takes-a-field-trip-the-creation-museum.ars">ArsTechnica.com</a>)<br /><br /><img src="http://www.funofmath.com/pics/2007/startingpoints2-1_silly.jpg" alt="staring points"/> (I assume the Creationism Museum promoters prefer the simple arrow rather than the exaggerated, meandering path of empirical knowledge about the physical world which they apparently confound with human reason only on the "evolution" side and not with any regard to their understanding of "God's word". Whether by malice or ignorance, I think it is a mistake.)<br /><br />This is the comment:<br /><blockquote><br />The scientific community is going to have to make up its mind about 'the big bang' theory and black holes. It will have to determine which really exists: big bang, or black holes. As I see it, the two are mutually exclusive and cannot exist in the same universe. If, as postulated, a black hole's gravitational pull is so strong that nothing can escape it, not even light, then the big bang could not possibly have existed, as nothing would have been strong enough to escape it. If the big bang is true, then black holes cannot exist as currently postulated. So, science must make up its mind which one of these theories is valid and which must be discarded as being illogical.<br /></blockquote><br />While the universe may be one way or the other, it is not required that the scientific community declare it to be one way or the other at this point by "making up its mind" from a lack of conclusive evidence on the subject.<br /><br />When people hold such notions that science is supposed to provide these absolutes so that their own world-views are neatly packaged and free from uncertainty, it's easy to see why people rebel against what they mistakenly view as a failure of science when they are simply expecting science to be something it is not. There is clearly something, such as a certainty on which to anchor a worldview, many people are looking for, and directing them to science for that is a solution only as stable as the evidence that science uses, and that evidence is likely to change. Science has no problem with these changes, and science leaves gaps where the evidence is not conclusive, but an attempt to force the universe to obey one's myopic view of how the universe is and was and will be is highly quixotic, especially when playing with a God of the Gaps whose gaps are being filled.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-19445102859982501212007-06-08T11:54:00.000-07:002007-06-11T13:36:47.872-07:00Diet Soft Drinks Linked to Obesity<a href="http://www.webmd.com/diet/news/20050613/drink-more-diet-soda-gain-more-weight">As reported</a> from a study at the University of Texas Health Science Center in San Antonio, diet sodas are worse than regular sodas. I'm assuming so far that the "regular" sodas are sweetened with high fructose corn syrup, which has it's own metabolic issues, rather than sucrose cane sugar.<br /><br /><blockquote>In fact, when the researchers took a closer look at their data, they found that nearly all the obesity risk from soft drinks came from diet sodas.<br /><br />"There was a 41% increase in risk of being overweight for every can or bottle of diet soft drink a person consumes each day," Fowler says.</blockquote>John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com3tag:blogger.com,1999:blog-34620758.post-88074493958838557452007-06-08T06:07:00.000-07:002007-06-08T18:01:23.195-07:00Antibacterial Products Can Help Breed SuperdiseasesAccording to this <a href="http://www.sciam.com/article.cfm?articleid=024FEAE8-E7F2-99DF-323D8E02C4E48BF6">Scientific American article</a>, triclosan and chemicals like it help select for resistant bacteria because they have specific targets in bacteria that are shared by some antibiotics, and antibacterial products leave behind a weaker residue that contributes even more to resistance selection because it is not as effective at killing. Products like alcohol and bleach, on the other hand, evaporate leaving less residue, and they do nonspecific damage to the bacteria, so the risk of bacteria developing cross-resistance with antibiotics from traditional cleaners is less.<br /><br />We are harming ourselves and our children by continued, widespread use of antibacterial products by breeding more resistant forms of bacterial diseases and by the contamination of our crops, streams, food, and water with these products. If this is true, none it should really be surprising despite the SciAm article's title. It makes sense, and the concern has existed for several years.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com4tag:blogger.com,1999:blog-34620758.post-40036914061088047752007-05-26T15:43:00.000-07:002007-06-09T15:34:06.796-07:00BeesToday a swarm of bees came to visit over the front door of our house. Go away, bees!<br /><br /><a href="http://www.funofmath.com/pics/2007/bees_sm.jpg"><img src="http://www.funofmath.com/weblog/pics/2007/bees_small.jpg"/></a><br /><a href="http://www.funofmath.com/pics/2007/bees_001_sm.jpg"><img src="http://www.funofmath.com/weblog/pics/2007/bees_001_small.jpg"/></a><br /><a href="http://www.funofmath.com/pics/2007/bees_002_sm.jpg"><img src="http://www.funofmath.com/weblog/pics/2007/bees_002_small.jpg"/></a>John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com2tag:blogger.com,1999:blog-34620758.post-67756991240557141132007-05-26T09:32:00.000-07:002007-06-09T15:34:31.408-07:00Texas Giant Centipede<i>Scolopendra heros</i><br /><br />Texas giant centipede is the common name for it, and it is pretty big. We saw this one in the parking garage at work as we were returning from lunch yesterday. It was moving quickly, so my camera work is not so great.<br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_top_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_top_crop_small.jpg" border="0" alt="giant centipede from the top" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_sharp_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_sharp_crop_small.jpg" border="0" alt="giant centipede" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_around_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_around_crop_small.jpg" border="0" alt="giant centipede" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_shoe_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_shoe_crop_small.jpg" border="0" alt="giant centipede" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_edge_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_edge_crop_small.jpg" border="0" alt="giant centipede" /></a><br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/pics/2007/cent_down_crop.jpg"><img style="cursor:pointer; cursor:hand;" src="http://www.funofmath.com/weblog/pics/2007/cent_down_crop_small.jpg" border="0" alt="giant centipede" /></a><br /><br />There is some interesting <a href="http://www.dallaszooed.com/animalfacts/animalfacts.php?id=95&name=TUV&ci=2&li=8">info from the Dallas Zoo</a> about the sting from being bitten. It's not very dangerous to humans.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com3tag:blogger.com,1999:blog-34620758.post-44471973974359951162007-05-17T21:01:00.000-07:002007-05-17T21:18:12.781-07:00LamentHere's another interesting quote that seems to relate to the pictured prayer card in <a href="http://www.funofmath.com/weblog/2007/04/loss.html">"Loss"</a><br /><br /><a href="http://www.cacradicalgrace.org/resources/rg/2006/01_Jan-Mar/RGv19i1_RRohr_ComplainingToGod.pdf"><br />Richard Rohr writes</a><br /><blockquote>Walter Brueggemann, my favorite Scripture teacher, points out that about one third of the Psalms are psalms of “lament”, but they have been the least used by Catholic and Protestant liturgies. We think, perhaps, they express sinful anger or negativity, when grief and loss are actually something quite different. We think they make us appear weak, helpless, and vulnerable, and most of us don’t want to go there. We think, perhaps, they show a lack of faith, whereas they are probably the summit of faith. So we quickly resort to praise and thanksgiving, even when it is often dishonest emotion. We forget that Jesus called weeping a “blessed” state (Matthew 5:5). We forget that only one book of the Bible is named after an emotion: Jeremiah’s book of “Lamentation”.</blockquote>John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-37935603243238729892007-05-08T19:25:00.000-07:002007-05-10T14:19:58.098-07:00The Difference Between Premature Optimization and Negligent DesignComputer programmers have all heard the the <a href="http://www-cs-faculty.stanford.edu/~knuth/">Donald Knuth</a> quote (<i>ed.</i> paraphrasing something by <a href="http://en.wikipedia.org/wiki/C._A._R._Hoare">C.A.R. Hoare</a>) that "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." But just what constitutes "premature optimization" can be a subjective matter. Some coworkers and I were talking about this, and I think we mostly agreed on that point. First, what is "premature"? If I have implemented a similar solution ten times, and experience tells me that the current situation is the same as those, then I may choose to use the optimized implementation that I have used before. If I am a conscientious developer, this will not involve a cut-and-paste of the solution, but a call to an appropriate abstraction for this special case.<br /><br />Secondly, what is "optimization"? When designing code, good developers will use data structures and other abstractions that semantically fit the problem. This is not optimization; it is simply appropriate design. The opposite of good design is negligence. A good characterization of "optimization" comes <a href="http://en.wikipedia.org/wiki/Optimization_(computer_science)">from Wikipedia</a> (premature) optimization is "a situation where a programmer lets performance considerations affect the design of a piece of code." The design of the code can be quite low level in the above case.<br /><br />Here is a simple example of one clarification of the difference between premature optimization and good design. Let us assume that we wish to make a collection of unique objects, such as names of subscribers on ten mailing lists. Some people may be subscribed to more than one of the lists, but we wish to have just once instance of the person in the collection. The code in Java might look like this:<br /><pre>Set extractSubscribers(Collection<MailingList> mailingLists)<br />{<br /> Set<String> subscriberNames = new HashSet<String>();<br /><br /> for (MailingList mailingList : mailingLists) {<br /> for (Subscriber subscriber : mailingList.getSubscribers()) {<br /> subscriberNames.add(subscriber.getName());<br /> }<br /> }<br /> return subscriberNames;<br />}</pre>The HashSet is a <a href="http://en.wikipedia.org/wiki/Set_%28computer_science%29">Set</a>, which means that it enforces that each of the names it holds is unique. That is what we wanted, so the design of the code has clear semantics that match the functional requirement. I could have used a TreeSet in most situations, but that adds a requirement of total ordering on the data items, which I have, but that is not important right now. HashSet is nice because its lookup and insertion <a href="http://en.wikipedia.org/wiki/Computational_complexity_theory">complexity</a> is O(1), but that is also not too important right now.<br /><br />Now let us look at a less desirable approach. Today I came across this quote from a computer programmer.<blockquote>For most of my programming, I just use ArrayList or Vector and call Contains before inserting. It's lazy, but I've never had to deal with a big enough list to make it worth my time.</blockquote>I would imagine his code looks something like this:<br /><pre>Collection extractSubscribers(Collection<MailingList> mailingLists)<br />{<br /> Collection<String> subscriberNames = new ArrayList<String>();<br /><br /> for (MailingList mailingList : mailingLists) {<br /> for (Subscriber subscriber : mailingList.getSubscribers()) {<br /> if (!subscriberNames.contains(subscriber.getName())) {<br /> subscriberNames.add(subscriber.getName());<br /> }<br /> }<br /> }<br /> return subscriberNames;<br />}</pre>There is only one extra line of code in this case, but that is due to the fact that the ArrayList datatype holding our unique subscriber names does not have the semantics we want. It also means that we would have to write even more code to get the method signature to reflect the semantics of the requirements. If we wanted the return type to be Set, we would have to put all of the subscriber names in a set anyway, but I shall stipulate that <a href="http://en.wikipedia.org/wiki/Literate_programming">literate programming</a> is not important to the person making the quote above. However, it would make putting everything in an ArrayList first look pretty strange.<br /><br />The code in the second example loses some semantic meaning because the return type does not indicate that the names in the collection are unique, but it also is considerably slower than the code using a HashSet. Because the time complexity of the first example is O(n), and that of the second example is O(n^2), finding the unique set of subscriber names in the second example will be roughly 1000 times slower than for the first example when there are 1000 subscribers.<br /><br />This complexity issue may not seem important in the age of GigaHertz computing, but a coworker of mine found that the implementers of Apache Ant, a build system for Java, did not seem to appreciate this. The software I develop at my job results in about 15,000 Java class files, and those all have to be copied by an ant "copy" task in the build target directory. Ant 1.6 and ant 1.7 both build a list of unique file names to copy using a Vector (like an ArrayList) collection. In our build, this results in about 30 seconds to one minute of 100% CPU utilization on a 2GHz Core Duo! That is 25% to 40% of the total build time!<br /><br />Fortunately, Ant is an open source project, so changing the code to use a Set rather than a Vector is almost trivial, and we have done so for our own use. It makes the builds 25% in most cases. All of that CPU time is wasted because the code was written using a datatype that was not appropriate and was also not semantically correct. Optimization could now be done if we decided that the semantically correct code had performance issues. In our example, the HashSet does have more overhead than the ArrayList or Vector, but that overhead is nearly constant for each name, so the performance does not degrade horribly when the number of names increases. However, for small data sets the overhead per name, which is negligible in our example, could be measurably significant compared to the cost of adding each name to the collection. The HashSet has to get the hash code for each name and do some comparisons that take more time than simply setting the next element of an array, but for a good implementation of HashSet, this overhead is not meaningful, and when the number of names is small, the whole process runs quickly anyway. It is only large numbers of names that cause problems, and they cause much worse problems when the wrong design is chosen. Avoiding the overhead of HashSet is one of the "small efficiencies" that is meant by Knuth.<br /><br />Start with a correct design, and then optimize as needed, but do not mistake correct design for premature optimization.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-25549860081709286242007-04-11T21:22:00.000-07:002007-05-17T21:16:16.790-07:00Loss<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.funofmath.com/weblog/uploaded_images/Trials_small-785601.jpg"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="http://www.funofmath.com/weblog/uploaded_images/Trials_small-785594.jpg" alt="" border="0" /></a><br /><br />My father passed away last month. I wrote some thoughts down to remind myself how I was feeling: <blockquote>2007-03-23<br /><br />I feel that my father's death on March 18, 2007 has cheated him, me, my mother, my siblings, my child, and my siblings' children of a man who absolutely adored his grandchildren. I did not know where my relationship with my father stood when I told him he was going to be a grandparent, and I wanted my daughter to have him as a loving grandpa. Even though he had made several invitations to my wife and me that we had often accepted, I was completely unprepared for the avalanche of support he immediately sent to me when I told him we were having a child. He was smoking several turkeys for Thanksgiving to give to the many people with whom he shared his generosity, and he announced on the phone to me that he was going to send me a turkey that day! The delicious turkey arrived by express mail in a styrofoam cooler.<br /><br />When my daughter was born by an unplanned caesarean section delivery, he left Wichita Falls for Austin immediately to see his first grandchild and also Amanda and me.<br /><br />I do still feel that life's events have cheated us, but I believe that God works through those who surrender their will to God's to love one another as my larger family has done abundantly since my father's death. The edges around this sudden hole in my life are made softer by the love I have been able to give and receive over the last five days since his death. Our faith tells us to comfort one another and know that we are safe in our love and God's love despite the uncertainty of life to which we are acutely aware. Knowing how much love constantly is here for us overrides the uncertainties that are simply a matter of fact.<br /><br />I had been trying to express my feelings of being cheated, not by God, but by the event of my father's death when I looked up and saw a card that had been taped to his desk clearly for some time. On it was a beautiful summation of what I was feeling: "Trials are not enemies of faith but are opportunities to prove God's faithfulness."<br /><br />There is still so much for me to be thankful for and sad about. I feel as if my dad's life was taken from all of us too soon. We had recently reconciled after a decade of some estrangement, and I was so happy for the role he took upon himself to reconcile us, and I feel like someone showed me a beautiful thing only yank it from my grasp as soon as I held it. I am thankful for our reconciliation, but sad and angry that simple things such as finishing my deck he helped me build will now have to be done without him, and I'm still immeasurably thankful that he did get to come help me build the deck.<br /></blockquote>My dad's oldest brother found and bought several copies of the inspirational card pictured and gave one to me on Easter that I now keep in my wallet.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com0tag:blogger.com,1999:blog-34620758.post-48419311921725227782007-04-11T18:47:00.000-07:002009-11-12T11:59:53.297-08:00Starcraft and NATGetting Starcraft to work for two people behind NAT<br /><br />Update: Please see <a href="http://www.funofmath.com/weblog/2007/04/starcraft-and-nat.html#c6918243441123495699">Jonathan's comment for v 1.16.1</a> for an updated set of instructions.<br /><br />Ed. <i>The symptom that this solves is that when two people are behind the same NAT gateway, they experience lots of lag in the game, and may see high latency in the Battle.net game setup. We work around this by remapping port 6112 at the NAT gateway.</i><br /><br />This information is from Jan 18, 2007. (<a href="http://funofmath.com/starcraft/starcraft_nat.txt">original</a>)<br /><br />My friend Jason and I have been figuring out how to allow two people behind a single NAT gateway router to play Starcraft through Battle.net. Limited information is found through Google on this topic, and Blizzard offers no help. We each have Linksys WRT54G routers with alternate firmware that supports running iptables. (DD-WRT and HyperWRT Thibor + tofu)<br /><br />Having two people behind a single NAT gateway router connect to the same Battle.net game typically results in the appearance of lots of lag as the two clients do not communicate with each other. To get around this, the following iptables rules can be inserted on the NAT gateway or router.<br /><br />In this example 70.100.200.24 is the public IP address for the two people behind the NAT router. 192.168.1.2 is the IP address of one client machine, and 192.168.1.3 is the IP address of the other client machine. On the router, type these commands as root:<br /><br />(NOTE: Try using 6113 and 6114 instead of 63002 and 63003, respectively. The original rules are not working as of Starcraft version 1.16.1. I suspect that the clients outside the NAT no longer listen or respond to UDP messages on "invalid" ports such as 63002 or 63003. I hope Blizzard did not restrict all traffic to port 6112.)<br /><br /><span style=";font-family:courier new;font-size:85%;" >iptables -t nat -I PREROUTING -p udp -d 70.100.200.24 --dport 63002 -j DNAT --to-destination 192.168.1.2:6112<br />iptables -t nat -I POSTROUTING -p udp -s 192.168.1.2 --sport 6112 -j SNAT --to-source 70.100.200.24:63002<br />iptables -t nat -I PREROUTING -p udp -d 70.100.200.24 --dport 63003 -j DNAT --to-destination 192.168.1.3:6112<br />iptables -t nat -I POSTROUTING -p udp -s 192.168.1.3 --sport 6112 -j SNAT --to-source 70.100.200.24:63003<br /></span><br />The PREROUTING chain entries cause the packets to be sent to the Internet with port 63002 or 63003 rather than the standard port 6112 for Starcraft.<br /><br />The POSTROUTING chain entries cause the packets to be sent on the LAN. It's important to make sure these are the first rules in their chains. I've seen other instructions that use "-A" rather than "-I" to add the rules, and this does not work for me since there are already some global rules in the chains that will handle the packets. For example, the POSTROUTING chain has a MASQUERADE target for all packets. That causes the local packets to be sent to their destinations with a LAN source address, which will be dropped by the Starcraft client because it is expecting the source address on game packets to be the public IP address.<br /><br />These iptables rules will not allow one of the local machines to host the game. When we've tried that, some clients were unable to connect, so this is an issue still under some investigation. When we have time, we'll look at the Wireshark captures.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com42tag:blogger.com,1999:blog-34620758.post-87838886492837673872007-02-18T19:42:00.000-08:002007-02-18T19:55:49.533-08:00A Notable Quote<blockquote>Even in human life we have seen the passion to dominate, almost to digest, one's fellow; to make his whole intellectual and emotional life merely an extension of one's own---to hate one's hatreds and resent one's grievances and indulge one's egoism through him as well as through oneself. His own little store of passion must of course be suppressed to make room for ours. If he resists this suppression, he is being very selfish.<br /><br />On Earth this desire is often called "love." In Hell I feign that they recognise it as hunger.</blockquote>- C.S. Lewis from the 1960 preface to <i>The Screwtape Letters</i><br /><br />It really is too bad that we use just one word for love compared to the three that the Greek used. The above perverse possible definition of love contrasts with that in <a href="http://www.usccb.org/nab/bible/1corinthians/1corinthians13.htm">Paul's first letter to the Corinthians</a>.John Paulhttp://www.blogger.com/profile/03099984750605700968noreply@blogger.com1