<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/d-e-v" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/d-e-v" type="application/rss+xml"></fs:self_link><lastBuildDate>Mon, 17 Mar 2008 05:27:25 GMT</lastBuildDate><title>D-E-V</title><link>http://dev.kenyth.name</link><language>en</language><pubDate>Mon, 17 Mar 2008 05:27:25 GMT</pubDate><item><title>env. preparation</title><link>http://dev.kenyth.name/2008/03/17/env-preparation/</link><content:encoded>&lt;p&gt;Keeping many tools at hand is very necessary:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows under Ubuntu via VirtualBox&lt;/li&gt;
&lt;li&gt;StarUML on Windows&lt;/li&gt;
&lt;li&gt;Wine for light wight windows executables (e.g., StarUML)&lt;/li&gt;
&lt;li&gt;Java &amp;amp; Web IDE and frameworks&lt;/li&gt;
&lt;li&gt;db server, web server &amp;amp; app server&lt;/li&gt;
&lt;li&gt;Project Planning Utilities: openproj &amp;amp; planner&lt;/li&gt;
&lt;li&gt;Project configuration tools&lt;/li&gt;
&lt;li&gt;Auto-build and release env.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Still needed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;free style drawing tool&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;During preparation, some tools did impress or even shock me a lot.&lt;/p&gt;
&lt;p&gt;VirtualBox is simple and small, only 20+M, but powerful, have better performance than VMware workstation. Most importantly, it&amp;#8217;s open sourced therefore totally free.&lt;/p&gt;
&lt;p&gt;VMware Server 2.0 beta is unbelievable and ambitious. Its web infrastructure access shocked me a lot, not only for management of vms (ajax) but also for vm console directly from web browser. Speaking of web browser based vm console, no java/flash/silverlight/AIR is used, but platform dependent implementation of browser plugin is used. Remote access to all of these conveys the ambition or even revolutionary of this product. Enterprise level (not only for big giants, but also for small and medium business) virtualization is just around the corner. It also gives us another picture about thin client and SaaS. Where&amp;#8217;s grid computing? I guess they may take the position of the underlying layer of virtualization and act as more a way for aggregating organization wide computing power than a way for providing charged public service. But wrt grid computing non-profit academic research has a different picture. We are really coming to an era of web and distributed system.&lt;/p&gt;
&lt;p&gt;Virtual or virtualization is really a beautiful word! But actually it&amp;#8217;s abstraction for coping with complexity.&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715610/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715610/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/03/17/env-preparation/feed/</wfw:commentRss><description>Keeping many tools at hand is very necessary:

Windows under Ubuntu via VirtualBox
StarUML on Windows
Wine for light wight windows executables (e.g., StarUML)
Java &amp;#38; Web IDE and frameworks
db server, web server &amp;#38; app server
Project Planning Utilities: openproj &amp;#38; planner
Project configuration tools
Auto-build and release env.

Still needed:

free style drawing tool

During preparation, some tools did impress or even shock me [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715610/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715610/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Uncategorized</category><category>virtualization</category><category>project</category><category>tools</category><pubDate>Mon, 17 Mar 2008 13:27:25 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/03/17/env-preparation/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/03/17/env-preparation/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/03/17/env-preparation/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715610/4990955</fs:itemid></item><item><title>JMX Study Notes</title><link>http://dev.kenyth.name/2008/03/10/jmx-study-notes/</link><content:encoded>&lt;h2&gt;1. Overview&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;J&lt;/strong&gt;ava &lt;strong&gt;M&lt;/strong&gt;anagement E&lt;strong&gt;X&lt;/strong&gt;tension, used to manage resources (applications, services, device, etc) within your JVM locally (in-box) or remotely (out-of-box).&lt;/p&gt;
&lt;p&gt;It is developed through JSR3 (JMX SPEC), JSR160 (extension for remote management).&lt;/p&gt;
&lt;h2&gt;2. Architecture&lt;/h2&gt;
&lt;p&gt;[MBean Server] Agent &amp;lt;&amp;#8212;-&amp;gt; connector (various protocols) &amp;lt;&amp;#8212;-&amp;gt;   management application&lt;br /&gt;
&lt;font color=&quot;#ffffff&quot;&gt; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;font color=&quot;#000000&quot;&gt;|&lt;/font&gt;&lt;/font&gt;&lt;br /&gt;
&lt;font color=&quot;#ffffff&quot;&gt;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&lt;/font&gt;\|/&lt;br /&gt;
[resources] MBean (instrumentation)&lt;br /&gt;
&lt;font color=&quot;#ffffff&quot;&gt; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;/font&gt;|&lt;br /&gt;
&lt;font color=&quot;#ffffff&quot;&gt; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-&lt;/font&gt;\|/&lt;br /&gt;
JVM (local or remote)&lt;/p&gt;
&lt;p&gt;MBean (Managed Java object, similar to JavaBean) is registered to the Agent, and resources are wrapped within MBeans, which is called instrumentation in JMX SPEC.&lt;/p&gt;
&lt;p&gt;Interfaces:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt; The management interface of an MBean consists of:&lt;/p&gt;
&lt;ul&gt;&lt;a title=&quot;wp998876&quot; name=&quot;wp998876&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Named and typed attributes that can be read and/or written&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998877&quot; name=&quot;wp998877&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Named and typed operations that can be invoked&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998878&quot; name=&quot;wp998878&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Typed notifications that can be emitted by the MBean&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt;MBeans can be instantiated and registered by:&lt;/p&gt;
&lt;ul&gt;&lt;a title=&quot;wp998826&quot; name=&quot;wp998826&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Another MBean&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998827&quot; name=&quot;wp998827&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;The agent itself&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998828&quot; name=&quot;wp998828&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;A remote management application&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;blockquote&gt;&lt;p&gt; The operations available on MBeans include:&lt;/p&gt;
&lt;ul&gt;&lt;a title=&quot;wp998813&quot; name=&quot;wp998813&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Discovering the management interface of MBeans&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998814&quot; name=&quot;wp998814&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Reading and writing their attribute values&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998815&quot; name=&quot;wp998815&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Performing operations defined by the MBeans&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998816&quot; name=&quot;wp998816&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Getting notifications emitted by MBeans&lt;/li&gt;
&lt;p&gt;&lt;a title=&quot;wp998817&quot; name=&quot;wp998817&quot;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;li&gt;Querying MBeans based on their object name or their attribute values&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Management applications do the management throw agent services that operates on MBeans.&lt;/p&gt;
&lt;h2&gt;3. Resources&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/j2se/1.5.0/docs/guide/jmx/&quot;&gt;Java Management Extensions (JMX)&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715611/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715611/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/03/10/jmx-study-notes/feed/</wfw:commentRss><description>1. Overview
Java Management EXtension, used to manage resources (applications, services, device, etc) within your JVM locally (in-box) or remotely (out-of-box).
It is developed through JSR3 (JMX SPEC), JSR160 (extension for remote management).
2. Architecture
[MBean Server] Agent &amp;#60;&amp;#8212;-&amp;#62; connector (various protocols) &amp;#60;&amp;#8212;-&amp;#62;   management application
 &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;
&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-\&amp;#124;/
[resources] MBean (instrumentation)
 &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&amp;#124;
 &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;-\&amp;#124;/
JVM (local or remote)
MBean (Managed Java object, similar [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715611/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715611/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>agent</category><category>jmx</category><category>Java</category><category>notes</category><category>javabean</category><pubDate>Mon, 10 Mar 2008 21:58:58 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/03/10/jmx-study-notes/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/03/10/jmx-study-notes/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/03/10/jmx-study-notes/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715611/4990955</fs:itemid></item><item><title>Java Troubleshooting Utilities</title><link>http://dev.kenyth.name/2008/03/09/java-troubleshooting-utilities/</link><content:encoded>&lt;h2&gt;jmap: prints memory statistics for a running jvm or core file&lt;/h2&gt;
&lt;p&gt;tips: use &lt;strong&gt;jps&lt;/strong&gt; to show java processes summary currently running on host machine.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;jmap -heap &amp;lt;pid&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;heap memory statistics&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;jmap -permstat &amp;lt;pid&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;permanent generation memory statistics&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;jmap -histo &amp;lt;pid&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is super useful. It displays number of instances of each class and memory size they occupy.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;jmap -dump:format=b,file=ConsoleInput.hprof &amp;lt;pid&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is a must use. It can dump the runtime jvm into a binary file in such a format called &lt;em&gt;hprof&lt;/em&gt; that another utility called &lt;strong&gt;jhat&lt;/strong&gt; can analize&lt;/p&gt;
&lt;h2&gt;jhat: java hotspot analysis tool&lt;/h2&gt;
&lt;p&gt;jhat takes the heap dump file produced by jmap as input, and starts a lightweight local web server so that you can visit and query the analysis results. I have to say the analysis results is very detailed.&lt;/p&gt;
&lt;p&gt;Just fire:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;jhat &amp;lt;dump_file_name&amp;gt;&lt;/p&gt;
&lt;p&gt;Reading from ConsoleInput.bin&amp;#8230;&lt;br /&gt;
Dump file created Sun Mar 09 00:59:15 CST 2008&lt;br /&gt;
Snapshot read, resolving&amp;#8230;&lt;br /&gt;
Resolving 5032 objects&amp;#8230;&lt;br /&gt;
Chasing references, expect 1 dots.&lt;br /&gt;
Eliminating duplicate references.&lt;br /&gt;
Snapshot resolved.&lt;br /&gt;
Started HTTP server on port 7000&lt;br /&gt;
Server is ready.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And I visit the results within my firefox at http://localhost:7000, it shows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;h2&gt;Package name.kenyth.hello&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://kell:7000/class/0x91149f98&quot;&gt;class name.kenyth.hello.ConsoleInput&lt;/a&gt;  [0&amp;#215;91149f98]&lt;/p&gt;
&lt;h2&gt;Other Queries&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/allClassesWithPlatform/&quot;&gt;All classes including platform&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/showRoots/&quot;&gt;Show all members of the rootset&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/showInstanceCounts/includePlatform/&quot;&gt;Show instance counts for all classes (including platform)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/showInstanceCounts/&quot;&gt;Show instance counts for all classes (excluding platform)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/histo/&quot;&gt;Show heap histogram&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/finalizerSummary/&quot;&gt;Show finalizer summary&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://kell:7000/oql/&quot;&gt;Execute Object Query Language (OQL) query&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can see you can query the results by writing your own OQL which is sql-style and therefore quite handy.&lt;/p&gt;
&lt;h2&gt;Others&lt;/h2&gt;
&lt;p&gt;Follow the link listed below, you can find even more.&lt;/p&gt;
&lt;h2&gt; Resources&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt; &lt;a href=&quot;http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf&quot;&gt;Troubleshooting and Diagnostic Guide&lt;/a&gt;. a good place to start investigating and experimenting.&lt;/li&gt;
&lt;/ol&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715612/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715612/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/03/09/java-troubleshooting-utilities/feed/</wfw:commentRss><description>jmap: prints memory statistics for a running jvm or core file
tips: use jps to show java processes summary currently running on host machine.
jmap -heap &amp;#60;pid&amp;#62;
heap memory statistics
jmap -permstat &amp;#60;pid&amp;#62;
permanent generation memory statistics
jmap -histo &amp;#60;pid&amp;#62;
This is super useful. It displays number of instances of each class and memory size they occupy.
jmap -dump:format=b,file=ConsoleInput.hprof &amp;#60;pid&amp;#62;
This is a must [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715612/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715612/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>utilities</category><category>troubeshoot</category><category>Java</category><category>notes</category><pubDate>Sun, 09 Mar 2008 01:38:09 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/03/09/java-troubleshooting-utilities/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/03/09/java-troubleshooting-utilities/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/03/09/java-troubleshooting-utilities/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715612/4990955</fs:itemid></item><item><title>JVM Structure Study Notes</title><link>http://dev.kenyth.name/2008/03/09/jvm-structure-study-notes/</link><content:encoded>&lt;h1&gt;1. Overview&lt;/h1&gt;
&lt;p&gt;Regardless of specific implementation, first take a look at what&amp;#8217;s described in &lt;a href=&quot;http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html&quot;&gt;JVM SPEC&lt;/a&gt;. And most of post is talking about server VM, however, where applicable you can reference for client VM.&lt;/p&gt;
&lt;p&gt;Given the assumption of having knowledge of conventional (from some point of view, Java itself may become a conventional language, so in this case it indicates those compiled language invented before Java)  compiled languages and compiler/linker/loader, it is very easy to understand the internal structure (more accurately, the structure of the JVM at runtime), and may be helpful to better understand conventional compiled languages.&lt;/p&gt;
&lt;h1&gt;2. Abstract Structural Element&lt;/h1&gt;
&lt;p&gt;This section is to give concepts of elements that consists the runtime jvm structure. They&amp;#8217;re supposed to be independent of specific data structure implementation. At the beginning of each element subsection, important properties are listed.&lt;/p&gt;
&lt;h3&gt;pc&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;private to each thread &lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;execution &lt;/em&gt;(which means it supports for the execution)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created when each thread is created&lt;br /&gt;
&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Program counter, which indicates the jvm instruction currently being executed. jvm can support many threads of execution at once and each jvm thread has its own pc. Unlike many conventional language, Java programming language is pure OO, which means no real global &amp;#8220;thing&amp;#8221; are allowed. Giving some thoughts on the execution of a java program for which the main &lt;strong&gt;method&lt;/strong&gt; is the entry in which the control may flow to &lt;strong&gt;constructor&lt;/strong&gt; of some class, static &lt;strong&gt;method&lt;/strong&gt; of some class, &lt;strong&gt;method&lt;/strong&gt; of some class instance, and so on, you&amp;#8217;ll quickly come to the conclusion, just as what&amp;#8217;s stated in JVM SPEC, that at any point in time each jvm thread is executing the code of a single method. For normal (&lt;em&gt;non-native&lt;/em&gt;) method, pc leads to the address the jvm instruction currently being executed, while for &lt;em&gt;native&lt;/em&gt; method, pc is undefined which means it is totally up to specific jvm implementor.&lt;/p&gt;
&lt;h3&gt;Method Area&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;shared by threads&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;program &lt;/em&gt;(which means it is the &amp;#8220;mapping&amp;#8221; of your program into jvm)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created at jvm start-up&lt;br /&gt;
&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Analogous to runtime structure of a program written in conventional language, a code area exists in jvm structure. In jvm, it is called a method area, though it doesn&amp;#8217;t only include code for method. It is &lt;strong&gt;shared&lt;/strong&gt; by all threads of execution in jvm. It can contain per-class structure such as runtime constant pool and code of class itself, field data and method data, method  (including constructor) code. In java terms, it contains the reflective data with regard to class and methods of a java program. This means as long as new classes (or in a special case, the interned string) are loaded, this area increases.&lt;/p&gt;
&lt;h3&gt;Constant Runtime Pool&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;private to each class&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;program&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created at compile time and &amp;#8220;mapped&amp;#8221; when each class is loaded&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;part of method area&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Refers to &lt;a href=&quot;http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#22972&quot;&gt;here (chapter 3, jvm spec)&lt;/a&gt; and &lt;a href=&quot;http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html#20080&quot;&gt;here (chapter 4, jvm spec)&lt;/a&gt; for more information.&lt;/p&gt;
&lt;h3&gt;Frames&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;private to each thread&lt;/em&gt; (or more specifically to each method, correct me)&lt;/li&gt;
&lt;li&gt;&lt;em&gt;execution&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created at method invocation&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;part of collection of frames&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Only with method area (the code understandable by jvm), the program is not alive, since method area is static, which means the size is fixed at compile time or load time. So just like &lt;em&gt;activation record&lt;/em&gt; with regard to conventional program, frames refer to the real execution of a program. Each thread of execution manages its own collection of frames that are not shared with other threads. This collection may itself be considered an abstract structure element which we will talk about later. Whenever a new invocation of method take place, a new frame is dynamically created, and discarded as the invocation completes, normally or abruptly. The method may be non-native or native.&lt;/p&gt;
&lt;p&gt;Each frame consists of &lt;strong&gt;a series of local variable&lt;/strong&gt; of the method, and &lt;strong&gt;the status of the method execution&lt;/strong&gt;, based on which jvm can put forward the execution, whether return the control to the invoker or continue within the method. The frame&amp;#8217;s creation and status moving forward, which consist of the &lt;em&gt;execution&lt;/em&gt;, are totally decided by information of the corresponded method, stored in the method area, which is the &lt;em&gt;program&lt;/em&gt;.&lt;/p&gt;
&lt;h3&gt;Collection of Frames&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;private to each thread&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;execution&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created when each thread is created&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;As mentioned above, it maintains all ever created and then discarded frames of a thread during execution.&lt;/p&gt;
&lt;h3&gt;Shared Data Area&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;shared by all threads&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;execution&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created at jvm start-up&lt;br /&gt;
&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All dynamically created data at runtime are stored at this area. It includes all class instances and arrays. This may correspond to the area in a conventional program where global variable and dynamically created data are stored.&lt;/p&gt;
&lt;h3&gt;Representation of Objects&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;shared by all threads and accessed according to visibility of the type of each object&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;execution&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;created&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;part of  method area or shared data area &lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;How does a real object is represented? Many abstract structural element may, via some way, have an access to this representation. Since each class has its own representation in jvm which is also an object, so in method area there also exist this kind of element. (correct me)&lt;/p&gt;
&lt;h1&gt;3. Data Structure Under the Hood&lt;/h1&gt;
&lt;p&gt;This section contains information that very likely is not very accurate and that is only based on my own knowledge. Please reference at your own risk.&lt;/p&gt;
&lt;h3&gt;pc&lt;/h3&gt;
&lt;p&gt;pc is a pointer which stored in register (logic register of jvm, or register on physical host machine). It may contain very little information. But what matters most is it must be very fast to access.&lt;/p&gt;
&lt;h3&gt;Method Area&lt;/h3&gt;
&lt;p&gt;Arrays, c-style structs, lists, tables (most likely an array of c-style structs), or cascaded tables.&lt;/p&gt;
&lt;h3&gt;Frames&lt;/h3&gt;
&lt;p&gt;local variables are stored in a table, and &lt;strong&gt;the status of the method execution&lt;/strong&gt; is stored in a stack called operand stack. Executing instructions stored in method area may pop out from and/or push on stack the operands and/or results of operations.&lt;/p&gt;
&lt;h3&gt;Collection of Frames&lt;/h3&gt;
&lt;p&gt;Each collection is stored in a stack called JVM Stack. An invocation of a method push a newly created frame on the stack and completion of an invocation pops a frame out from the stack, and then the control returns to invoker&amp;#8217;s frame. Each jvm thread has two kinds of stack: stack for java code and stack size for native code.&lt;/p&gt;
&lt;h3&gt;Shared Data Area&lt;/h3&gt;
&lt;p&gt;The shared data area is structured as a heap. GC consumes most of its time here.&lt;/p&gt;
&lt;h3&gt;Representation of Objects&lt;/h3&gt;
&lt;p&gt;Stored and organized on heap. Its internal structure may be c-style struct record.&lt;/p&gt;
&lt;p&gt;Totally undefined which means it is completely subject to specific jvm implementation. Please skip this subsection.&lt;/p&gt;
&lt;p&gt;But as I imagine, first get the representation of reference, and then the shared data area, and last the representation of objects.&lt;/p&gt;
&lt;p&gt;As jvm spec stated, a reference is  pointer to the address space that stores the address of the real object, which means it is similar to be of type pointer to a pointer.&lt;/p&gt;
&lt;h1&gt;4. More Under the Hood&lt;/h1&gt;
&lt;p&gt;This section contains information that very likely is not very accurate and that is only based on my own knowledge. Please reference at your own risk.&lt;/p&gt;
&lt;p&gt;Heap and stack (and other data structures mentioned in this post) are not terms of jvm spec, they refer to underlying implementation of the data, or their counterpart terms in data structure theory. The purpose of introducing two concepts heap and stack and making the difference visible is that although they &lt;strong&gt;both can be dynamically allocated&lt;/strong&gt;, workloads and policies of managing allocation and deallocation of these two kinds of data are quite different. Stack is quite manageable (which needs little workload and theoretically runs no risk of memory leak) and its size is easily inferred at compile time, while heap needs a quite complex way to manage (which needs so much workload that the runtime performance of the program based on it would be largely affected) and its size is most of time impossible to be inferred at compile time.&lt;/p&gt;
&lt;p&gt;So below we divide memory as heap memory and non-heap memory, which is to follow Sun&amp;#8217;s official document about JVM implementation.&lt;/p&gt;
&lt;h3&gt;Heap Memory&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;shared data area&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Non-heap Memory&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;Java virtual machine stack&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;native method stack (for native method frames, correct me)&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;method area (logically belongs to, but adopt a quite different policy compared to runtime data area, so it is usually counted as non-heap memory), corresponding to Permanent Generation space of Sun&amp;#8217;s implementation&lt;/li&gt;
&lt;/ul&gt;
&lt;ul&gt;
&lt;li&gt;internal processes (threads scheduler or dispatcher) or optimization&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Garbage Collection&lt;/h3&gt;
&lt;p&gt;Few parts of JVM&amp;#8217;s memory is of fixed size at runtime, they may from time to time be expanded and/or compacted. This work is done by memory manager. And garbage collector is a type of memory manager. It is used to destroy &amp;#8220;unreferenced&amp;#8221; objects to free memory space.&lt;/p&gt;
&lt;p&gt;Sun&amp;#8217;s implementation of jvm use a strategy called &lt;strong&gt;generational GC&lt;/strong&gt; (Garbage Collection). It divides memory into several generation, from young generation (eden space and survivor space, together sometimes are called new generation) , to tenured generation (or old generation), to permanent generation. When GC is performed in young generation , it is called a &lt;strong&gt;partial GC&lt;/strong&gt;, when performed in old generation, it is called a &lt;strong&gt;full GC&lt;/strong&gt;. Partial GC is much faster than full GC (&lt;a href=&quot;http://docs.sun.com/source/819-0084/pt_tuningjava.html#wp57003&quot;&gt;why&lt;/a&gt;). Each generation is sometimes called a memory pool.&lt;/p&gt;
&lt;p&gt;However, heap memory and non-heap memory don&amp;#8217;t seem to have a clean alignment with generations mentioned above. But roughly heap memory aligns with eden space, survivor space and tenured space, and non-heap memory aligns with permanent generation.  Tuning  the size of different  different  generation space and their ratio has big impacts on the performance of GC when your program runs in some demanding environment, say within a hosted web server. And what makes the matter complex, almost every abstract structure element mentioned in previous section has corresponding option to get tuned.&lt;/p&gt;
&lt;p&gt;GC is also can be configured to use different algorithms.  But this is out of the scope of this post.&lt;/p&gt;
&lt;h3&gt;Tuning JVM&lt;/h3&gt;
&lt;p&gt;One of the purpose of writing this post is to let your better tune your jvm, that is, give you good conceptions of which part of jvm are you tuning when you adjust some of the jvm options. &lt;a href=&quot;http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf&quot;&gt;Troubleshooting and Diagnostic Guide&lt;/a&gt; is a good starting point to tuning your jvm. Below only Sun&amp;#8217;s implementation is talked about.&lt;/p&gt;
&lt;h5&gt;Tuning Heap&lt;/h5&gt;
&lt;p&gt;Note that in Sun&amp;#8217;s different official document there exist conflicts that &lt;strong&gt;permanent generation space&lt;/strong&gt; sometimes is counted as heap memory and sometimes as non-heap memory, for which we mentioned above method area logically belongs to heap memory although we put it into the category of non-heap memory.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;-Xms&lt;em&gt;[value]&lt;/em&gt; // initial size of the total heap, e.g., -Xms64m. This means a heap of this size will be occupied when the jvm is started up. If this amount of memory request couldn&amp;#8217;t be meeted, the start-up would fail.&lt;/li&gt;
&lt;li&gt;-Xmx&lt;em&gt;[value]&lt;/em&gt; // maximum size of the total heap, e.g., -Xmx1024m. When requested more memory usually during creating new  class instances or arrays than maximum heap size, an &lt;em&gt;OutOfMemoryError&lt;/em&gt; will be thrown&lt;/li&gt;
&lt;li&gt;&lt;/li&gt;
&lt;li&gt;-XX:MinHeapFreeRatio=&lt;em&gt;minimum &lt;/em&gt;// the minimum proportion of free space to living objects (both of which make up the total heap), the lower limit of a range that each GC tries keep the proportion within&lt;/li&gt;
&lt;li&gt;-XX:MaxHeapFreeRatio=&lt;em&gt;maximum &lt;/em&gt;// the maximum proportion of free space to living objects, the upper limit of a range that each GC tries keep the proportion within&lt;/li&gt;
&lt;li&gt;-XX:NewRatio=ratio // the proportion of new generation to old genertion,when heap grows or shrinks, jvm must recaculate the size of new and old generation&lt;/li&gt;
&lt;li&gt;-XX:NewSize=&lt;em&gt;size&lt;/em&gt; // the minimum size of new generation&lt;/li&gt;
&lt;li&gt;-XX:MaxNewSize=&lt;em&gt;size&lt;/em&gt; // the maximum size of new generation&lt;/li&gt;
&lt;li&gt;-XX:OldSize=&lt;em&gt;size&lt;/em&gt; // the size of old generation&lt;/li&gt;
&lt;li&gt;-XX:SurvivorRatio=&lt;em&gt;size&lt;/em&gt; // the proportion of survivor generation to eden generation&lt;/li&gt;
&lt;li&gt;-XX:PermSize=&lt;em&gt;size&lt;/em&gt; // minimum size of permanent generation&lt;/li&gt;
&lt;li&gt;-XX:MaxPermSize=&lt;em&gt;size&lt;/em&gt; // maximum size of permanent generation&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sun&amp;#8217;s jvm has two equally sized survivor space, above tuning related to survivor is for each not for the two in total.&lt;/p&gt;
&lt;p&gt;To make the matter clear, new generation and old generation definitions are redeclared here:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;new generation = eden space + survivor space&lt;/li&gt;
&lt;li&gt;old generation = tenured space&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;Tuning Others&lt;/h5&gt;
&lt;ul&gt;
&lt;li&gt;-XX:ThreadStackSize=&lt;em&gt;512&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;-Xss&lt;em&gt;[value]&lt;/em&gt; // native method stack size, &lt;em&gt;StackOverflowError&lt;/em&gt; will be thrown if this limit is exceeded&lt;/li&gt;
&lt;li&gt;-Xoss&lt;em&gt;[value]&lt;/em&gt; // jvm stack size, &lt;em&gt;StackOverflowError&lt;/em&gt; will be thrown if this limit is exceeded&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;5. Resources&lt;/h1&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/docs/books/jvms/second_edition/html/VMSpecTOC.doc.html&quot;&gt;JVM SPEC 2nd edition&lt;/a&gt;, a must read.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/technotes/guides/management/jconsole.html#gdeao&quot;&gt;Using JConsole&lt;/a&gt;. aside from how to use it, it also contains much information about the structure of sun&amp;#8217;s implementation of jvm.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/j2se/1.5/pdf/jdk50_ts_guide.pdf&quot;&gt;Troubleshooting and Diagnostic Guide&lt;/a&gt;. a good place to start investigating and experimenting.&lt;/li&gt;
&lt;li&gt;Open JDK. source codes are available for further investigating and experimenting.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://www.velocityreviews.com/forums/t144933-questions-about-jvm-internals.html&quot;&gt;Questions about JVM internals&lt;/a&gt;, a discussion on bbs by non-experts, a good starting point.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://my.donews.com/kenyth/2006/12/26/qqwxthjgpwgzvhxhxhbnprarizjqhdaxuxuo/&quot;&gt;My another blog posts related&lt;/a&gt; (in Chinese)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://docs.sun.com/source/819-0084/pt_tuningjava.html#wp57027&quot;&gt;Tuning the Java Runtime System&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/tprf_tunejvm_v61.html&quot;&gt;Tuning Java Virtual Machine&lt;/a&gt;, IBM&amp;#8217;s guide in WebSphere manual.&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/javase/technologies/hotspot/vmoptions.jsp#PerformanceTuning&quot;&gt;Categories of Java HotSpot VM Options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/javase/6/docs/technotes/tools/index.html&quot;&gt;JDK Tools and Utilities&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715613/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715613/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/03/09/jvm-structure-study-notes/feed/</wfw:commentRss><description>1. Overview
Regardless of specific implementation, first take a look at what&amp;#8217;s described in JVM SPEC. And most of post is talking about server VM, however, where applicable you can reference for client VM.
Given the assumption of having knowledge of conventional (from some point of view, Java itself may become a conventional language, so in this [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715613/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715613/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>data structure</category><category>jvm</category><category>heap</category><category>Java</category><category>jdk</category><category>gc</category><category>memory</category><category>notes</category><category>stack</category><category>languages</category><pubDate>Sun, 09 Mar 2008 00:35:25 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/03/09/jvm-structure-study-notes/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/03/09/jvm-structure-study-notes/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/03/09/jvm-structure-study-notes/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715613/4990955</fs:itemid></item><item><title>Sharing one dsl internet connection in a HUB-based LAN</title><link>http://dev.kenyth.name/2008/01/29/sharing-one-dsl-internet-connection-in-a-hub-based-lan/</link><content:encoded>&lt;p&gt;Since I&amp;#8217;ve got a new laptop, I&amp;#8217;d like to share one internet connection between it and my desktop pc, both of which dual-boot Linux (Ubuntu) and Windows (Vista/XP).&lt;/p&gt;
&lt;p&gt;Until now I&amp;#8217;ve only tested the sharing when both are under ubuntu, latter I&amp;#8217;ll test it with one on Ubuntu (which serves as the router) and another on Windows. If in your case Windows machine are connecting to the Internet, then you may use Winows&amp;#8217; ICS (Internet Connection Sharing) which is very simple. But now I&amp;#8217;m writing the cases where Ubuntu machine is connecting to the Internet.&lt;/p&gt;
&lt;p&gt;Configuration:&lt;br /&gt;
laptop (ubuntu 7.10)&lt;br /&gt;
eth0 (192.168.0.1) &amp;lt;&amp;#8211;&amp;gt; hub&lt;br /&gt;
ppp0 &amp;lt;&amp;#8211;&amp;gt; Internet&lt;/p&gt;
&lt;p&gt;desktop pc (ubuntu 7.10)&lt;br /&gt;
eth0 (192.168.0.8)  &amp;lt;&amp;#8211;&amp;gt; hub&lt;/p&gt;
&lt;p&gt;The following steps will do this job:&lt;br /&gt;
on laptop:&lt;br /&gt;
1. enable NAT (network address translation, you may encounter this if you&amp;#8217;re playing with vmware)&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;root:~&amp;gt; iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;only doing this, you may not get NAT enabled after you reboot your system. So add the following to /etc/network/interface (may be at the end of auto eth0 section):&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;pre-up iptables-restore &amp;lt; /etc/iptables.rules&lt;br /&gt;
post-down iptables-save &amp;gt; /etc/iptables.rules&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;optionally if it doesn&amp;#8217;t work with all the others (including all those below), try this first before the others:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;root:~&amp;gt; iptables -P FORWARD ACCEPT&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;2. enable ip forward. add this line to /etc/sysctrl.conf (may be at the end of this file):&lt;br /&gt;
net.ipv4.ip_forward = 1&lt;/p&gt;
&lt;p&gt;On desktop pc&lt;br /&gt;
1. set laptop as the gateway of it&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;root:~&amp;gt; route add default gw 192.168.0.1&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;All done! Now reboot the laptop and make the dsl connection. To check everything you configured normal just do this:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;root:~&amp;gt; cat /proc/sys/net/ipv4/ip_forward&lt;br /&gt;
1&lt;br /&gt;
root:~&amp;gt; iptables -t nat -L &lt;strike&gt;MASQUERADE&lt;/strike&gt; POSTROUTING&lt;br /&gt;
target     prot opt source               destination&lt;br /&gt;
MASQUERADE  0    &amp;#8212;  anywhere             anywhere&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;If you get the same output, then everything goes all right. Ping a website on the desktop pc to ensure the sharing succeed.&lt;/p&gt;
&lt;p&gt;I did all the above following these:&lt;br /&gt;
http://forums.afterdawn.com/thread_view.cfm/616232&lt;br /&gt;
http://lindesk.com/2007/04/internet-connection-sharing-using-iptables/&lt;/p&gt;
&lt;p&gt;The key point for understanding what these steps mean and do to your system is to understand the command iptables and the target (iptables term) MASQUERADE. I read the manual of iptables carefully and as I understand, enabling MASQUERADE (or NAT) replaces the source addresses of packets that the desktop pc sends out to the Internet with ppp0&amp;#8217;s address and destination addresses of packets that are sent from the Internet to your desktop PC with your desktop pc&amp;#8217;s address in the LAN. In addition &amp;#8220;-o ppp0&amp;#8243; means all packets going out through ppp0 will be MASQUERADEed.&lt;/p&gt;
&lt;p&gt;But the trick is how the laptop know which packets are sent to itself and which are sent to the desktop pc. If your ever somewhat investigate network connections in a LAN, you may find it is the port number that is the secrete.&lt;/p&gt;
&lt;p&gt;To make things clear, iptables contains some rules (table of chains) to handle any packets going through. You can add, delete and modify these rules. Roughly, a rule is made up of two parts: 1) the criteria to match packets; 2) for the matched packets, what you wanna do with them, which is called a &amp;#8220;target&amp;#8221;. The rough syntax of the iptables command is:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;iptables [-t table] [param] [some chain in the specified table] [option]&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Many built-in chains (each chain is a chain of rules) contains some pre-defined criteria to match the packets. In this post, we just utilizes the built-in rules and pre-defined target (yes target can be separately defined).&lt;/p&gt;
&lt;p&gt;Note: the terms and understandings may not be accurate, because It&amp;#8217;s just my understanding without further deep investigation.&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715614/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715614/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/01/29/sharing-one-dsl-internet-connection-in-a-hub-based-lan/feed/</wfw:commentRss><description>Since I&amp;#8217;ve got a new laptop, I&amp;#8217;d like to share one internet connection between it and my desktop pc, both of which dual-boot Linux (Ubuntu) and Windows (Vista/XP).
Until now I&amp;#8217;ve only tested the sharing when both are under ubuntu, latter I&amp;#8217;ll test it with one on Ubuntu (which serves as the router) and another on [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715614/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715614/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>ubuntu</category><category>linux</category><category>Uncategorized</category><category>administration</category><category>network</category><category>Internet</category><category>laptop</category><category>configuration</category><pubDate>Tue, 29 Jan 2008 00:56:48 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/01/29/sharing-one-dsl-internet-connection-in-a-hub-based-lan/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/01/29/sharing-one-dsl-internet-connection-in-a-hub-based-lan/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/01/29/sharing-one-dsl-internet-connection-in-a-hub-based-lan/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715614/4990955</fs:itemid></item><item><title>Finally decide to use the genkitheme for this blog</title><link>http://dev.kenyth.name/2008/01/09/finally-to-decide-to-use-the-genkitheme-for-this-blog/</link><content:encoded>&lt;p&gt;This blog is created for the purpose of being as a CMS (Content Management System) for software development (actually I call myself a *designer* sometimes for fun, yes, software designer) I&amp;#8217;ve involved in, technologies I&amp;#8217;ve learned and am learning, sometimes resource collection, etc. In a word, it&amp;#8217;s mainly about codes and all stuff related.&lt;/p&gt;
&lt;p&gt;And like a similar blog previously  I wrote, it will be written all in English.  This is for the ease of avoiding translation new and non popular technology terms, which otherwise would be mixed with other text that is in my mother language: Chinese. Yes, it&amp;#8217;s totally crap. Straightforwardly,  I&amp;#8217;m lazy. But don&amp;#8217;t expect highly for my English. Maybe I call it English and you don&amp;#8217;t.  All crap!&lt;/p&gt;
&lt;p&gt;Only one thing I wanna say is about the theme, named &lt;a href=&quot;http://ericulous.com/2007/05/21/wp-theme-genkitheme/&quot;&gt;genkitheme&lt;/a&gt; (any idea about the name?)  that I chose for this blog. Actually I first see it at &lt;a href=&quot;http://robertmao.com&quot;&gt;Robert Mao&lt;/a&gt;&amp;#8217;s blog. I just feel comfortable when I saw it. One of the best thing that I like it is that it has a flexible width so that wide enough area is there for the post content which is sometimes very important for code snippet and pic demonstration.  I tried to find a better 3-column theme than this one but in vain.&lt;/p&gt;
&lt;p&gt;And I&amp;#8217;m also looking for a good Linux (I&amp;#8217;m under ubuntu 7.1 for most of the time) desktop tool for writing blog. Previously I used Windows Live Writer for a long time for mainly for my another blog (it&amp;#8217;s mainly about my life sharing with my family and intimate friends). It&amp;#8217;s really the best one I&amp;#8217;ve ever used (If you work under windows you may follow &lt;a href=&quot;http://robertmao.com/?s=live+writer&quot;&gt;Robert&amp;#8217;s path&lt;/a&gt; to reach it. I reached it before he made it :). Until I find that tool, I&amp;#8217;ll write posts online.&lt;/p&gt;
&lt;p&gt;And in case you are browsing this blog to find something valuable, I&amp;#8217;d better tell something about my tech background so that you may not waste your time here. Currently, I&amp;#8217;m not a guru in any area and I just started my career as a Java developer last June.  Languages that I really know (used it for coding for a relatively long time) are c/c++ (ever wrote codes for some *baby* embedded system), delphi (not for .Net platform) and Java/AspectJ. For other many commonly used languages, I won&amp;#8217;t say anything about them for they&amp;#8217;re commonly used. I hold a master degree in CS and a bachelor degree in EE. I spent a lot of time researching in areas like programming languages, OO, AOP and software engineering theories (yes, theories). Recently I&amp;#8217;m extremely interested in web related stuff. But you may consider me as beginner level. I&amp;#8217;m very pleased to be able to work on some open source projects if given the opportunity.  And also I&amp;#8217;m looking for a career in a Internet company (especially startup company). I won&amp;#8217;t repeat my resume here. It&amp;#8217;s enough.&lt;/p&gt;
&lt;p&gt;Last but not least, you can reach me by kenyth at gmail dot com.&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715615/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715615/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/01/09/finally-to-decide-to-use-the-genkitheme-for-this-blog/feed/</wfw:commentRss><description>This blog is created for the purpose of being as a CMS (Content Management System) for software development (actually I call myself a *designer* sometimes for fun, yes, software designer) I&amp;#8217;ve involved in, technologies I&amp;#8217;ve learned and am learning, sometimes resource collection, etc. In a word, it&amp;#8217;s mainly about codes and all stuff related.
And like [...]&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715615/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715615/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>career</category><category>wordpress</category><category>Uncategorized</category><category>project</category><category>about</category><category>helloworld</category><category>blogblog</category><pubDate>Wed, 09 Jan 2008 23:39:23 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/01/09/finally-to-decide-to-use-the-genkitheme-for-this-blog/#comments</comments><guid isPermaLink="false">http://dev.kenyth.name/2008/01/09/finally-to-decide-to-use-the-genkitheme-for-this-blog/</guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/01/09/finally-to-decide-to-use-the-genkitheme-for-this-blog/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715615/4990955</fs:itemid></item><item><title>Hello world!</title><link>http://dev.kenyth.name/2008/01/07/hello-world/</link><content:encoded>&lt;p&gt;Welcome to &lt;a href=&quot;http://kenyth.name/&quot;&gt;Kenyth.name&lt;/a&gt;. This is your first post. Edit or delete it, then start blogging!&lt;/p&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715616/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715616/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://dev.kenyth.name/2008/01/07/hello-world/feed/</wfw:commentRss><description>Welcome to Kenyth.name. This is your first post. Edit or delete it, then start blogging!&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/d-e-v/324715616/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/d-e-v/324715616/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Uncategorized</category><category>helloworld</category><pubDate>Mon, 07 Jan 2008 21:50:09 +0800</pubDate><author>Kenyth</author><comments>http://dev.kenyth.name/2008/01/07/hello-world/#comments</comments><guid isPermaLink="false"></guid><dc:creator>Kenyth</dc:creator><fs:srclink>http://dev.kenyth.name/2008/01/07/hello-world/</fs:srclink><fs:srcfeed>http://dev.kenyth.name/feed/</fs:srcfeed><fs:itemid>feedsky/d-e-v/~6882869/324715616/4990955</fs:itemid></item></channel></rss>