<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Think Lamp</title>
	<atom:link href="http://www.think-lamp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.think-lamp.com</link>
	<description>Everything Linux Apache Php Mysql</description>
	<lastBuildDate>Mon, 16 Aug 2010 02:46:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Image with same path doesn&#8217;t show up due to cache in browsers</title>
		<link>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/</link>
		<comments>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:50:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[browsers]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[caching]]></category>
		<category><![CDATA[image]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=191</guid>
		<description><![CDATA[Browsers are designed to think that Images with same name don&#8217;t change rapidly so regularly.  This creates a problem in some cases where you have to reuse a  specific name Or a specific location for a system. One such case can be a social network which is designed in a way where the profile images [...]]]></description>
			<content:encoded><![CDATA[<p>Browsers are designed to think that Images with same name don&#8217;t change rapidly so regularly.  This creates a problem in some cases where you have to reuse a  specific name Or a specific location for a system.<br />
<span id="more-191"></span><br />
One such case can be a social network which is designed in a way where the profile images are always:</p>
<p><strong>http://www.mysite.com/users/images/user123/profile.jpg</strong></p>
<p>Now, on changing this image, sometimes browsers don&#8217;t clear cache and thus show the last image. In Order to solve this, use a random number at the end of the image location and you will be able to see that image. as browsers will not cache it.</p>
<p><strong>http://www.mysite.com/users/images/user123/profile.jpg?123</strong></p>
<p>One method that I used is:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$stamp</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$imageLocation</span>  <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.mysite.com/users/images/user123/profile.jpg?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$stamp</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$imageLocation</span></pre></div></div>

<p>This should work.</p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F09%2Fimage-with-same-path-doesnt-show-up-due-to-cache-in-browsers%2F&amp;linkname=Image%20with%20same%20path%20doesn%26%238217%3Bt%20show%20up%20due%20to%20cache%20in%20browsers"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/09/image-with-same-path-doesnt-show-up-due-to-cache-in-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fastest Insertion Sort in PHP</title>
		<link>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/</link>
		<comments>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 20:20:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[analysis of algorithms]]></category>
		<category><![CDATA[insertion sort]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=189</guid>
		<description><![CDATA[$numbers = array(2,3,4,5,1,8,11,0); $count = count($numbers); for($i=1;$i&#60;$count;$i++){ $j=$i-1; $key = $numbers[$i]; while($j&#62;=0 &#38;&#38; $numbers[$j] &#62; $key){ $numbers[$j+1] = $numbers[$j]; $numbers[$j]= $key; $j= $j-1; } } print_r($numbers);]]></description>
			<content:encoded><![CDATA[<pre class="brush: php;">
$numbers = array(2,3,4,5,1,8,11,0);
$count = count($numbers);

for($i=1;$i&lt;$count;$i++){
	$j=$i-1;
	$key = $numbers[$i];
	while($j&gt;=0 &amp;&amp; $numbers[$j] &gt;  $key){
		$numbers[$j+1] = $numbers[$j];
		$numbers[$j]= $key;
		$j= $j-1;
	}
}
print_r($numbers);
</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F08%2Ffastest-insertion-sort-in-php%2F&amp;linkname=Fastest%20Insertion%20Sort%20in%20PHP"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/08/fastest-insertion-sort-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTTP sessions and background processes on Apache-PHP</title>
		<link>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/</link>
		<comments>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 21:08:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[background process]]></category>
		<category><![CDATA[file descriptor]]></category>
		<category><![CDATA[flock]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[session_start()]]></category>
		<category><![CDATA[session_write_close]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=167</guid>
		<description><![CDATA[OK , so you are all excited about running a 10 minute process and you are happy that you have set the processing as a background process, while the user can surf along your website / CMS. If you are are using sessions, not quite smarty ! Consider this script [parentProcess.php] $backgroundCall = 'php childProcess.php [...]]]></description>
			<content:encoded><![CDATA[<p>OK , so you are all excited about running a 10 minute process and you are happy that<br />
you have set the processing as a background process, while the user can surf along your<br />
website / CMS. If you are are using sessions, not quite smarty !</p>
<p><span id="more-167"></span></p>
<p>Consider this script [parentProcess.php]</p>
<pre class="brush: php;">
$backgroundCall = 'php childProcess.php &amp;gt; /dev/null &amp;amp;';

shell_exec($backgroundCall );

echo &quot;Hello world ! My background job is fired&quot;;

// other code , redirects etc
</pre>
<p>When you call a background file with the &#8216;ampersand&#8217; in the end, it sure becomes a background file.<br />
But it does not mean that the user will get control back of the browser. If you are using sessions,<br />
the webpage will be busy until the background process finishes execution.</p>
<p>Why is that ?</p>
<p><span style="color: #800000;"><em>[There is bug described <a href="http://bugs.php.net/bug.php?id=10675" target="_blank">here</a> and it is still not solved even in the php 5.0+ versions.]</em></span></p>
<p style="text-align: justify;">What happens is that the child process which is called by the <strong>system() ,exec() or shell_exec()</strong> command<br />
holds the file lock on the parent process, thus locking the session file.<br />
Thus, the session file being locked <strong>session_start();</strong> function cannot access the file.<br />
This is due to to open file descriptors locking the session file.Your entire session will be locked, so none of the pages of the website can be opened ( which are under session control )<br />
unless you change the browser or delete cookies.</p>
<h2><span style="color: #ff0000;">Solution:</span></h2>
<p>There are places on the internet which provide C code and perl code to do that. But PHP has its own<br />
function , which sadly is ignored <strong>session_write_close();</strong> This function can be used to trigger the close of session. Thus instructing the session<br />
that there is nothing to write until the next session start. Triggering this before firing background process will not hold locks on<br />
the session file.</p>
<pre class="brush: php;">
$backgroundCall = 'php childProcess.php &amp;gt; /dev/null &amp;amp;';

session_write_close();

shell_exec($backgroundCall );

echo &quot;Hello world ! My background job is fired&quot;;

// other code , redirects etc</pre>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F04%2Fhttp-sessions-and-background-processes-on-apache-php%2F&amp;linkname=HTTP%20sessions%20and%20background%20processes%20on%20Apache-PHP"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/04/http-sessions-and-background-processes-on-apache-php/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>The (hidden) power of &#8216;ping&#8217;</title>
		<link>http://www.think-lamp.com/2009/03/the-hidden-power-of-ping/</link>
		<comments>http://www.think-lamp.com/2009/03/the-hidden-power-of-ping/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 23:50:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[computer]]></category>
		<category><![CDATA[LAN]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[ping]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=108</guid>
		<description><![CDATA[PING Ping is a Unix utility that sends ICMP ECHO to the server ( destination machine ) from the client ( originating machine ). It takes its name from a submarine sonar search &#8211; you send a short sound burst and listen for an echo &#8211; a ping &#8211; coming back. There is a myth [...]]]></description>
			<content:encoded><![CDATA[<h1 style="text-align: center;"><span style="color: #000000;">PING</span></h1>
<p><img class="aligncenter size-medium wp-image-109" title="echo" src="http://www.think-lamp.com/wp-content/uploads/2008/11/echo-300x178.jpg" alt="" width="300" height="178" /></p>
<p><strong>Ping </strong>is a Unix utility that sends ICMP ECHO to the server ( destination machine )  from the client ( originating machine ). It takes its name from a submarine sonar search &#8211; you send a short sound burst and listen for an echo &#8211; a <em>ping</em> &#8211; coming back. There is a myth that  Ping is actually an acronym for the words &#8216;Packet INternet Groper&#8217;, but there is no proven evidence to support the statement.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-3741710014597097";
/* 468x15, created 3/25/09 */
google_ad_slot = "1110499399";
google_ad_width = 468;
google_ad_height = 15;
// --></script><br />
<script src="http://pagead2.googlesyndication.com/pagead/show_ads.js" type="text/javascript"></script></p>
<p><span id="more-108"></span></p>
<p>For years, system admins, managers, developers, and the-next-door-jack have been using this utility, primarily to check if the <strong><em>&#8216;target system is alive&#8217;</em></strong><em><strong>. </strong></em>Ping, is thus undercredited by deeming it as an utility which has only one function.  &#8220;<span style="color: #333300;"><em><strong>Type in ping &lt;target_machine&gt; , if it gives response the machine is UP, if it doesn&#8217;t either machine is down OR network is down.</strong> </em></span>&#8220;NOT NECESSARILY TRUE!</p>
<h3><strong>What (other) Information can a  &#8216;ping&#8217; give you ? </strong></h3>
<ol>
<li> If the &lt;target_machine&gt; is alive  [ there are cases where this doesn't work ]</li>
<li>How long each packet exchange took</li>
<li>Interframe Gap</li>
<li>Reports other ICMP messages that might otherwise get buried in the system software</li>
<li>Exponential Moving Average</li>
<li>How occupied is the target system including the network that routes from host to the target.</li>
</ol>
<p>Now, how &#8216;you&#8217;  use this information to draw conclusions and metrics, is upon you. I&#8217;ll show some examples in the later part of this article.</p>
<p><em><strong>Lets see a sample Ping Output</strong></em></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">-bash-<span style="color: #000000;">3.00</span>$ <span style="color: #c20cb9; font-weight: bold;">ping</span> www.google.com
PING www.l.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.104<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">56</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">84</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> bytes of data.
<span style="color: #000000;">64</span> bytes from yo-in-f104.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.104<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">0</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">246</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">7.97</span> ms
<span style="color: #000000;">64</span> bytes from yo-in-f104.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.104<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">246</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">13.7</span> ms
<span style="color: #000000;">64</span> bytes from yo-in-f104.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.104<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">2</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">246</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">9.69</span> ms
<span style="color: #000000;">64</span> bytes from yo-in-f104.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.104<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">3</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">246</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">8.15</span> ms
&nbsp;
<span style="color: #660033;">---</span> www.l.google.com <span style="color: #c20cb9; font-weight: bold;">ping</span> statistics <span style="color: #660033;">---</span>
<span style="color: #000000;">4</span> packets transmitted, <span style="color: #000000;">4</span> received, <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> packet loss
rtt min<span style="color: #000000; font-weight: bold;">/</span>avg<span style="color: #000000; font-weight: bold;">/</span>max<span style="color: #000000; font-weight: bold;">/</span>mdev = <span style="color: #000000;">7.971</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9.884</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">13.716</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2.313</span> ms</pre></div></div>

<p>pretty normal eh ! Whats so new in that ?<br />
Now, I can bet 50% of people who read this may not know the significance of all the digits or abbreviations in the output. It is a good idea to have a detailed knowledge of it in order to understand what is actually happening.<br />
This will also help you to change the data in order to detect certain problems.</p>
<p><strong>1.</strong> When you ping www.google.com it replies www.l.google.com which is actually a CNAME in the DNS database.<br />
<strong>2.</strong> The second line has the IP address of the host that is found. This IP address is found from the DNS query to the DNS database. ( I will be writing an article about how the DNS query actually works ! Watch out for it )<br />
<strong>3.</strong> Line two has two numbers (56 and 84 ) as bytes of data while all the reply has another (64) bytes of data. Now what are these ?</p>
<p>PING is an ICMP Packet with  20 bytes of IP header + 8 bytes ICMP header  + XX byes of data ( or call it the payload )</p>
<p>IN default case, the whole frame is set to 64 bytes That is 20 IP header + 8 ICMP header + 56 bytes of payload. That is how you get all these numbers .. never thought of it isn&#8217;t it ?</p>
<div class="wp-caption aligncenter" style="width: 522px"><img title="ICMP Packet" src="http://www.caida.org/tools/measurement/skitter/packets/skitter_ttl_out_pkt.gif" alt="image reference : www.caida.org" width="512" height="309" /><p class="wp-caption-text">image reference : www.caida.org</p></div>
<p><strong>4. </strong>The next four lines show the successful reply from the IP address and their reverse DNS host names. See how the host names actually differ in all the first three lines of the output  ? That is the magic of DNS and load balancing, which I will be discussing in a n separate article.</p>
<p><strong>5.</strong> These also have 3 major things: (a) icmp_seq  (b)ttl and (c)time in miliseconds</p>
<p><strong>(a) icmp_seq </strong>number is the sequence number of packets that are transmitted and received back by the client. If a sequence number is missing OR if there is a gap in the sequence number that means that the client is sending more than what the server can take. It is called source quench. As ICMP is a lower level protocol it can only detect errors not correct it ( as IP or TCP does ).</p>
<h3><em><strong>how to  simulate source quench ? </strong></em></h3>
<div id="attachment_140" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.think-lamp.com/wp-content/uploads/2009/03/echo_point.jpg"><img class="size-medium wp-image-140" title="Echo " src="http://www.think-lamp.com/wp-content/uploads/2009/03/echo_point-300x204.jpg" alt="Image Courtesy: www.cartoonstock.com" width="300" height="204" /></a><p class="wp-caption-text">Image Courtesy: www.cartoonstock.com</p></div>
<p>You can use the command -i0 :this switch will set interval to 0 , this means that the client will continuously keep on sending packets without waiting for a response from the server. This will result in server getting busy and thus dropping packets.<br />
You can also use the switch -s500 : this switch will set the payload along with ICMP header size to 500 and the server has to accept and process more data from the server ( A ping with packet larger than 64 is called <strong><span style="text-decoration: underline;">The Ping of Death</span></strong> )<br />
You can use both at the same time to get good results</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ping</span> <span style="color: #660033;">-i0</span> <span style="color: #660033;">-s500</span> www.google.com</pre></div></div>

<p><span style="text-decoration: underline;">Lets see an output:</span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">64</span> bytes from host232.hostmonster.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>74.220.215.232<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">24</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">50</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">114</span> ms
<span style="color: #000000;">64</span> bytes from host232.hostmonster.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>74.220.215.232<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">25</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">50</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">123</span> ms
<span style="color: #000000;">64</span> bytes from host232.hostmonster.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>74.220.215.232<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">27</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">50</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">time</span></span>=<span style="color: #000000;">112</span> ms</pre></div></div>

<p>Here we see that the icmp sequence number 26 is lost. This indicates that the server is busy and thus cannot accept data at these throughputs.<strong> <span style="color: #993300;">Now, in production environment something like this can be used to  compare  past &#8216;good&#8217; results to a problem scenario. If all of a sudden you find that there is a large packet drop on the ping with the normal 64 byte 0 second interval packets, you can judge that there could be something wrong with the either devices OR the network pipe OR the internet connection itself could be slow. Comparing these figures on a different server / different network  / different subnet would help you determine the problem area, and in some cases you can actually pinpoint the culprit. </span></strong></p>
<p><strong>(b) TTL</strong></p>
<p>Any IP packet that gets sent out will have a TTL field which normally is set to a relatively high number (in the case of ping the default  TTL is 255). As the packet traverses the network, the TTL field gets decreased by one by each HOP ( or router ) it goes through; when the TTL drops to 0, the packet is discarded by the router. The IP specification says that the TTL should be set to 60 (though it&#8217;s 255 for ping packets). The main purpose of this is so that a packet doesn&#8217;t live forever on the network and will eventually die when it is deemed &#8220;lost.&#8221; But for ping purposes, it provides additional information. The TTL can be used to determine approximately how many router hops the packet has gone through. If the TTL field varies in successive pings, it could indicate that the successive reply packets are going via different routes, which isn&#8217;t a great thing.</p>
<p>So a TTL of 245 for gogole.com means that it took (255-245 = ) 10 hops to reach google.com server.<br />
<strong><span style="color: #993300;">On a production environment, in a ping output a low TTL means that it took the packet higher number of hops to reach to the destination. Time to check your network routing table ?</span></strong></p>
<p><strong>(c) time</strong></p>
<p>The time is the time in milliseconds (ms) that it took to reach to the source and back. <span style="color: #993300;"><span style="color: #000000;">Thus it is also called RTT or the Round Trip Time</span>.</span><strong><span style="color: #993300;"> In a production environment a HIGH  RTT suggests that there is a congestion in the network. </span></strong></p>
<p><strong>6.</strong> After the ping terminates ( normally ctrl+c  OR with a switch -c&lt;#&gt; where &lt;#&gt; is the count before termination ) you will see number of packets transmitted, number failed and the percentage failed. In this example output its a 100% success but In the above source quench example we can see the number of packets failed and the percentage non zero.</p>
<p><strong>7.</strong> The min/avg/max/mdev is the  minimum / average / maximum / standard deviation of the round trip times. To have a good number and analysis, send at least  50 to 100 packets.</p>
<h3><strong>What else ?</strong></h3>
<p style="text-align: center;"><a href="http://www.think-lamp.com/wp-content/uploads/2009/03/english_echo.jpg"><img class="size-medium wp-image-141 aligncenter" title="Give something get something" src="http://www.think-lamp.com/wp-content/uploads/2009/03/english_echo.jpg" alt="" width="300" height="300" /></a></p>
<p>Lets take a look at the end of the output:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">64</span> bytes from yo-in-f99.google.com <span style="color: #7a0874; font-weight: bold;">&#40;</span>64.233.169.99<span style="color: #7a0874; font-weight: bold;">&#41;</span>: <span style="color: #007800;">icmp_seq</span>=<span style="color: #000000;">29</span> <span style="color: #007800;">ttl</span>=<span style="color: #000000;">245</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>truncated<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #660033;">---</span> www.l.google.com <span style="color: #c20cb9; font-weight: bold;">ping</span> statistics <span style="color: #660033;">---</span>
<span style="color: #000000;">30</span> packets transmitted, <span style="color: #000000;">30</span> received, <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> packet loss, <span style="color: #000000; font-weight: bold;">time</span> 540ms
rtt min<span style="color: #000000; font-weight: bold;">/</span>avg<span style="color: #000000; font-weight: bold;">/</span>max<span style="color: #000000; font-weight: bold;">/</span>mdev = <span style="color: #000000;">7.560</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">7.996</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">8.609</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.257</span> ms,  ipg<span style="color: #000000; font-weight: bold;">/</span>ewma <span style="color: #000000;">18.632</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">7.945</span> ms</pre></div></div>

<p>Focus on the line: ipg/ewma . That is: inter-packet gap / exponential moving average.</p>
<p><strong>InterPacket Gap (measured in seconds)</strong></p>
<p>The Inter-packet gap (or the inter-frame gap) is an idle time period appended to the end of every frame by the ethernet adapter. This idle time gives the network media a chance to stabilize, and other network components time to process the frame. On specifying the i0 or the -f switch in ping we can get the output resulting ping statistics which gives the current ipg of the system.<br />
The minimum interframe gap is 96 bit times (the time it takes to transmit 96 bits of raw data on the medium), which is<br />
9.6 μs for 10 Mbit/s Ethernet,<br />
960 ns for 100 Mbit/s (fast) Ethernet,<br />
96 ns for 1 Gbit/s (gigabit) Ethernet, and<br />
9.6 ns for 10 Gbit/s (10 gigabit) Ethernet.<br />
This is the minimum gap as specified in Ethernet protocol and required for a non-colliding transmission. There are ways to reduce it for a faster UDP transmissions, but can cause heavy collisions if other devices ( client and server ) aren&#8217;t able to handle the high rate of transmission.</p>
<p>In ideal situations for a 10 Mbps line and 9.6 μs of IFG the loss is 14.28%</p>
<p style="text-align: center;"><a href="http://www.think-lamp.com/wp-content/uploads/2009/03/ifg_calc.gif"><img class="size-medium wp-image-143 aligncenter" title="ifg calculations" src="http://www.think-lamp.com/wp-content/uploads/2009/03/ifg_calc.gif" alt="" width="300" height="286" /></a></p>
<p style="text-align: left;"><strong><span style="color: #993300;">Now, once you have the ifg and your Ethernet pipe speed. You can easily determine the network efficiency.</span></strong></p>
<p><strong>Exponential Weighted Moving Average (measured in seconds)</strong></p>
<p>Estimated packet rate is used to identify abnormal activities and attacks. The ethernet adapter estimates the arrival of the next packet based on the information of previous packet. If the packet time is more it will go to sleep (saving power).<br />
Although I want to I cannot talk a lot about EWMA as it is beyond the scope of this article, but on a <strong><span style="color: #993300;">production system  A quick look at the rtt and ewma will tell you if something is wrong. rtt ~ ewma  for regular case. </span></strong></p>
<p>During operations, the effective idletime is measured using an exponential weighted moving average (EWMA), which considers recent packets to be exponentially more important than past ones. The Unix loadaverage is calculated in the same way.<br />
The calculated idle time is subtracted from the EWMA measured one, the resulting number is called &#8216;avgidle&#8217;. A perfectly loaded link has an avgidle of zero: packets arrive exactly at the calculated interval.</p>
<p><span style="font-family: Courier New;"><small></small></span></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F03%2Fthe-hidden-power-of-ping%2F&amp;linkname=The%20%28hidden%29%20power%20of%20%26%238216%3Bping%26%238217%3B"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/03/the-hidden-power-of-ping/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>What Rasmus Lerdorf is talking about AJAX</title>
		<link>http://www.think-lamp.com/2009/02/what-rasmus-lerdorf-is-talking-about-ajax/</link>
		<comments>http://www.think-lamp.com/2009/02/what-rasmus-lerdorf-is-talking-about-ajax/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 08:08:58 +0000</pubDate>
		<dc:creator>kinjal.ch</dc:creator>
				<category><![CDATA[AJAX]]></category>

		<guid isPermaLink="false">http://www.think-lamp.com/?p=136</guid>
		<description><![CDATA[Are you blindly following any ajax library to work your way. Take a look what Rasmus is talking about AJAX He follows the rule of simplicity as he described in his framework approach. The very basic of ajax structure - Javascript function createRequestObject() { var ro; var browser = navigator.appName; if(browser == &#8220;Microsoft Internet Explorer&#8221;){ [...]]]></description>
			<content:encoded><![CDATA[<p>Are you blindly following any ajax library to work your way.</p>
<p>Take a look what <a href="http://news.php.net/php.general/219164" target="_blank">Rasmus is talking about AJAX</a></p>
<p>He follows the rule of simplicity as he described in his framework approach.</p>
<p><span id="more-136"></span></p>
<p>The very basic of ajax structure -</p>
<p><strong>Javascript</strong></p>
<p>function createRequestObject() {</p>
<p>var ro;</p>
<p>var browser = navigator.appName;</p>
<p>if(browser == &#8220;Microsoft Internet Explorer&#8221;){</p>
<p>ro = new ActiveXObject(&#8220;Microsoft.XMLHTTP&#8221;);</p>
<p>}else{</p>
<p>ro = new XMLHttpRequest();</p>
<p>}</p>
<p>return ro;</p>
<p>}</p>
<p>var http = createRequestObject();</p>
<p>function sndReq(action) {</p>
<p>http.open(&#8216;get&#8217;, &#8216;rpc.php?action=&#8217;+action);</p>
<p>http.onreadystatechange = handleResponse;</p>
<p>http.send(null);</p>
<p>}</p>
<p>function handleResponse() {</p>
<p>if(http.readyState == 4){</p>
<p>var response = http.responseText;</p>
<p>var update = new Array();</p>
<p>if(response.indexOf(&#8216;|&#8217; != -1)) {</p>
<p>update = response.split(&#8216;|&#8217;);</p>
<p>document.getElementById(update[0]).innerHTML = update[1];</p>
<p>}</p>
<p>}</p>
<p>}</p>
<p><strong>HTML</strong></p>
<p>&lt;a href=&#8221;javascript:sndReq(&#8216;foo&#8217;)&#8221;&gt;[foo]&lt;/a&gt;</p>
<p>&lt;div id=&#8221;foo&#8221; /&gt;</p>
<p>server side script(<strong>rpc.php</strong>) -</p>
<p>switch($_REQUEST['action']) {</p>
<p>case &#8216;foo&#8217;:</p>
<p>/* do something */</p>
<p>echo &#8220;foo|foo done&#8221;;</p>
<p>break;</p>
<p>&#8230;</p>
<p>}</p>
<p>Thats all. Everything else is just building on top of this.</p>
<p>Source : <a href="http://news.php.net/php.general/219164" target="_blank">http://news.php.net/php.general/219164</a></p>
<a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save?linkurl=http%3A%2F%2Fwww.think-lamp.com%2F2009%2F02%2Fwhat-rasmus-lerdorf-is-talking-about-ajax%2F&amp;linkname=What%20Rasmus%20Lerdorf%20is%20talking%20about%20AJAX"><img src="http://www.think-lamp.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a>]]></content:encoded>
			<wfw:commentRss>http://www.think-lamp.com/2009/02/what-rasmus-lerdorf-is-talking-about-ajax/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
