2006-06-23

人生本是賤 - 我的OS term project

人生本是賤 - 我的OS term projectThis entry was originally published at 抓~ 抓到一隻瞌睡蟲

從大三專題做sniffer到現在要研二了, 連個OS term project也是做sniffer, 酷威…

喔, 其實是因為我覺得這個寫出來的OS沒有網路相當於一個人沒有了眼睛, 沒有disk-IO的作業系統相當於一個人沒有了嘴巴跟屁股… (為什麼是沒眼睛呢? 因為沒有網路, 就不能上網看美圖了.)

為了醫治這個作業系統的眼疾(那無嘴症和無肛症呢? 那個在上上次作業的時候參考linux的DMA controller和floppy driver解決了.), 又是參考linux的network的東西…

在崔死扣的過程中, 我發現有一堆(一堆一堆一堆一堆), network device driver裡面, 都有(我有看過的部份都有!)Donald Becker這位老兄, 現在project寫完了, 要感謝的人太多了, 就感謝Donald Becker吧. XD

qemu給你看page directory長得像怎樣

qemu給你看page directory長得像怎樣This entry was originally published at 抓~ 抓到一隻瞌睡蟲

我的page directory長得像這樣

paging

好吧, 是因為上次demo作業想要拿出來用的, 不過助教不准這個偷吃步.

tap interface

tap interfaceThis entry was originally published at 抓~ 抓到一隻瞌睡蟲

剛剛發現一件事情, 根據linux kernel的documentation/networking/tuntap的部份

2. What is TUN/TAP driver used for?
As mentioned above, main purpose of TUN/TAP driver is tunneling.
It is used by VTun (http://vtun.sourceforge.net).

Another interesting application using TUN/TAP is pipsecd
(http://perso.enst.fr/~beyssac/pipsec/), an userspace IPSec
implementation that can use complete kernel routing (unlike FreeS/WAN).

3. How does Virtual network device actually work ?
Virtual network device can be viewed as a simple Point-to-Point or
Ethernet device, which instead of receiving packets from a physical
media, receives them from user space program and instead of sending
packets via physical media sends them to the user space program.

Let’s say that you configured IPX on the tap0, then whenever
the kernel sends an IPX packet to tap0, it is passed to the application
(VTun for example). The application encrypts, compresses and sends it to
the other side over TCP or UDP. The application on the other side decompresses
and decrypts the data received and writes the packet to the TAP device,
the kernel handles the packet like it came from real physical device.

4. What is the difference between TUN driver and TAP driver?
TUN works with IP frames. TAP works with Ethernet frames.

This means that you have to read/write IP packets when you are using tun and
ethernet frames when using tap.

5. What is the difference between BPF and TUN/TAP driver?
BFP is an advanced packet filter. It can be attached to existing
network interface. It does not provide a virtual network interface.
A TUN/TAP driver does provide a virtual network interface and it is possible
to attach BPF to this interface.

第四點對我而言比較有用, 而且我另外發現的是, 之前說的惡搞raw socket的部份, 在tap interface上面是沒辦法搞定的, 要再找資料了.

我瞎了, 跑錯測試的程式… 其實可以work啊, 只是我沒有弄對interface的index而已. 有沒有比較聰明的方法拿到interface的index呢? 現在我是從/proc讀出來的.

怎麼不會interrupt呢? 囧

怎麼不會interrupt呢? 囧This entry was originally published at 抓~ 抓到一隻瞌睡蟲

上次把floppy controller的東西搞定以後, 為了簡單愚蠢可以demo, 原本mask掉的interrupt, 到現在都還沒有開回來…

結果試了半天, 最後才想起來根本就是mask掉沒有開, 難怪我的機器不會亂叫.

8259 PIC 我真不懂你啊 XD

2006-06-21

做投影片

做投影片This entry was originally published at 抓~ 抓到一隻瞌睡蟲

下午找到怎麼惡搞ethernet frame以後, 距離OS project又進了一步, 所以就context switch到作投影片, 不過我想到上次被靠腰說.

明明就是簡單的圖, 怎麼那麼多毛邊…

喔, 毛邊是我自己說的啦… 原因是存的檔案全都是BMP或者是PNG, 不是向量圖檔, 所以includegraphics就會長毛. 然後原本想再放一張圖的, 後來怕被靠腰, 所以就把spec上面的公式抄下來, 然後想辦法用matlab畫出來. 長成這個樣子.

moscqe_r

echo off;
R=0:0.1:100;
for i=1:length(R)
MOScqe(i) = 1 + 0.035 * R(i) + R(i) * (R(i) - 60) * (100 - R(i)) * 7 * (10^(-6));
end;
outx(1) = 68.5;
outy(1) = 1 + 0.035 * 68.5 + 68.5 * (68.5 - 60) * (100 - 68.5) * 7 * (10^(-6));
% Plotting commands follow
plot(R, MOScqe);
hold on;
plot(outx, outy, ‘-ro’);
title(’MOScqe as function of rating factor R’);
xlabel(’R');
ylabel(’MOScqe’);
grid on
set(gca, ‘YTick’,[1 2 3 4 4.5 5]);
set(gca, ‘YTickLabel’,{’1 Bad’;'2 Poor’;'3 Fair’;'4 Good’; ‘4.5′;’5 Excellent’});
axis([0 100 1 5]);

等一下用gnuplot畫好了…

UPDATED:
畫好了, 參考這個link
進gnuplot以後定義一下function

f(x) = 1+0.035*x+x*(x-60)*(100-x)*7*10**(-6)

moscqe_r_gnuplot

操人? 超人

操人? 超人This entry was originally published at 抓~ 抓到一隻瞌睡蟲

剛剛在白爛板看到的…

車牌賊:我叫「操人」員警:我還蝙蝠俠咧

快笑翻了

spoofing ethernet frame using linux raw socket

spoofing ethernet frame using linux raw socketThis entry was originally published at 抓~ 抓到一隻瞌睡蟲

要惡搞ethernet frame的話, 好像要用到raw socket, 至少一般的socket明顯是不行的, 由於本人是讀網路工程研究所裡面唯一一個不會socket programming的遜砲, 所以在惡搞之前要先survey一下…

手邊有linux跟FreeBSD的機器, 原本是想要先找FreeBSD的, 不過問google他先給我的答案是linux的.

linux的raw socket可以到data-link layer, 所以可以拿來惡搞ethernet header的部份, 不過在FreeBSD上面看起來就是只提供到可以惡搞network layer的樣子.

linux raw ethernet的寫法可以參照 Linux Network Performance

如果要在FreeBSD上面惡搞data-link layer的東西的話, 看來就是要考慮用libnet了, 不過我還在研究… 此libnet非彼libnet, 所以我也不知道到底是哪個, 看來是前者的樣子.

在freebsd-net的mailing list上面, 有人說可以用netgraph, 或者是bpf也可以惡搞, 再來參考看看吧, 大不了不要用FreeBSD去測就好了.

2006-06-19

最後一個夏天倒數中

最後一個夏天倒數中This entry was originally published at 抓~ 抓到一隻瞌睡蟲

16號的夜烤過後, 正是今年的畢業典禮, 今年的畢業典禮過後相當於宣告研究所的最後一個夏天要到了.

畢業典禮那天我一直跟著菜配到處拍照, 先是跟專題老師拍照. 菜配的專題老師, John是一個蠻有趣的老師, 不過有一個習慣, 跟學生約時間好像常常遲到 XD. 我是路人, 只是來拍照而已.

拍完了之後, 菜配要續攤跟高中同學拍照, 因為菜配是竹女資優班的, 所以他的同學當然也就是那些竹女資優班的囉. 簡單來講就是, 很好… 我體驗了當衣架的感覺, 還有當工具的感覺. 不過一群女生在一起的時候就是會一直講很多有的沒有的, 所以行進速度很慢, 大概花了三四十分鐘還在浩然沒有移動, 然後又帶不走.

後來菜佩的爸媽也來囉, 所以後來我們就趕快出去拍照, 等著跟校長合照. 接下來已經要換校長了, 我想這大概已經成了絕響, 所以一定要拍一下的. 不得不說一下, 四張照片所有人都在看不同的地方. XD

pictures, by yhsungpictures, by yhsungpictures, by yhsungpictures, by yhsung

然後我們接著再走回去六樓拍照, 還遇到傑出校友… 反正就是拍了不少照片就是了, 還蠻累的…

因為有了去年的經驗, 我們今年留在實驗室, 等到了要放煙火的時候才出現, 看完煙火又躲回實驗室. 所以就沒有再找其他人拍照了. 其實是因為我不想去畢業典禮啊, 去年參加過一次了, 今年的也沒什麼感覺… 看煙火之前還把星期五烤肉剩下的東西用實驗室的烤箱烤掉了一些, 起因是Hubert說他肚子餓了, 所以我就拿了肉片跟豆乾出來, 肉片烤起來還算正常, 可是豆乾怎麼辦呢? 最後我加了一些醬油下去, 幾乎變滷豆乾了… 有圖有真相

pictures, by yhsung

晚上十點在seven門口, 是系排喝酒團, 其實在我大二的時候, 是系排成熟團, 晚上宵夜我們都自己煮麵來吃, 有事沒事就煮火鍋. 大三以後就懶得這樣弄了, 再過一年就演進成系排喝酒團… 很多東西都是從校隊那邊過來的, 好的不學學壞的, 專門拿酒灌學弟, 真是太糟糕了.

去年我不知道為什麼會約要喝啤酒, 今年是喝伏特加和汽水, 因為威力強大, 所以今年就有三個人抓兔子. 更糟糕的應該就是有某人喝醉以後就講了很白痴的東西(十八禁)…

後來因為倒了太多人, 所以沒什麼人想繼續喝下去了, 所以最後是解決了三瓶伏特加而已, 倒是吃掉了一堆零食. 想想, 五年已經過去了, 只剩下不到一年的時間, 然後我總算要開始面對自己解決所有問題的階段了.

2006-06-17

FreeBSD locate.updatedb

FreeBSD的locate.updatedb, 是weekly-310, 要讓他不跑的話要改/etc/periodic.conf 加上 weekly_locate_enable=NO 詳情參考/etc/defaults/periodic.conf

跟VoIP相關的有趣文章?!

跟VoIP相關的有趣文章?!This entry was originally published at 抓~ 抓到一隻瞌睡蟲

其實有趣的不是文章, 而是讓我想到已經雨後快三年的春筍… 春筍啊春筍, 你哪個時候才會好吃呢?

參考這裡: 什麼是「VoIP」?