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