<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Yangzhe1990&#039;s Blog</title>
	<atom:link href="http://yangzhe1990.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://yangzhe1990.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Thu, 17 Nov 2011 10:45:47 +0000</lastBuildDate>
	<language>zh</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='yangzhe1990.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Yangzhe1990&#039;s Blog</title>
		<link>http://yangzhe1990.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://yangzhe1990.wordpress.com/osd.xml" title="Yangzhe1990&#039;s Blog" />
	<atom:link rel='hub' href='http://yangzhe1990.wordpress.com/?pushpress=hub'/>
		<item>
		<title>地球上的骨干网带宽真便宜啊</title>
		<link>http://yangzhe1990.wordpress.com/2011/11/17/%e5%9c%b0%e7%90%83%e4%b8%8a%e7%9a%84%e9%aa%a8%e5%b9%b2%e7%bd%91%e5%b8%a6%e5%ae%bd%e7%9c%9f%e4%be%bf%e5%ae%9c%e5%95%8a/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/11/17/%e5%9c%b0%e7%90%83%e4%b8%8a%e7%9a%84%e9%aa%a8%e5%b9%b2%e7%bd%91%e5%b8%a6%e5%ae%bd%e7%9c%9f%e4%be%bf%e5%ae%9c%e5%95%8a/#comments</comments>
		<pubDate>Thu, 17 Nov 2011 10:45:43 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=328</guid>
		<description><![CDATA[Tinet: $1/Mbps/month (到中国好，其它特点不太了解) He.net: $1/Mbps/month (到全球基本说得过去吧) NTT: $1/Mbps/month (日本) Level3: $1.3/Mbps/month Telia: $1.3/Mbps/month (欧洲) 当然，中国是排除在外的。(1000RMB/Mbps/month = $157/Mbps/month)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=328&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Tinet: $1/Mbps/month (到中国好，其它特点不太了解)<br />
He.net: $1/Mbps/month (到全球基本说得过去吧)<br />
NTT: $1/Mbps/month (日本)<br />
Level3: $1.3/Mbps/month<br />
Telia: $1.3/Mbps/month (欧洲)</p>
<p>当然，中国是排除在外的。(1000RMB/Mbps/month = $157/Mbps/month)</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/328/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/328/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/328/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=328&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/11/17/%e5%9c%b0%e7%90%83%e4%b8%8a%e7%9a%84%e9%aa%a8%e5%b9%b2%e7%bd%91%e5%b8%a6%e5%ae%bd%e7%9c%9f%e4%be%bf%e5%ae%9c%e5%95%8a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>关于如何破除电信、联通的垄断，我刚刚想了这样一个办法</title>
		<link>http://yangzhe1990.wordpress.com/2011/11/13/%e5%85%b3%e4%ba%8e%e5%a6%82%e4%bd%95%e7%a0%b4%e9%99%a4%e7%94%b5%e4%bf%a1%e3%80%81%e8%81%94%e9%80%9a%e7%9a%84%e5%9e%84%e6%96%ad/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/11/13/%e5%85%b3%e4%ba%8e%e5%a6%82%e4%bd%95%e7%a0%b4%e9%99%a4%e7%94%b5%e4%bf%a1%e3%80%81%e8%81%94%e9%80%9a%e7%9a%84%e5%9e%84%e6%96%ad/#comments</comments>
		<pubDate>Sun, 13 Nov 2011 04:34:13 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Network]]></category>
		<category><![CDATA[生态]]></category>
		<category><![CDATA[互联网]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=332</guid>
		<description><![CDATA[A去部署和经营一个全国性骨干网。其实一开始只覆盖大城市也好。 之后开始向那些大城市里的接入商出售骨干网接入服务。很多大城市都有区域性接入商，比如成都、杭州、北京、上海。同时向大城市的数据中心出售接入服务。 比如可以免费半年之类的。但本文完全不考虑成本问题。因为假定骨干网运营成本不会比电信、联通更高，因为他们的运营成本包括最后一公里的成本。 当然要注意做好两个措施： 跟地域性接入商签订消费者质量保障协议，要求接入商不得限制从骨干流入接入商的带宽。（不得oversale来自本骨干的带宽的意思），并保留因接入商接入带宽质量不好而随时终止提供带宽的权利； 对来自数据中心的流入带宽做好合理分配，避免配额超出骨干运行能力。 最重要的一点是：在免费服务结束后后，无论是最终用户接入的价格还是数据中心的接入价格一定要比电信便宜！ 我们知道，目前电信、联通的状况是： 自建的骨干越来越支持不住自己的最终用户的正常上网流量。在光进铜退提高最终用户接入速度大跃进后必然更加糟糕。 因此他们绝对不会降低数据中心接入带宽的价格。否则其骨干网根本撑不住，沦为一个劣质网络。 电信、联通垄断地位的基础是庞大的最终用户数量。 其垄断和打击最终用户接入市场竞争对手的基础在于庞大的接入数量，故其断然不可能向地域性接入商提供低价的接入。 电信、联通抵抗其它骨干网运行商的法宝是1000元/M/月的昂贵接入费用。并给数据中心提供更低的接入费用，借此牢牢捆住数据制造者，也就是各种网站，尤其是小型网站。并且目前绝大多数数据中心都是电信、联通建设，缺少第三方独立建设的数据中心，另外可能对于这种第三方数据中心，电信、联通也有不同程度的价格歧视。 1、2对于A来说，都是绝对有利的竞争条件。最重要的问题是，A是否能成功破除中国的互联网市场的垄断性。（所谓垄断这里认为是定价权被某一方或者某个托拉斯掌握） A必须同时接入一定规模的最终用户和数据中心，并且最离不开的是数据中心。 因为A通过更低的最终用户接入价格，成功得通过价格和网络质量将其最终用户接入业务包给了一些大城市内的最终用户接入商。并且由于价格的低廉性，凡是通过A的骨干网发送给其最终用户的流量，都会取代相同大小的电信、联通发送给其最终用户的流量，对接入商来说是绝对的好事。因此，A接入的数据中心越多，对整个市场，也包括A就越有利。 但问题也出在数据中心，在上面的3这个因素的作用下，电信、联通一定会其自有的数据中心向A或者A的数据中心用户收取极高的“进楼费”。而A自建数据中心，电信、联通一定不肯卖带宽给A。虽然我相信聪明的中国人一定能想出破解的办法，比如增加一个中间环节。但是没有一个简明正确的理论，最终还是难以迅速铺开，以改变现有市场生态。 不过对于已有的第三方数据中心，更便宜的骨干带宽一定是一件共赢的事情，这个与接入商是同理的。 总结一下我的思路和关键点：避免恶性竞争和保持物种多样性的最好办法是增加专一食物动物的比例、减少杂食动物的比例。于是欢迎讨论和设计更好的解决办法。<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=332&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A去部署和经营一个全国性骨干网。其实一开始只覆盖大城市也好。</p>
<p>之后开始向那些大城市里的接入商出售骨干网接入服务。很多大城市都有区域性接入商，比如成都、杭州、北京、上海。同时向大城市的数据中心出售接入服务。</p>
<p>比如可以免费半年之类的。但本文完全不考虑成本问题。因为假定骨干网运营成本不会比电信、联通更高，因为他们的运营成本包括最后一公里的成本。</p>
<p>当然要注意做好两个措施：</p>
<ol>
<li>跟地域性接入商签订消费者质量保障协议，要求接入商不得限制从骨干流入接入商的带宽。（不得oversale来自本骨干的带宽的意思），并保留因接入商接入带宽质量不好而随时终止提供带宽的权利；</li>
<li>对来自数据中心的流入带宽做好合理分配，避免配额超出骨干运行能力。</li>
</ol>
<p>最重要的一点是：在免费服务结束后后，无论是最终用户接入的价格还是数据中心的接入价格一定要比电信便宜！</p>
<p>我们知道，目前电信、联通的状况是：</p>
<ol>
<li>自建的骨干越来越支持不住自己的最终用户的正常上网流量。在光进铜退提高最终用户接入速度大跃进后必然更加糟糕。
<ul>
<li>因此他们绝对不会降低数据中心接入带宽的价格。否则其骨干网根本撑不住，沦为一个劣质网络。</li>
</ul>
</li>
<li>电信、联通垄断地位的基础是庞大的最终用户数量。
<ul>
<li>其垄断和打击最终用户接入市场竞争对手的基础在于庞大的接入数量，故其断然不可能向地域性接入商提供低价的接入。</li>
</ul>
</li>
<li>电信、联通抵抗其它骨干网运行商的法宝是1000元/M/月的昂贵接入费用。并给数据中心提供更低的接入费用，借此牢牢捆住数据制造者，也就是各种网站，尤其是小型网站。并且目前绝大多数数据中心都是电信、联通建设，缺少第三方独立建设的数据中心，另外可能对于这种第三方数据中心，电信、联通也有不同程度的价格歧视。</li>
</ol>
<p>1、2对于A来说，都是绝对有利的竞争条件。最重要的问题是，A是否能成功破除中国的互联网市场的垄断性。（所谓垄断这里认为是定价权被某一方或者某个托拉斯掌握）</p>
<p>A必须同时接入一定规模的最终用户和数据中心，并且最离不开的是数据中心。</p>
<p>因为A通过更低的最终用户接入价格，成功得通过价格和网络质量将其最终用户接入业务包给了一些大城市内的最终用户接入商。并且由于价格的低廉性，凡是通过A的骨干网发送给其最终用户的流量，都会取代相同大小的电信、联通发送给其最终用户的流量，对接入商来说是绝对的好事。因此，A接入的数据中心越多，对整个市场，也包括A就越有利。</p>
<p>但问题也出在数据中心，在上面的3这个因素的作用下，电信、联通一定会其自有的数据中心向A或者A的数据中心用户收取极高的“进楼费”。而A自建数据中心，电信、联通一定不肯卖带宽给A。虽然我相信聪明的中国人一定能想出破解的办法，比如增加一个中间环节。但是没有一个简明正确的理论，最终还是难以迅速铺开，以改变现有市场生态。</p>
<p>不过对于已有的第三方数据中心，更便宜的骨干带宽一定是一件共赢的事情，这个与接入商是同理的。</p>
<p>总结一下我的思路和关键点：避免恶性竞争和保持物种多样性的最好办法是增加专一食物动物的比例、减少杂食动物的比例。于是欢迎讨论和设计更好的解决办法。</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/332/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/332/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/332/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=332&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/11/13/%e5%85%b3%e4%ba%8e%e5%a6%82%e4%bd%95%e7%a0%b4%e9%99%a4%e7%94%b5%e4%bf%a1%e3%80%81%e8%81%94%e9%80%9a%e7%9a%84%e5%9e%84%e6%96%ad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>vaapi g45-h264 is still not usable</title>
		<link>http://yangzhe1990.wordpress.com/2011/11/06/vaapi-g45-h264-is-still-not-usable/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/11/06/vaapi-g45-h264-is-still-not-usable/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 22:44:28 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=329</guid>
		<description><![CDATA[To install it, run git clone cgit.freedesktop.org/vaapi/intel-driver/ -b g45-h264 then build the source and copy the *.so into the correct location. But after installation, test it by [QYQ][BDrip][AIR][OP_Longver.A][AVC_FLAC][3769CFBF].mkv you may find it&#8217;s too slow to play. And black blocks occasional appears when it&#8217;s playing. `mplayer2 -vc ffh264 -lavdopts threads=2 -benchmark -nosound` takes 104.122s to decode; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=329&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>To install it, run</p>
<p><code>git clone cgit.freedesktop.org/vaapi/intel-driver/ -b g45-h264</code></p>
<p>then build the source and copy the <code>*.so</code> into the correct location.</p>
<p>But after installation, test it by <code>[QYQ][BDrip][AIR][OP_Longver.A][AVC_FLAC][3769CFBF].mkv</code> you may find it&#8217;s too slow to play. And black blocks occasional appears when it&#8217;s playing.</p>
<p>`<code>mplayer2 -vc ffh264 -lavdopts threads=2 -benchmark -nosound</code>` takes 104.122s to decode;<br />
`<code>mplayer-vaapi -benchmark -nosound</code>` takes 196.749s.</p>
<p>But the total length of the video is only 201s.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/329/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/329/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/329/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=329&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/11/06/vaapi-g45-h264-is-still-not-usable/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>unbound模块简要说明</title>
		<link>http://yangzhe1990.wordpress.com/2011/10/18/unbound%e6%a8%a1%e5%9d%97%e7%ae%80%e8%a6%81%e8%af%b4%e6%98%8e/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/10/18/unbound%e6%a8%a1%e5%9d%97%e7%ae%80%e8%a6%81%e8%af%b4%e6%98%8e/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 16:34:39 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=319</guid>
		<description><![CDATA[unbound是一个DNS递归解析服务程序，支持DNSSEC、Caching以及pymod扩展。 pymod的链接包含了pymod的基本介绍和一些用pymod实现的小玩具。由于之前用python-libunbound时候被略坑了一下，并且在pythonmod/examples/resip.py中看到了这段话： # Please note that if this module blocks, by moving to the validator # to validate or iterator to lookup or spawn a subquery to look up, # then, other incoming queries are queued up onto this module and # all of them receive the same reply. # You can inspect the cache. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=319&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><a href="http://unbound.net">unbound</a>是一个DNS递归解析服务程序，支持DNSSEC、Caching以及<a href="http://unbound.net/documentation/pythonmod/index.html">pymod</a>扩展。</p>
<p>pymod的链接包含了pymod的基本介绍和一些用pymod实现的小玩具。由于之前用python-libunbound时候被略坑了一下，并且在<code>pythonmod/examples/resip.py</code>中看到了这段话：</p>
<p><code># Please note that if this module blocks, by moving to the validator<br />
# to validate or iterator to lookup or spawn a subquery to look up,<br />
# then, other incoming queries are queued up onto this module and<br />
# all of them receive the same reply.<br />
# You can inspect the cache.<br />
</code><br />
由于我的模块有网络操作，必须写成async的或者只能在这里block，我不得不从C代码中寻找我需要的东西。</p>
<p>unbound模块的基本介绍在这里：<a href="http://unbound.net/documentation/pythonmod/examples/example0.html">http://unbound.net/documentation/pythonmod/examples/example0.html</a>。阅读这里可以了解unbound module的大概。我在这里补充一些不可或缺的细节。</p>
<p>可用的模块列表被hardcoded到了<code>services/modstack.c</code>中，初始化检查合法性时会用到<code>util/fptr_wlist.c</code>中的函数。需要手工patch。</p>
<p>模块需要提供这些函数和一个<code>static struct module_func_block yourmodule_block</code>，</p>
<p><code>/**<br />
* Module functionality block<br />
*/<br />
struct module_func_block {<br />
/** text string name of module */<br />
const char* name;</code></p>
<p><code>/**<br />
* init the module. Called once for the global state.<br />
* This is the place to apply settings from the config file.<br />
* @param env: module environment.<br />
* @param id: module id number.<br />
* return: 0 on error<br />
*/<br />
int (*init)(struct module_env* env, int id);</code></p>
<p><code>/**<br />
* de-init, delete, the module. Called once for the global state.<br />
* @param env: module environment.<br />
* @param id: module id number.<br />
*/<br />
void (*deinit)(struct module_env* env, int id);</code></p>
<p><code>/**<br />
* accept a new query, or work further on existing query.<br />
* Changes the qstate-&gt;ext_state to be correct on exit.<br />
* @param ev: event that causes the module state machine to<br />
* (re-)activate.<br />
* @param qstate: the query state.<br />
* Note that this method is not allowed to change the<br />
* query state 'identity', that is query info, qflags,<br />
* and priming status.<br />
* Attach a subquery to get results to a different query.<br />
* @param id: module id number that operate() is called on.<br />
* @param outbound: if not NULL this event is due to the reply/timeout<br />
* or error on this outbound query.<br />
* @return: if at exit the ext_state is:<br />
* o wait_module: next module is started. (with pass event).<br />
* o error or finished: previous module is resumed.<br />
* o otherwise it waits until that event happens (assumes<br />
* the service routine to make subrequest or send message<br />
* have been called.<br />
*/<br />
void (*operate)(struct module_qstate* qstate, enum module_ev event,<br />
int id, struct outbound_entry* outbound);</code></p>
<p><code>/**<br />
* inform super querystate about the results from this subquerystate.<br />
* Is called when the querystate is finished.<br />
* @param qstate: the query state that is finished.<br />
* Examine return_rcode and return_reply in the qstate.<br />
* @param id: module id for this module.<br />
* This coincides with the current module for the super qstate.<br />
* @param super: the super querystate that needs to be informed.<br />
*/<br />
void (*inform_super)(struct module_qstate* qstate, int id,<br />
struct module_qstate* super);</code></p>
<p><code>/**<br />
* clear module specific data<br />
*/<br />
void (*clear)(struct module_qstate* qstate, int id);</code></p>
<p><code>/**<br />
* How much memory is the module specific data using.<br />
* @param env: module environment.<br />
* @param id: the module id.<br />
* @return the number of bytes that are alloced.<br />
*/<br />
size_t (*get_mem)(struct module_env* env, int id);<br />
};</code></p>
<p>这里对函数的行为解释得差不多了。<code>init()</code>、<code>deinit()</code>是模块全局初始化用的；<code>operate()</code>、<code>inform_super()</code>、<code>clear()</code>是在处理每个query中用的。我来说明一下<code>struct module_env</code>、<code>struct module_qstate</code>等。</p>
<p>在使用中其实<code>module_env</code>只会被创建一个，所有module的所有这些函数被传入的参数中的<code>env</code>都是它，<code>env-&gt;modinfo[id]</code>是<code>void *</code>类型，是存放全局module信息的指针。指针的值由module在<code>init()</code>时候设置，这个指针指向的内存由<code>init()</code>自行<code>malloc()</code>、<code>deinit()</code>时<code>free()</code>。<code>get_mem()</code>函数用来计算并返回这些东西的大小。</p>
<p><code>struct module_qstate</code>是对每个询问创建的一个context，每个询问被创建后会按照module的顺序进行执行。计算一个query的结果时，程序自己可能需要创建一个subquery，subquery则又会对应一个独立的<code>struct module_qstate</code>。</p>
<p><code>struct module_qstate</code>中保存了询问相关信息、一些全局信息、模块相关信息还有一些会用到的函数指针。其中<code>minfo[id]</code>用来给module存放模块跟当前<code>qstate</code>相关的信息。<code>ext_state[id]</code>存放模块在处理这个query时的执行状态信息。模块执行状态信息是<code>enum module_ext_state</code>，包含：</p>
<p><code> /** initial state - new query */<br />
module_state_initial = 0,<br />
/** waiting for reply to outgoing network query */<br />
module_wait_reply,<br />
/** module is waiting for another module */<br />
module_wait_module,<br />
/** module is waiting for another module; that other is restarted */<br />
module_restart_next,<br />
/** module is waiting for sub-query */<br />
module_wait_subquery,<br />
/** module could not finish the query */<br />
module_error,<br />
/** module is finished with query */<br />
module_finished<br />
</code></p>
<p>module的<code>ext_state</code>应该在<code>operate()</code>中设置，<code>operate()</code>会被unbound调用多次，分阶段完成module执行。如果module进行了外部询问，则应设置状态为<code>wait_reply</code>；如果将任务交给了下级，则应设置状态<code>wait_module</code>；如果生成了一个subquery，需要等待它的结果，则应设置<code>wait_subquery</code>；<code>restart_next</code>比较特殊，一般当它下级的module跑挂了（<code>module_error</code>或者没给满意的结果）之后，当前module可以选择重启下级，此后下级会先被调用一次<code>clear()</code>，再被调用<code>operate()</code>重新来过。<code>operate()</code>会在外部请求被回答、subquery完成、下级module执行完成（<code>error</code>或<code>finished</code>）后被调用以继续完成module的任务。</p>
<p><code>operate()</code>被调用时，参数<code>event</code>用来传递被调用的原因：</p>
<p><code>enum module_ev {<br />
/** new query */<br />
module_event_new = 0,<br />
/** query passed by other module */<br />
module_event_pass,<br />
/** reply inbound from server */<br />
module_event_reply,<br />
/** no reply, timeout or other error */<br />
module_event_noreply,<br />
/** reply is there, but capitalisation check failed */<br />
module_event_capsfail,<br />
/** next module is done, and its reply is awaiting you */<br />
module_event_moddone,<br />
/** error */<br />
module_event_error<br />
};<br />
</code></p>
<p>其中<code>reply</code>、<code>noreply</code>、<code>capsfail</code>都是向外进行的询问被回答时传递的，<code>moddone</code>和<code>pass</code>比较明显。<code>noreply</code>和<code>reply</code>都是字面意思，reply了空也算<code>reply</code>。<code>capsfail</code>是说虽然有reply，但是这个reply是攻击者伪造的而非被询问者的回复。</p>
<p>caps是指Capitalisation randomisation，又叫dns0x20。是通过改变请求的大小写增加随机性避免暴力投毒的办法。穷举所有一般只要2^30。通过这个再增加8bits（平均）的安全性…</p>
<p>module的<code>clear()</code>和<code>inform_super()</code>的注释解释得不太具体。</p>
<p><code>clear()</code>通常用来清除<code>qstate</code>相关的module数据（一般只用清理<code>minfo[id]</code>）。这里比较特殊，module在处理query时，请求内存应该用<code>regional_alloc()</code>函数，具体可参考<code>iterator/iterator.c:iter_new()</code>，被<code>regional_alloc()</code>的内存无须手工释放，它会在query的计算结束时自动被释放。因此<code>clear()</code>最多只需要把<code>minfo[id]</code>重设为<code>NULL</code>。</p>
<p><code>inform_super()</code>在两种情况下会被调用：subquery的计算结束、subquery由于计算时间太长被程序终止。此时父query的当前模块的<code>inform_super()</code>函数会被调用。看名字会误以为是subquery的某个模块的<code>inform_super()</code>被调用。之后父query会被设置为可执行，因此不必在此时进行<code>operate()</code>。我不知道为什么unbound要把<code>inform_super()</code>分开而不是在<code>operate()</code>时像外界询问被回复后传递<code>outbound_entry</code>一样把subquery作为附加参数一起传递进来，这样<code>inform_super()</code>就根本不需要了。</p>
<p>最后，模块执行时创建subquery和创建外部询问的方法可以分别参考<code>validatorator.c:generate_request()</code>和<code>ititerator.c:processQueryTargets()</code>最后几行。</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/319/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/319/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/319/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=319&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/10/18/unbound%e6%a8%a1%e5%9d%97%e7%ae%80%e8%a6%81%e8%af%b4%e6%98%8e/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>被我坑了一年半的项目pfdns，终于有望在今年写出来了</title>
		<link>http://yangzhe1990.wordpress.com/2011/10/08/%e8%a2%ab%e6%88%91%e5%9d%91%e4%ba%86%e4%b8%80%e5%b9%b4%e5%8d%8a%e7%9a%84%e9%a1%b9%e7%9b%aepfdns%ef%bc%8c%e7%bb%88%e4%ba%8e%e6%9c%89%e6%9c%9b%e5%9c%a8%e4%bb%8a%e5%b9%b4%e5%86%99%e5%87%ba%e6%9d%a5/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/10/08/%e8%a2%ab%e6%88%91%e5%9d%91%e4%ba%86%e4%b8%80%e5%b9%b4%e5%8d%8a%e7%9a%84%e9%a1%b9%e7%9b%aepfdns%ef%bc%8c%e7%bb%88%e4%ba%8e%e6%9c%89%e6%9c%9b%e5%9c%a8%e4%bb%8a%e5%b9%b4%e5%86%99%e5%87%ba%e6%9d%a5/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 18:10:28 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=314</guid>
		<description><![CDATA[项目的地址在http://code.google.com/p/pfdns/，是给多线的网络设计的DNS。提出这个设想的背景自然是跟VPN有关。 虽然说既然是多线网络，路由表配置好了的话，也应该差不多好使了。过度蛋疼是不必要的。很多时候，选择dns的结果只是为了节省VPN流量和降低网络延时。 说说在教育网，大体上需要一个怎样的pfdns： 尽可能把图片、视频、下载、门户流量弄到教育网，如果他们有针对教育网的解析的话，不然延时就要命了，用户受不了 对于google等到处做了cdn的国际大站，不能解析到香港去，要用湾区的解析结果，这样从VPN出来只要不到10ms，各种有保证。 接下来就是策略性的了，偏向电信还是偏向联通。比如北大到电信好，以及设想pfdns的时候清华到联通还挺好的。所以对北大来的询问返回偏向电信的好，对清华偏向联通不错（已经不成立了）。 不过说到DNS的解决方案，由于pfdns被我自己坑了这么久，我在做电信+VPN解析或者联通+VPN解析的时候，没有沿用教育网的思路。而是对解析用了中国内、中国外的分割方法，设定bind的路由表，让它递归解析。询问中国的权威时，使用电信/联通的地址，而询问国外时，通过VPN。这是基于假设有愿望做国内智能解析的网站，基本上会把权威放到国内的。这个方法实践效果其实我挺满意的。 对教育网，是不能用这个方法的。一来，我没有一个能访问整个国内IP范围的教育网的机器。二来，不少国内的智能解析服务商十分不靠谱（是基本没一个靠谱），给清华IP（有时候清华IP并不被认为是教育网IP，因为whois……）的解析结果经常会出乎意料。就算给的结果正确，也总有这种情况发生：似乎外界都认为联通到教育网挺好的，所以给教育网的解析IP就是联通IP。而这并不是我想得到的结果。三就是虽然都是教育网，每个学校的网络不怎么一样的，甚至很不一样。 DNS是很复杂的，这是我一直坑着pfdns的主要原因。加上以前写tcp的async server也写错过，最终写了一个无bug的后来也不想用。作为懒人我看了看libex，文档有一部分没有看懂，使用它干活还算可以接受吧。总之觉得自己写网络通信什么的有点烦，UDP什么的还要recvmsg去看IP_PKTINFO。 最近看wikipedia的DNS服务器对比列表的时候，发现libunbound（虽然很早就知道unbound，且机器上一直装着libldns-dev）支持async得解析，并且意外发现unbound有一个叫做pymod的模块可以让用户根据需求编辑递归resolver解析的结果。 虽然文档不怎么详细，demo没告诉我我能做的所有事情。看了看代码我觉得unbound的模块和状态机设计应该可以让我完成我想做的事情。另外这几天用libunbound-python写了一下async的解析，对每个域名同时问几个upstream的DNS，最终根据它们的结果选择到底使用哪个结果。只可惜用python的binding无法把answer_packet拿出来，只好写C了。<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=314&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>项目的地址在<a href="http://code.google.com/p/pfdns/">http://code.google.com/p/pfdns/</a>，是给多线的网络设计的DNS。提出这个设想的背景自然是跟VPN有关。</p>
<p>虽然说既然是多线网络，路由表配置好了的话，也应该差不多好使了。过度蛋疼是不必要的。很多时候，选择dns的结果只是为了节省VPN流量和降低网络延时。</p>
<p>说说在教育网，大体上需要一个怎样的pfdns：</p>
<ul>
<li>尽可能把图片、视频、下载、门户流量弄到教育网，如果他们有针对教育网的解析的话，不然延时就要命了，用户受不了</li>
<li>对于google等到处做了cdn的国际大站，不能解析到香港去，要用湾区的解析结果，这样从VPN出来只要不到10ms，各种有保证。</li>
<li>接下来就是策略性的了，偏向电信还是偏向联通。比如北大到电信好，以及设想pfdns的时候清华到联通还挺好的。所以对北大来的询问返回偏向电信的好，对清华偏向联通不错（已经不成立了）。</li>
</ul>
<p>不过说到DNS的解决方案，由于pfdns被我自己坑了这么久，我在做电信+VPN解析或者联通+VPN解析的时候，没有沿用教育网的思路。而是对解析用了中国内、中国外的分割方法，设定bind的路由表，让它递归解析。询问中国的权威时，使用电信/联通的地址，而询问国外时，通过VPN。这是基于假设有愿望做国内智能解析的网站，基本上会把权威放到国内的。这个方法实践效果其实我挺满意的。</p>
<p>对教育网，是不能用这个方法的。一来，我没有一个能访问整个国内IP范围的教育网的机器。二来，不少国内的智能解析服务商十分不靠谱（是基本没一个靠谱），给清华IP（有时候清华IP并不被认为是教育网IP，因为whois……）的解析结果经常会出乎意料。就算给的结果正确，也总有这种情况发生：似乎外界都认为联通到教育网挺好的，所以给教育网的解析IP就是联通IP。而这并不是我想得到的结果。三就是虽然都是教育网，每个学校的网络不怎么一样的，甚至很不一样。</p>
<p>DNS是很复杂的，这是我一直坑着pfdns的主要原因。加上以前写tcp的async server也写错过，最终写了一个无bug的后来也不想用。作为懒人我看了看libex，文档有一部分没有看懂，使用它干活还算可以接受吧。总之觉得自己写网络通信什么的有点烦，UDP什么的还要recvmsg去看IP_PKTINFO。</p>
<p>最近看wikipedia的DNS服务器对比列表的时候，发现libunbound（虽然很早就知道unbound，且机器上一直装着libldns-dev）支持async得解析，并且意外发现unbound有一个叫做pymod的模块可以让用户根据需求编辑递归resolver解析的结果。</p>
<p>虽然文档不怎么详细，demo没告诉我我能做的所有事情。看了看代码我觉得unbound的模块和状态机设计应该可以让我完成我想做的事情。另外这几天用libunbound-python写了一下async的解析，对每个域名同时问几个upstream的DNS，最终根据它们的结果选择到底使用哪个结果。只可惜用python的binding无法把answer_packet拿出来，只好写C了。</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/314/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/314/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/314/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=314&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/10/08/%e8%a2%ab%e6%88%91%e5%9d%91%e4%ba%86%e4%b8%80%e5%b9%b4%e5%8d%8a%e7%9a%84%e9%a1%b9%e7%9b%aepfdns%ef%bc%8c%e7%bb%88%e4%ba%8e%e6%9c%89%e6%9c%9b%e5%9c%a8%e4%bb%8a%e5%b9%b4%e5%86%99%e5%87%ba%e6%9d%a5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>回转企鹅罐 ED3</title>
		<link>http://yangzhe1990.wordpress.com/2011/10/08/%e5%9b%9e%e8%bd%ac%e4%bc%81%e9%b9%85%e7%bd%90-ed3/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/10/08/%e5%9b%9e%e8%bd%ac%e4%bc%81%e9%b9%85%e7%bd%90-ed3/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 17:18:46 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=312</guid>
		<description><![CDATA[一直想在正式的场合（blog）表现的很认真，但反而觉得每天在校内发GalGame截图和翻译的(在汉化组的)朋友、在打扮得很宅的blog上写下自己心情的朋友们很幸福。 前一段时间看到@virushuo关于博客和自我的观点，让我重拾wordpress写了一点东西，对我做了的事情聊作记录，毕竟连纪念都说不上。在我那快要被心因性遺忘失去并且不想找回来的大三大四之后，总想做点什么找回自我的事情。 说起来我不喜欢做VPN什么的。都只不过是我的死脑筋而已，我认为应该有的东西，没有的话我就要自己做出来它，而且它要足够reasonable。 晚上不知道怎么说起我想干什么，会这个多好啊，的，尽管说到爱好是不能当饭吃的，其实我想说有爱真好。世上太多美好的东西，向往但又一个也抓不住。 http://www.bilibili.tv/video/av153960/ 所以我要把歌词抄下来。还不会日语就抄翻译过来。 无法传达的思念 被撕裂的羁绊 宛若一片空白 云朵静静流淌 灰色的星期三 来吧回想起来吧 那曾经闪耀的时刻 所有的一切如此耀眼 那坠入爱恋的时刻 来吧回想起来吧 那相思相爱的时刻 以无比认真的眼神 那互相凝望的时刻 来吧回想起来吧 那曾经闪耀的时刻 那与梦为伴的时刻 那相思相爱的时刻<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=312&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>一直想在正式的场合（blog）表现的很认真，但反而觉得每天在校内发GalGame截图和翻译的(在汉化组的)朋友、在打扮得很宅的blog上写下自己心情的朋友们很幸福。</p>
<p>前一段时间看到@virushuo关于博客和自我的观点，让我重拾wordpress写了一点东西，对我做了的事情聊作记录，毕竟连纪念都说不上。在我那快要被心因性遺忘失去并且不想找回来的大三大四之后，总想做点什么找回自我的事情。</p>
<p>说起来我不喜欢做VPN什么的。都只不过是我的死脑筋而已，我认为应该有的东西，没有的话我就要自己做出来它，而且它要足够reasonable。</p>
<p>晚上不知道怎么说起我想干什么，会这个多好啊，的，尽管说到爱好是不能当饭吃的，其实我想说有爱真好。世上太多美好的东西，向往但又一个也抓不住。</p>
<p><a href="http://www.bilibili.tv/video/av153960/">http://www.bilibili.tv/video/av153960/</a></p>
<p>所以我要把歌词抄下来。还不会日语就抄翻译过来。</p>
<p>无法传达的思念<br />
被撕裂的羁绊<br />
宛若一片空白<br />
云朵静静流淌<br />
灰色的星期三<br />
来吧回想起来吧<br />
那曾经闪耀的时刻<br />
所有的一切如此耀眼<br />
那坠入爱恋的时刻<br />
来吧回想起来吧<br />
那相思相爱的时刻<br />
以无比认真的眼神<br />
那互相凝望的时刻<br />
来吧回想起来吧<br />
那曾经闪耀的时刻<br />
那与梦为伴的时刻<br />
那相思相爱的时刻</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/312/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/312/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/312/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=312&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/10/08/%e5%9b%9e%e8%bd%ac%e4%bc%81%e9%b9%85%e7%bd%90-ed3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>配置owamp通过带外通信测量单向延时丢包信息</title>
		<link>http://yangzhe1990.wordpress.com/2011/09/02/outband-owamp/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/09/02/outband-owamp/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 16:38:09 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=298</guid>
		<description><![CDATA[主机A到主机B之间有某条待测线路C&#60;-&#62;D，其中A、B、C、D均为IP地址，A、B为公网地址，C、D为内网地址。C&#60;-&#62;D线路上可能出现极端的丢包情况，也可能是某个单向出现问题，这时却因为owamp无法建立控制连接导致不能测量单向丢包。 owamp设计时是允许通过别的链路建立控制连接进行测量的。 在owping的参数中，可以增加创建控制连接用的server地址。但是3.2rc4版本的实现中，在上述背景下，owping会通过A创建到B的控制连接，随后进行的是A和D这两个地址之间的单向延时丢包信息，不是C&#60;-&#62;D。owping的-S选项在manpage中说会将本地socket绑定到指定的IP上，然而它会将控制连接和测试的本地IP都指定为源地址。此时，指定-S C后，C到B根本无法创建控制连接（公网、内网不互通），也无法正确测试C&#60;-&#62;D的单向延时丢包信息。 为此我修改了owping的代码，将-S参数的作用仅仅限定为测试时使用这个本地地址，控制连接不绑定到本地IP。补丁见：owping.patch。 在patch代码后，owping就是通过系统（自动使用地址A）创建到B的控制连接，再测量C&#60;-&#62;D链路了。然而patch owping的代码仍然不能正确运行：为了防止owping被用来攻击，（B上运行的）owampd拒绝了测试IP（C）跟控制连接的客户端（A）不同的测试请求。 /* * Check for possible DoS as advised in Section 7 of owdp * spec. * (control-client MUST be receiver if openmode.) */ 阅读owamp/sapi.c可以发现，只要不是openmode，这种测量行为就被允许。 为此，只要对owping和owampd加上验证信息，并进行正确配置。 增加验证信息的方式十分简单：在B上执行pfstore -f /etc/owampd/owampd.pfs -n yangzhe输入密码即可创建yangzhe的认证信息。将owampd.pfs中yangzhe这行复制到机器A的owampd.pfs中去。 在owampd.limits中，还可以增加assign user yangzhe root取消用户yangzhe的流量限制。 在B上重启owampd后，在A上就可以通过owping -S C -i 0.001 -c 1000 -k /etc/owampd/owampd.pfs -u yangzhe D B以0.001秒的间隔来回发送1000个数据包对C&#60;-&#62;D线路进行双向测试了，并且控制连接是在A、B间建立的，不用担心C&#60;-&#62;D本身的不稳定造成无法测量。<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=298&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>主机A到主机B之间有某条待测线路C&lt;-&gt;D，其中A、B、C、D均为IP地址，A、B为公网地址，C、D为内网地址。C&lt;-&gt;D线路上可能出现极端的丢包情况，也可能是某个单向出现问题，这时却因为<code>owamp</code>无法建立控制连接导致不能测量单向丢包。</p>
<p><code>owamp</code>设计时是允许通过别的链路建立控制连接进行测量的。</p>
<p>在<code>owping</code>的参数中，可以增加创建控制连接用的server地址。但是3.2rc4版本的实现中，在上述背景下，<code>owping</code>会通过A创建到B的控制连接，随后进行的是A和D这两个地址之间的单向延时丢包信息，不是C&lt;-&gt;D。<code>owping</code>的-S选项在manpage中说会将本地socket绑定到指定的IP上，然而它会将控制连接和测试的本地IP都指定为源地址。此时，指定-S C后，C到B根本无法创建控制连接（公网、内网不互通），也无法正确测试C&lt;-&gt;D的单向延时丢包信息。</p>
<p>为此我修改了<code>owping</code>的代码，将-S参数的作用仅仅限定为测试时使用这个本地地址，控制连接不绑定到本地IP。补丁见：<a href="http://yangzhe1990.files.wordpress.com/2011/09/owping-patch.ppt">owping.patch</a>。</p>
<p>在patch代码后，<code>owping</code>就是通过系统（自动使用地址A）创建到B的控制连接，再测量C&lt;-&gt;D链路了。然而patch <code>owping</code>的代码仍然不能正确运行：为了防止<code>owping</code>被用来攻击，（B上运行的）<code>owampd</code>拒绝了测试IP（C）跟控制连接的客户端（A）不同的测试请求。</p>
<pre>        /*
         * Check for possible DoS as advised in Section 7 of owdp
         * spec.
         * (control-client MUST be receiver if openmode.)
         */</pre>
<p>阅读<code>owamp/sapi.c</code>可以发现，只要不是openmode，这种测量行为就被允许。</p>
<p>为此，只要对<code>owping</code>和<code>owampd</code>加上验证信息，并进行正确配置。</p>
<p>增加验证信息的方式十分简单：在B上执行<code>pfstore -f /etc/owampd/owampd.pfs -n yangzhe</code>输入密码即可创建<code>yangzhe</code>的认证信息。将<code>owampd.pfs</code>中<code>yangzhe</code>这行复制到机器A的<code>owampd.pfs</code>中去。</p>
<p>在<code>owampd.limits</code>中，还可以增加<code>assign user yangzhe root</code>取消用户yangzhe的流量限制。</p>
<p>在B上重启<code>owampd</code>后，在A上就可以通过<code>owping -S C -i 0.001 -c 1000 -k /etc/owampd/owampd.pfs -u yangzhe D B</code>以0.001秒的间隔来回发送1000个数据包对C&lt;-&gt;D线路进行双向测试了，并且控制连接是在A、B间建立的，不用担心C&lt;-&gt;D本身的不稳定造成无法测量。</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/298/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/298/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/298/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=298&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/09/02/outband-owamp/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>owamp测量单向延时、丢包</title>
		<link>http://yangzhe1990.wordpress.com/2011/08/31/owamp/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/08/31/owamp/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 15:47:56 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=284</guid>
		<description><![CDATA[中国互联网极其坑爹，在很多情况下，为了更加清楚地了解问题所在，需要对单向延时、丢包率进行测量。 owamp的网站地址在http://www.internet2.edu/performance/owamp/index.html。由于它是用来测量单向延时的，这要求两端的机器时钟必须同步。 时钟同步 服务器可以安装ntp进行时间同步。必须注意的是，为了得到精确时间，所选NTP服务器和本地服务器之间的延时应该对称的，也就是往返所需时间相等。另外NTP服务器和本地服务器之间的延时应该稳定，否则时钟会随时间漂移。 根据经验，即使在同一城市同一ISP，在一天之内延时都可能有1ms左右的波动。因此对NTP的精度要求在精确到若干毫秒就可以了。 在坑爹的中国网络中，寻找一个可以将本地时间同步精确到若干毫秒的NTP服务器难上加难。国家授时中心的NTP服务器尽管是多线路的，不受电信、联通难以互通之影响，然而电信和联通也不能保障从北京到用户所在地一天24小时内延时稳定。例如联通存在南北互通问题、电信存在“CHINANET核心压力很大”的问题。教育网的s2a.time.edu.cn和s2b.time.edu.cn跟标准时间相差340ms左右，也不可用。 我目前使用的NTP服务器分别是： 清华大学（北京教育网）：ntp.cuhk.edu.hk的ipv6地址和ntp2.cuhk.edu.hk(ipv4)和另一个ipv6地址用来中转clock.isc.org //ipv6不稳定的学校例如北大、北邮就不必使用ntp.cuhk.edu.hk的ipv6地址了。即便清华ipv6目前没有问题也不能过于相信ipv6，首选ntp设置为了ntp2 上海片区电信：首先要确定本地到上海国际出口的延时是否稳定，在稳定的情况下，clock.isc.org可用。 联通：联通勉强可以用ntp2.cuhk.edu.hk，只不过联通到cuhk的延时有2ms左右的波动外加丢包。 美国：美国好啊，一般ISP都会提供ntp的，更别说各种机构了，并且一般延时稳定。我用的是clock.isc.org，ntp.nasa.gov对比观察。 这套组合我验证过了在清华、美国、电信、联通的机器如此设置相互间的时钟相差在2ms以内。 其中ntp2.cuhk.edu.hk跟clock.isc.org基本无差别（小于0.5ms）、clock.isc.org和ntp.nasa.gov有3ms左右的差别。 安装owamp 我的系统是Debian，目前还没有Debian安装包，因此要手动编译。configure时指定 ./configure --prefix=/usr --exec-prefix=/usr --libexecdir=/usr/lib/owampd --sysconfdir=/etc/owampd --sharedstatedir=/var/lib --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info 安装后复制conf/目录中的owampd.conf、owampd.limits到/etc/owampd/，并编辑owampd.conf中的datadir。（/var/lib/owampd/ ?) 启动owampd的命令行为owampd -c /etc/owampd -R /var/run/。可能要在运行owampd之前运行ntptime -N。 处理owping数据 owping的运行参数设置为-i 0.001 -R -L 1较方便。 -R选项对应的输出格式是每行输出SEQNO SENDTIME SSYNC SERR RECVTIME RSYNC RERR TTL。其中TIME的格式是：高32位是从1900年1月1日到现在的秒数（不是Epoch time），低32位是纳秒数/10^9 * 2^32。 记录是按照收到回复的顺序排列的，最后会补上没有收到回复的记录并将RECVTIME标记为0。<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=284&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>中国互联网极其坑爹，在很多情况下，为了更加清楚地了解问题所在，需要对单向延时、丢包率进行测量。</p>
<p>owamp的网站地址在<a href="http://www.internet2.edu/performance/owamp/index.html" target="_blank">http://www.internet2.edu/performance/owamp/index.html</a>。由于它是用来测量单向延时的，这要求两端的机器时钟必须同步。</p>
<h2>时钟同步</h2>
<p>服务器可以安装ntp进行时间同步。必须注意的是，为了得到精确时间，所选NTP服务器和本地服务器之间的延时应该对称的，也就是往返所需时间相等。另外NTP服务器和本地服务器之间的延时应该稳定，否则时钟会随时间漂移。</p>
<p>根据经验，即使在同一城市同一ISP，在一天之内延时都可能有1ms左右的波动。因此对NTP的精度要求在精确到若干毫秒就可以了。</p>
<p>在坑爹的中国网络中，寻找一个可以将本地时间同步精确到若干毫秒的NTP服务器难上加难。国家授时中心的NTP服务器尽管是多线路的，不受电信、联通难以互通之影响，然而电信和联通也不能保障从北京到用户所在地一天24小时内延时稳定。例如联通存在南北互通问题、电信存在“CHINANET核心压力很大”的问题。教育网的<code>s2a.time.edu.cn</code>和<code>s2b.time.edu.cn</code>跟标准时间相差340ms左右，也不可用。</p>
<p>我目前使用的NTP服务器分别是：</p>
<p>清华大学（北京教育网）：<code>ntp.cuhk.edu.hk</code>的ipv6地址和<code>ntp2.cuhk.edu.hk</code>(ipv4)和另一个ipv6地址用来中转<code>clock.isc.org</code> //ipv6不稳定的学校例如北大、北邮就不必使用<code>ntp.cuhk.edu.hk</code>的ipv6地址了。即便清华ipv6目前没有问题也不能过于相信ipv6，首选ntp设置为了ntp2<br />
上海片区电信：首先要确定本地到上海国际出口的延时是否稳定，在稳定的情况下，<code>clock.isc.org</code>可用。<br />
联通：联通勉强可以用<code>ntp2.cuhk.edu.hk</code>，只不过联通到cuhk的延时有2ms左右的波动外加丢包。<br />
美国：美国好啊，一般ISP都会提供ntp的，更别说各种机构了，并且一般延时稳定。我用的是<code>clock.isc.org</code>，<code>ntp.nasa.gov</code>对比观察。</p>
<p>这套组合我验证过了在清华、美国、电信、联通的机器如此设置相互间的时钟相差在2ms以内。</p>
<p>其中<code>ntp2.cuhk.edu.hk</code>跟<code>clock.isc.org</code>基本无差别（小于0.5ms）、<code>clock.isc.org</code>和<code>ntp.nasa.gov</code>有3ms左右的差别。</p>
<h2>安装owamp</h2>
<p>我的系统是Debian，目前还没有Debian安装包，因此要手动编译。configure时指定<br />
<code>./configure --prefix=/usr --exec-prefix=/usr --libexecdir=/usr/lib/owampd --sysconfdir=/etc/owampd --sharedstatedir=/var/lib --localstatedir=/var --mandir=/usr/share/man --infodir=/usr/share/info</code><br />
安装后复制<code>conf/</code>目录中的<code>owampd.conf</code>、<code>owampd.limits</code>到<code>/etc/owampd/</code>，并编辑<code>owampd.conf</code>中的datadir。（<code>/var/lib/owampd/</code> ?)</p>
<p>启动<code>owampd</code>的命令行为<code>owampd -c /etc/owampd -R /var/run/</code>。可能要在运行<code>owampd</code>之前运行<code>ntptime -N</code>。</p>
<h2>处理owping数据</h2>
<p><code>owping</code>的运行参数设置为<code>-i 0.001 -R -L 1</code>较方便。</p>
<p><code>-R</code>选项对应的输出格式是每行输出<code>SEQNO SENDTIME SSYNC SERR RECVTIME RSYNC RERR TTL</code>。其中TIME的格式是：高32位是从1900年1月1日到现在的秒数（<span style="color:#ff0000;">不是Epoch time</span>），低32位是纳秒数/10^9 * 2^32。</p>
<p>记录是按照收到回复的顺序排列的，最后会补上没有收到回复的记录并将RECVTIME标记为0。</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/284/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/284/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/284/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=284&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/08/31/owamp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>增加、删除、修改RRD文件中的DS、RRA记录</title>
		<link>http://yangzhe1990.wordpress.com/2011/08/31/%e7%bc%96%e8%be%91rrd%e6%96%87%e4%bb%b6/</link>
		<comments>http://yangzhe1990.wordpress.com/2011/08/31/%e7%bc%96%e8%be%91rrd%e6%96%87%e4%bb%b6/#comments</comments>
		<pubDate>Wed, 31 Aug 2011 07:46:18 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=278</guid>
		<description><![CDATA[最近想变更RRD的存储内容，再对RRA进行扩容，保存1年多的5分钟数据备查，却在rrdtool提供的action中找不到合适的方法。 用rrddump生成xml编辑后rrdrestore出来不失为一种办法，不过对扩容来说要生成过大的文本文件，并且脚本处理xml比较麻烦。 后来找到了perl Module RRD-Editor能完成这类任务。这个Module使用起来也很简便，例如我要修改前4个RRA的大小，删除后4个RRA（共8个），只要执行如下perl程序： #!/usr/bin/env perl use strict; use RRD::Editor (); if (@ARGV &#60; 1) { print "USAGE: $0 &#60;rrd file name&#62;\n"; exit 1; } my $rrd = RRD::Editor-&#62;new(); $rrd-&#62;open($ARGV[0]); for (my $i = 4; $i &#60; 8; ++$i) { $rrd-&#62;delete_RRA(4); } $rrd-&#62;resize_RRA(0, 105408); $rrd-&#62;resize_RRA(1, 35136); $rrd-&#62;resize_RRA(2, 8784); $rrd-&#62;resize_RRA(3, 732); $rrd-&#62;save();<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=278&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>最近想变更RRD的存储内容，再对RRA进行扩容，保存1年多的5分钟数据备查，却在rrdtool提供的action中找不到合适的方法。</p>
<p>用rrddump生成xml编辑后rrdrestore出来不失为一种办法，不过对扩容来说要生成过大的文本文件，并且脚本处理xml比较麻烦。</p>
<p>后来找到了perl Module <a title="RRD-Editor" href="http://search.cpan.org/~dougleith/RRD-Editor-0.09/lib/RRD/Editor.pm" target="_blank">RRD-Editor</a>能完成这类任务。这个Module使用起来也很简便，例如我要修改前4个RRA的大小，删除后4个RRA（共8个），只要执行如下perl程序：</p>
<pre style="padding-left:30px;">#!/usr/bin/env perl

use strict;
use RRD::Editor ();

if (@ARGV &lt; 1) {
    print "USAGE: $0 &lt;rrd file name&gt;\n";
    exit 1;
}

my $rrd = RRD::Editor-&gt;new();
$rrd-&gt;open($ARGV[0]);

for (my $i = 4; $i &lt; 8; ++$i) {
     $rrd-&gt;delete_RRA(4);
}

$rrd-&gt;resize_RRA(0, 105408);
$rrd-&gt;resize_RRA(1, 35136);
$rrd-&gt;resize_RRA(2, 8784);
$rrd-&gt;resize_RRA(3, 732);

$rrd-&gt;save();</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/278/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/278/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/278/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=278&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2011/08/31/%e7%bc%96%e8%be%91rrd%e6%96%87%e4%bb%b6/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
		<item>
		<title>活在错误的基础之上</title>
		<link>http://yangzhe1990.wordpress.com/2010/11/15/%e6%b4%bb%e5%9c%a8%e9%94%99%e8%af%af%e7%9a%84%e5%9f%ba%e7%a1%80%e4%b9%8b%e4%b8%8a/</link>
		<comments>http://yangzhe1990.wordpress.com/2010/11/15/%e6%b4%bb%e5%9c%a8%e9%94%99%e8%af%af%e7%9a%84%e5%9f%ba%e7%a1%80%e4%b9%8b%e4%b8%8a/#comments</comments>
		<pubDate>Sun, 14 Nov 2010 16:13:11 +0000</pubDate>
		<dc:creator>yangzhe1990</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://yangzhe1990.wordpress.com/?p=273</guid>
		<description><![CDATA[很久很久以前我很鄙视写CSS这行，因为要应对各种浏览器bug。而且这行还缺人。因为是个人都需要至少半年学会，并且以后的工作全是重复。写浏览器的人总会希望，有那么一天，自己的浏览器没有bug了吧。如果这一天真的来了，那些写CSS的人是不是都可以去死了？ 说到正题：教育网目前有多糟糕有目共睹，晚上到电信丢包10%。这简直就是没有人愿意花钱用的网络了（我指包月）。没有人愿意花钱，就没有钱用来改造，恶性循环。 接下来我们来比较清华和北大：清华绝对是个更官僚的地方。 北大为了改善上网环境，专门购买了电信通的500M光纤接入。其实价格也就一年50万多而已。平均到1万人，一人一年只有50元。得到的是在晚上网络使用高峰连接电信的速度仍然有200KB/s以上，经常可以达到500KB/s。 听说当年北大把每个月网费从5元涨到10元的时候还有学生群起抗议。在这点上我觉得聪明的独裁比乌合之众强不知道多少倍。比傻逼的官僚更不知道强多少倍。 以上是清华和教育网的错误。而我们每一个人，很不幸得活在这个错误之上。我，就更不幸得活在了一个更大的错误之上。还居然动过花3万一年从电信通搞个10M的微波接入到机房的念头。 再看电信通和北京联通：实际上这两个在北京恶评也不小。俩字“垄断”。你看10M的接入都3万一年。然而联通的20M FTTH虽然每个月只要不到600元，却只有部分地方可以接入。我们设想3年后，联通的北京网络改造完成，清华可以接入联通的光纤了（好吧就算清华你不接，我接可以了吧？），情况又是怎样？ &#160;<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=273&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>很久很久以前我很鄙视写CSS这行，因为要应对各种浏览器bug。而且这行还缺人。因为是个人都需要至少半年学会，并且以后的工作全是重复。写浏览器的人总会希望，有那么一天，自己的浏览器没有bug了吧。如果这一天真的来了，那些写CSS的人是不是都可以去死了？</p>
<p>说到正题：教育网目前有多糟糕有目共睹，晚上到电信丢包10%。这简直就是没有人愿意花钱用的网络了（我指包月）。没有人愿意花钱，就没有钱用来改造，恶性循环。</p>
<p>接下来我们来比较清华和北大：清华绝对是个更官僚的地方。</p>
<p>北大为了改善上网环境，专门购买了电信通的500M光纤接入。其实价格也就一年50万多而已。平均到1万人，一人一年只有50元。得到的是在晚上网络使用高峰连接电信的速度仍然有200KB/s以上，经常可以达到500KB/s。</p>
<p>听说当年北大把每个月网费从5元涨到10元的时候还有学生群起抗议。在这点上我觉得聪明的独裁比乌合之众强不知道多少倍。比傻逼的官僚更不知道强多少倍。</p>
<p>以上是清华和教育网的错误。而我们每一个人，很不幸得活在这个错误之上。我，就更不幸得活在了一个更大的错误之上。还居然动过花3万一年从电信通搞个10M的微波接入到机房的念头。</p>
<p>再看电信通和北京联通：实际上这两个在北京恶评也不小。俩字“垄断”。你看10M的接入都3万一年。然而联通的20M FTTH虽然每个月只要不到600元，却只有部分地方可以接入。我们设想3年后，联通的北京网络改造完成，清华可以接入联通的光纤了（好吧就算清华你不接，我接可以了吧？），情况又是怎样？</p>
<p>&nbsp;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/yangzhe1990.wordpress.com/273/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/yangzhe1990.wordpress.com/273/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/yangzhe1990.wordpress.com/273/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=yangzhe1990.wordpress.com&amp;blog=7908676&amp;post=273&amp;subd=yangzhe1990&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://yangzhe1990.wordpress.com/2010/11/15/%e6%b4%bb%e5%9c%a8%e9%94%99%e8%af%af%e7%9a%84%e5%9f%ba%e7%a1%80%e4%b9%8b%e4%b8%8a/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">yangzhe1990</media:title>
		</media:content>
	</item>
	</channel>
</rss>
