2013年7月16日 星期二

在windows讀取linux的磁區

http://www.diskinternals.com/linux-reader/

DiskInternals Linux Reader is a new easy way to do this. This program plays the role of a bridge between your Windows and Ext2/Ext3/Ext4, HFS and ReiserFS file systems.

Linux Reader is 100% FREE.

----

看起來應該是可以用!? XD

2013年6月26日 星期三

用shell script產生兩個不重複的亂數

#!/bin/bash
export PATH=/bin:/sbin:/usr/bin:/usr/sbin

n=`expr \( \( $RANDOM % 7 \) + 1 \)`
echo $n

m=`expr \( \( $RANDOM % 7 \) + 1 \)`

while [ $n == $m ]
  do
    m=`expr \( \( $RANDOM % 7 \) + 1 \)`
  done

echo $m

----

單純紀錄 XD

2013年5月23日 星期四

win7不能開機!! (安裝Fedora之後)

今天幫學弟裝Fedora, 然後要切回win7的時候, 竟然出現錯誤訊息, 不能開機. 囧

BOOTMGR is missing
Press Ctrl+Alt+Del to restart 


後來查了一下, 發現只要修改grub的選單就可以開進win7了. XD

ref: http://ubuntuforums.org/showthread.php?t=1159205

以我學弟為例, 他原本win7的選單是寫 (hd0,0), 改成 (hd0,1)就可以開機了. XDD

2013年5月21日 星期二

openwrt 的開機選單

其實只是存起來當備份而已. 科科

這樣就可以直接把這些選單語法加到Fedora的grub選單裡面,

直接用原本的開機選單選擇隨身碟開openwrt. XDD


title   OpenWrt
root    (hd0,0)
kernel  /boot/vmlinuz root=/dev/sda2 rootfstype=ext4 rootwait console=tty0 console=ttyS0,38400n8 noinitrd reboot=bios
boot

title   OpenWrt (failsafe)
root    (hd0,0)
kernel  /boot/vmlinuz failsafe=true root=/dev/sda2 rootfstype=ext4 rootwait console=tty0 console=ttyS0,38400n8 noinitrd reboot=bios
boot

2013年4月10日 星期三

把ns2(2.29, multichannel版)移到ubuntu

我用的版本是 Ubuntu 12.04.1 LTS
原本在Fedora10上面裝了ns2 with multichannel (2.29)

因為是整個資料夾移過去, 所以要重新安裝.

重新安裝的話, 我是先去各個資料夾make clean, 再把三個config.cache刪掉, 順便把ns-allinone-2.29/bin/裡面的link都刪掉, 最後再重新 ./install 就好了

只是在 ./install 過程中會出現一些錯誤訊息, 然後找到了這篇
Installing ns-2.29 in Ubuntu 12.04
http://www.nsnam.com/2012/06/installing-ns-229-in-ubuntu-1204.html

按照他的步驟去修改, 然後就安裝成功了 XD

-------
三個config.cache的位置
ns-allinone-2.29/xgraph-12.1/config.cache
ns-allinone-2.29/tcl8.4.11/unix/config.cache
ns-allinone-2.29/tk8.4.11/unix/config.cache


-------
進去每個資料夾make clean (其實只要找出Makefile在哪個資料夾, 就知道要去哪裡make clean了)

cd ns-allinone-2.29/cweb/
make clean
cd ns-allinone-2.29/cweb/examples/
make clean
cd ns-allinone-2.29/sgb/
make clean
cd ns-allinone-2.29/tclcl-1.17/
make clean
cd ns-allinone-2.29/otcl-1.11/
make clean
cd ns-allinone-2.29/zlib-1.2.3/
make clean
cd ns-allinone-2.29/zlib-1.2.3/contrib/blast/
make clean
cd ns-allinone-2.29/zlib-1.2.3/contrib/untgz/
make clean
cd ns-allinone-2.29/zlib-1.2.3/contrib/puff/
make clean
cd ns-allinone-2.29/zlib-1.2.3/contrib/minizip/
make clean
cd ns-allinone-2.29/xgraph-12.1/
make clean
cd ns-allinone-2.29/tcl8.4.11/macosx/
make clean
cd ns-allinone-2.29/tcl8.4.11/unix/
make clean
cd ns-allinone-2.29/tcl8.4.11/unix/dltest/
make clean
cd ns-allinone-2.29/nam-1.11/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/cmu-scen-gen/setdest/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/dosdbell/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/webtrace-conv/nlanr/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/webtrace-conv/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/webtrace-conv/epa/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/webtrace-conv/dec/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/webtrace-conv/ucb/
make clean
cd ns-allinone-2.29/ns-2.29/indep-utils/model-gen/
make clean
cd ns-allinone-2.29/ns-2.29/
make clean
cd ns-allinone-2.29/ns-2.29/ns-tutorial/
make clean
cd ns-allinone-2.29/ns-2.29/emulate/support/src/nrgarp/
make clean
cd ns-allinone-2.29/ns-2.29/doc/
make clean
cd ns-allinone-2.29/ns-2.29/doc/kfall/
make clean
cd ns-allinone-2.29/tk8.4.11/macosx/
make clean
cd ns-allinone-2.29/tk8.4.11/unix/
make clean
cd ns-allinone-2.29/gt-itm/sgb2ns/
make clean
cd ns-allinone-2.29/gt-itm/src/
make clean

在ubuntu上安裝freenx (Ubuntu 12.04.1 LTS)

原本想要在ubuntu上設定遠端, 可是vnc一直設定失敗 -.-
用內建的desktop share又很頓, 不知道為啥 orz...
最後就改用nxserver. XD
搞了很久終於可以看到畫面了   囧~~

------------------------------------------------------
我的版本是  Ubuntu 12.04.1 LTS

主要安裝流程  (請參考 https://help.ubuntu.com/community/FreeNX )

sudo apt-add-repository ppa:freenx-team
sudo sed -i 's/natty/lucid/g' /etc/apt/sources.list.d/freenx-team-ppa-natty.list
sudo apt-get update 
sudo apt-get install freenx
wget https://bugs.launchpad.net/freenx-server/+bug/576359/+attachment/1378450/+files/nxsetup.tar.gz
tar -xvf nxsetup.tar.gz 
sudo cp nxsetup /usr/lib/nx/nxsetup
sudo /usr/lib/nx/nxsetup --install 
(安裝完會跟你說key在哪裡) 

把key找出來, 複製, 待會在windows上裝好nx-client會用到
sudo cat /var/lib/nxserver/home/.ssh/client.id_dsa.key 

================================
NX Client for Windows
http://www.nomachine.com/download-package.php?Prod_Id=3835

================================
因為我設定完連線後,會出現!M的logo, 然後畫面是黑的, 過一陣子程式就關閉了.  囧
試了一堆方法後終於成功了, 可是我也不知道哪個才是關鍵, 所以就通通記下來 XDD

================================
 [ref1] http://wiki.centos.org/zh-tw/HowTos/FreeNX
 如果 nx 在最後一步連線失敗並停了下來,請檢查你在伺服器上的主目錄。刪除所有 .Xauthority* 檔(或把它們移往別處)然後重試。要是這樣沒有幫助,請嘗試移除 /tmp/.X11-unix。
 
編輯 /etc/nxserver/node.conf 並且更改此行:
#AGENT_EXTRA_OPTIONS_X="-nolisten tcp"

為:
AGENT_EXTRA_OPTIONS_X=""

================================
[ref2] https://help.ubuntu.com/community/FreeNX

[Enabling the PASSDB database]
編輯 /etc/nxserver/node.conf , 包含這句
ENABLE_PASSDB_AUTHENTICATION="1"

[Adding the User ID and Password to the database:]
sudo nxserver --adduser xxxx
sudo nxserver --passwd  xxxx

sudo vi /etc/ssh/sshd_config , 包含這句
AllowUsers nx xxxx

sudo service ssh restart


================================
[ref 3] http://notepad2.blogspot.com/2012/04/install-freenx-server-on-ubuntu-1110.html
我忘記改到啥東西, 看到錯誤訊息跳出來 (原本都不會跳), 然後訊息有gnome-fallback
後來在這個網頁看到說要安裝東西

[Install gnome-session-fallback:]
sudo apt-get install gnome-session-fallback

[Edit /usr/NX/etc/node.conf file as root, and enable the following line]
COMMAND_START_GNOME="gnome-session --session=gnome-fallback"

[Restart freenx server]
sudo /etc/init.d/freenx-server restart

------------------------------------------------------------------------------------

最後弄完 gnome-session-fallback 就可以看到畫面了 (感動)

而且速度也比內建的desktop share快很多 = =+

2013年2月13日 星期三

ns2很蠢的錯誤訊息 XD

今天跑實驗課的code, 一直出現
mobile/tworayground.cc: TwoRayGround propagation model assume flat ground

最後才發現, 原來我在設定node座標的時候, 有一個node的Z座標不是0.   XDDDDDD

Z座標通通弄成0就沒有這個錯誤訊息了.

--

天啊, 我怎麼會犯這麼蠢的問題 XD

2012年9月5日 星期三

ns2 - 安裝時遇到的錯誤訊息

Troubleshooting
http://nsnam.isi.edu/nsnam/index.php/Troubleshooting


http://ramakrishnamundugar.blogspot.tw/p/network-simulator-v2.html

2012年8月23日 星期四

ns2 - multi channel & 設定ll_(5)時發生錯誤訊息

http://www.cse.msu.edu/~wangbo1/ns2/nshowto8.html

原本的multi channel, 在添加新的interface時, 只有加五筆資料, 所以最多只能設定五個NIC資訊.

像我要設定ll_(5)時, 就會出現錯誤訊息了.
因為原本的code頂多只有到ll_(4)

(可參閱tcl/lib/ns-mobilenode.tcl)

========================================

簡單說, 如果我現在想要把NIC的資訊設定到8張網卡時, 要參考網址的修改資訊.
http://www.cse.msu.edu/~wangbo1/ns2/nshowto8.html

    1. Modifications in tcl/lib/ns-lib.tcl
    2. Modifications in tcl/lib/ns-mobilenode.tcl

像是原本語法是寫chan chan2 chan3 chan4 chan5, 那就在後面多加chan6, chan7, chan8.

還有$sndT5 target [$self set ll_(4)], 後面再多加$sndT6 target [$self set ll_(5)]....等

全部以此類推!!

========================================

還有ns-2.29/manual/manual.{cc, h}

在.h要NsObject *downtarget5_; 的後面多加三筆資訊

在.cc
1. 要在這個後面多加三組
  else if (prte->nic_id == 5)
      downtarget5_->recv(p, (Handler *)0);

2. 還有downtarget5_(0) 要再多三筆資訊

3. 這個也是
      else if (strcasecmp (argv[1], "down-target-5") == 0) {
          downtarget5_ = (NsObject *) obj;
          return TCL_OK;
      }  

========================================

大概就是這樣吧 zzzZZZ....

========================================
補充幾個容易忘記設定的檔案:
gedit ns-2.29/tcl/lib/ns-lib.tcl -> 設定MCMI的數量
gedit ns-2.29/tcl/lib/ns-mobilenode.tcl -> 設定MCMI的數量
gedit ns-2.29/mac/mac-802_11.cc -> 設定MCMI的數量

======================================== 
需要修改檔案的清單備份


Multi-channel Multi-interface Extension
1. Modifications in tcl/lib/ns-lib.tcl
2. Modifications in tcl/lib/ns-mobilenode.tcl
3. Modifications in mac/arp.cc
4. Modifications in mac/channel.h
5. Modifications in mac/channel.cc
6. Modifications in mac/mac-802_11.cc
Use Multi-channel Multi-interface — Manual Routing Protocol (proposed in Hyacinth)
7. Modifications in tcl/lib/ns-lib.tcl
8. Modifications in tcl/lib/ns-mobilenode.tcl
9. Modifications in common/packet.h
10. Modifications in apps/udp.h
11. Modifications in apps/udp.cc
12. Modifications in tcp/tcp.h
13. Modifications in tcp/tcp.cc
14. Modifications in tcp/tcp-sink.h
15. Modifications in tcp/tcp-sink.cc
16. Manual routing protocol implmentation and NS2 configuration
Simuilation Results
17. Simulation results for validating the extension

2012年6月28日 星期四

在XP上利用apache提供WebDAV服務

有天發現iPad似乎可以利用WebDAV的東西, 這樣就可以有超大的網路空間了 科科~

然後try了一下, 似乎是成功了, 只是我不知道要怎麼上傳檔案 -.-
下載, 讀取檔案的話倒是沒問題 = =+

1. 去安裝apache  ( 在 http://httpd.apache.org/download.cgi )
2. 進入apache的bin資料夾, 先建立你要的帳號, 以下為範例 (一行)
htdigest -c "C:/Program Files/Apache Software Foundation/Apache2.2/user.passwd" DAV-upload admin
(這個東西在 Apache2.2\cond\extra\httpd-dav.conf 有提到)

3. 進入apache安裝資料夾, 修改設定檔
( C:\Program Files\Apache Software Foundation\Apache2.2\conf )
需要修改 httpd.conf, 把裡面的這幾行前面的註解#刪掉

LoadModule dav_module modules/mod_dav.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule auth_digest_module modules/mod_auth_digest.so
Include conf/extra/httpd-dav.conf

4. 還要修改 extra資料夾下的httpd-dav.conf  (Apache2.2\cond\extra\httpd-dav.con)

設定你想要的資料夾, 以下也是一個範例 XD

Alias /upload "D:/dav_upload"


    Dav On

    Order Allow,Deny
    Allow from all

    AuthType Digest
    AuthName DAV-upload

    AuthUserFile "C:/Program Files/Apache Software Foundation/Apache2.2/user.passwd"
    AuthDigestProvider file

   
        require user admin
   


5. 最後去ipad找webdav的程式, 網址輸入http://xxxxxxxxx/upload
然後輸入自己的帳號密碼, 就可以看到本機電腦上的D:/dav_upload裡面的東西 = =+


在設定過程中有看了這幾個網頁:
http://herb123456.pixnet.net/blog/post/1009884-%E3%80%90apache%E3%80%91webdav-%E7%9B%B8%E9%97%9C%E8%A8%AD%E5%AE%9A
http://www.errorhelp.com/search/details/86393/invalid-command-authdigestprovider-perhaps-mis-spelled-or-defined-by-a-module-not-included-in-the-server-configuration
http://robert-linux.blogspot.tw/2009/10/ubuntu904-apache2-webdav.html
http://llls.cpshs.tyc.edu.tw/mediawiki/index.php?title=%E8%A8%AD%E5%AE%9A%E7%B5%A6Ipad%E7%9A%84WebDav&redirect=no

----

好像記的有點凌亂 XD

---------------------------------

[2012.12.19 補充]
原本都一直無法上傳&刪除檔案, 在檢查設定檔有看到這句
DavLockDB "C:/Program Files/Apache Software Foundation/Apache2.2/var/DavLock"

當初安裝apache的時候並沒有var/DavLock這個資料夾, 建立這個資料夾後似乎一切都正常運作了!?

科科~~