<?xml version="1.0" encoding="Big5"?>
<?xml-stylesheet type="text/css" href="document.css"?>
<document xmlns:HTML="http://www.w3.org/1999/xhtml">
	<title>
	在 Win32 平台下安裝 ns2
	</title>
	<content>
		<subject>→ 下載安裝 ns2 所需要的相關軟體</subject>
	下載原始檔 : 
	<HTML:BR/>
		<item>
		1. <HTML:A href="http://www.isi.edu/nsnam/dist/tcltk/tcl8.3.2.tar.gz">Tcl 8.3.2</HTML:A>
		</item>
		<item>
		2. <HTML:A href="http://www.isi.edu/nsnam/dist/tcltk/tk8.3.2.tar.gz">Tk 8.3.2</HTML:A>
		</item>
		<item>
		3. <HTML:A href="http://www.isi.edu/nsnam/dist/otcl-1.0a7.tar.gz">Otcl 1.0a7</HTML:A>
		</item>
		<item>
		4. <HTML:A href="http://www.isi.edu/nsnam/dist/tclcl-src-1.0b11.tar.gz">Tclcl 1.0b11</HTML:A>
		</item>
		<item>
		5. ns2 ( 
		<HTML:A href="http://www.isi.edu/nsnam/dist/binary/ns-2.1b8a.exe">Windows 版執行檔</HTML:A> 、
		<HTML:A href="http://www.isi.edu/nsnam/dist/ns-src-2.1b8.tar.gz">原始檔</HTML:A> )
		</item>
	<HTML:BR/>
	ps. 若您的使用平台上並未支援 TCL 編譯器時, 請安裝 Tcl8.3.2.exe － 例如：Windows 2000. 
	<HTML:BR/>
	接下來的工作, 就是解壓縮下載的原始檔到同一個目錄內, 以 c:\ns2 為例, 將以上的檔案都放在 c:\ns2 裡.
	現在要示範的平台為 Windows 2000 作業系統, Microsoft Visual C++ 6.0, 並假設 Visual Studio 安裝在
	c:\program files\microsoft visual studio (Windows XP 系統下也可以安裝). 接下來就是開起「命令提示字元」
	, 並執行c:\program files\microsoft visual studio\vc98\bin\vcvars32.bat，設定環境變數.
	</content>	
	<content>
	<subject>→ 編譯 Tcl 8.3.2 </subject>
		<item>
		下圖代表 c:\ns2\tcl8.3.2\win\makefile.vc 的部分檔案內容 : 
		</item>
	<HTML:IMG src="graph/ns_install_win_1.PNG" border="1"/>
	<HTML:BR/>
	其中 : 
		<HTML:OL>
			<HTML:LI>其中 ROOT 是您的 Tcl 的上層目錄. </HTML:LI>
			<HTML:LI>INSTALLDIR 為您的 Tcl 所在之目錄. </HTML:LI>
			<HTML:LI>更改上圖紅線框起來的部分. </HTML:LI>
				<HTML:OL type="a">
					<HTML:LI>將 TOOLS32 改成 VC++ 所在目錄. </HTML:LI>
					<HTML:LI>將 TOOLS32_rc 改為 VC++ 目錄下 Resource 檔之目錄. </HTML:LI>
				</HTML:OL>	
		</HTML:OL>	
	<HTML:HR/>	
	接下來依序執行下列動作 : 
		<HTML:OL>
		第一點 : 編輯c:\ns2\tcl8.3.2\win\makefile.vc, 將
			<HTML:OL>TOOLS32 = c:\Progra~1\devstudio\vc</HTML:OL>
			<HTML:OL>TOOLS32_rc = c:\Progra~1\devstudio\sharedide</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>TOOLS32 = c:\program files\microsoft visual studio\vc98</HTML:OL>
			<HTML:OL>TOOLS32_rc = c:\program files\microsoft visual studio\common\msdev98</HTML:OL>
			</HTML:FONT>
			<HTML:OL>及把</HTML:OL>
			<HTML:OL>INSTALLDIR = c:\Progra~1\Tcl</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>INSTALLDIR = c:\ns2</HTML:OL>
			</HTML:FONT>
			</HTML:OL>
		<HTML:OL>
		第二點 : 在命令模式下執行cd c:\ns2\tcl8.3.2\win
		</HTML:OL>
		<HTML:OL>
		第三點 : 在命令模式下執行nmake -f makefile.vc
		</HTML:OL>
	ps. 編譯成功後會產生兩檔 tclsh83.exe 及 tcl83.lib 在 win\Release\ 中. 以上兩檔放在 win\Release\ 中不動.
	(OTcl及Tclcl編譯時會用上) 若您的平台未支援 Tcl, 請將 tclsh83.exe 複製一份到 NetSim\ 中以供 NS2.exe
	執行時呼叫使用. 	
	</content>	
	<content>
	<subject>→ 編譯 Tk 8.3.2 </subject>
	<item>
	下圖代表 c:\ns2\tk8.3.2\win\makefile.vc 的部分檔案內容 :
	</item>
	<HTML:IMG src="graph/ns_install_win_2.PNG" border="1"/>
	<HTML:BR/>
	其中 :
		<HTML:OL>
			<HTML:LI>TCLDIR 是您的TCL所在之目錄.</HTML:LI>
			<HTML:LI>INSTALLDIR 是您的TK所在之目錄.</HTML:LI>
			<HTML:LI>更改上圖紅線框起來的部分. </HTML:LI>
				<HTML:OL type="a">
					<HTML:LI>TOOLS32 是 VC++所在之目錄. </HTML:LI>
					<HTML:LI>TOOLS32_rc 是 VC++目錄下 Resource 檔之目錄. </HTML:LI>
				</HTML:OL>	
		</HTML:OL>	
	<HTML:HR/>	
	接下來依序執行下列動作 :
		<HTML:OL>
		第一點 : 編輯c:\ns2\tk8.3.2\win\makefile.vc, 將
			<HTML:OL>TOOLS32 = c:\Progra~1\devstudio\vc</HTML:OL>
			<HTML:OL>TOOLS32_rc = c:\Progra~1\devstudio\sharedide</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>TOOLS32 = c:\program files\microsoft visual studio\vc98</HTML:OL>
			<HTML:OL>TOOLS32_rc = c:\program files\microsoft visual studio\common\msdev98</HTML:OL>
			</HTML:FONT>
			<HTML:OL>及把</HTML:OL>
			<HTML:OL>TCLDIR = ..\..\tcl8.3</HTML:OL>
			<HTML:OL>INSTALLDIR = c:\Progra~1\Tcl</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>TCLDIR = ..\..\tcl8.3.2</HTML:OL>
			<HTML:OL>INSTALLDIR = c:\ns2</HTML:OL>
			</HTML:FONT>
		</HTML:OL>
		<HTML:OL>
		第二點 : 在命令模式下執行cd c:\ns2\tk8.3.2\win
		</HTML:OL>
		<HTML:OL>
		第三點 : 在命令模式下執行nmake -f makefile.vc
		</HTML:OL>
	ps. 編譯成功後會產生 wish83.exe 及 tk83.lib在 win\Release\ 中 (OTcl編譯時會用到). 以上兩檔留在 
	win\Release\ 中不動，等待後續程式組呼叫使用. 	
	</content>	
	<content>
	<subject>→ 編譯 Otcl 1.07a</subject>
	<item>
	下面兩張圖代表 c:\ns2\otcl-1.0a7\makefile.vc 的部分檔案內容 :
	</item>
	<HTML:IMG src="graph/ns_install_win_3.PNG" border="1"/>
	<HTML:BR/>
	其中 :
		<HTML:OL>
			<HTML:LI>TOOLS32 是您的 VC++ 所在之目錄.</HTML:LI>
			<HTML:LI>cc32 是您的 cl.exe 所在之目錄.</HTML:LI>
			<HTML:LI>link32 是您的 Link.exe 所在之目錄.</HTML:LI>
		   	<HTML:LI>INSTALL 是您 OTcl 所在之目錄.</HTML:LI>
		</HTML:OL>
	<HTML:IMG src="graph/ns_install_win_4.PNG" border="1"/>	
	<HTML:BR/>
	接下來依序執行下列動作 :
		<HTML:OL>
			第一點 : 編輯c:\ns2\otcl-1.0a7\makefile.vc，將
			<HTML:OL>TOOLS32= c:\progra~1\micros~4\VC98</HTML:OL>
			<HTML:OL>cc32= $(TOOLS32)\bin\cl</HTML:OL>
			<HTML:OL>link32= $(TOOLS32)\bin\link</HTML:OL>
			<HTML:OL>TCLINC= -I..\tcl8.0\generic</HTML:OL>
			<HTML:OL>TKINC= -I..\tk8.0\generic</HTML:OL>
			<HTML:OL>TKXINC= -I..\tk8.0\xlib</HTML:OL>
			<HTML:OL>TCLLIB= ..\tcl8.0\win\stcl80.lib</HTML:OL>
			<HTML:OL>TKLIB= ..\tk8.0\win\stk80.lib</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>TOOLS32= c:\program files\microsoft visual studio\vc98</HTML:OL>
			<HTML:OL>cc32= "$(TOOLS32)\bin\cl"</HTML:OL>
		    <HTML:OL>link32= "$(TOOLS32)\bin\link"</HTML:OL>
			<HTML:OL>TCLINC= -I..\tcl8.3.2\generic</HTML:OL>
			<HTML:OL>TKINC= -I..\tk8.3.2\generic</HTML:OL>
			<HTML:OL>TKXINC= -I..\tk8.3.2\xlib</HTML:OL>
			<HTML:OL>TCLLIB= ..\tcl8.3.2\win\release\tcl83.lib</HTML:OL>
			<HTML:OL>TKLIB= ..\tk8.3.2\win\release\tk83.lib</HTML:OL>
			</HTML:FONT>
		</HTML:OL>
		<HTML:OL>
		第二點 : 在命令模式下執行cd c:\ns2\otcl-1.0a7
		</HTML:OL>
		<HTML:OL>
		第三點 : 在命令模式下執行nmake -f makefile.vc
		</HTML:OL>
	ps. 編譯成功後會產生 otclsh.exe、owish.exe 兩個檔案提供呼叫. 以上兩檔留在 OTcl 
	目錄中等待後續程式組呼叫使用.	
	</content>	
	<content>
	<subject>→ 編譯 Tclcl 1.0b11</subject>
	<item>
	下面三張圖代表 c:\ns2\tclcl-1.0b11\conf\makefile.win 的部分檔案內容 :
	</item>
	<HTML:IMG src="graph/ns_install_win_5.PNG" border="1"/>
	<HTML:BR/>
	其中 :
		<HTML:OL>
			<HTML:LI>MSVCDIR 是您的 VC++ 所在之目錄</HTML:LI>
			<HTML:LI>LOCAL_SRC 是您的Tclcl目前所在之目錄</HTML:LI>
		</HTML:OL>
	<HTML:IMG src="graph/ns_install_win_6.PNG" border="1"/>	
	<HTML:BR/>
	其中 :
		<HTML:OL>
			<HTML:LI>TK_VER、TK_SUFFIX 是您的 TK 版本</HTML:LI>
			<HTML:LI>TCL_VER、TCL_SUFFIX 是您的 TCL 版本</HTML:LI>
			<HTML:LI>TK_DIR、TCL_DIR、OTCL_DIR、TCLCL_DIR 是各模組所在之目錄. 
			(這就是為何要將所有模組放在同一目錄下之原因.)</HTML:LI>
			<HTML:LI>LIB_TK、LIB_TCL 是 tcl83.lib 與 tk83.lib 所在之目錄及檔名.</HTML:LI>
		</HTML:OL>
	<HTML:IMG src="graph/ns_install_win_7.PNG" border="1"/>	
	<HTML:BR/>
	其中 :
		<HTML:OL>
			<HTML:LI>LIB_OTCL、LIB_TCLCL otcl.lib 是 tclcl.lib 所在之目錄</HTML:LI>
			<HTML:LI>LIBRARY_TK、LIBRARY_TCL 是 TK、TCL目錄下之 library 目錄</HTML:LI>
			<HTML:LI>TCLSH 是 您的 tclsh83.exe 所在之目錄</HTML:LI>
			<HTML:LI>TCL2C 是 您的 tcl2c++.exe 要存放之目錄</HTML:LI>
		</HTML:OL>
	接下來依序執行下列動作 :
		<HTML:OL>
		第一點 : 編輯c:\ns2\tclcl-1.0b11\conf\makefile.win，將
			<HTML:OL>MSVCDIR = c:\progra~1\micros~4\VC98</HTML:OL>
			<HTML:OL>LOCAL_SRC = c:\research\vint\ns-allinone-2.1b7</HTML:OL>
			<HTML:OL>TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b10</HTML:OL>
			<HTML:OL>TOOLS32 = $(MSVCDIR)</HTML:OL>
			<HTML:OL>OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a6</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>MSVCDIR = c:\program files\microsoft visual studio\vc98</HTML:OL>
			<HTML:OL>LOCAL_SRC = c:\ns2</HTML:OL>
			<HTML:OL>TCLCL_DIR = $(LOCAL_SRC)\tclcl-1.0b11</HTML:OL>
			<HTML:OL>TOOLS32 = "$(MSVCDIR)"</HTML:OL>
			<HTML:OL>OTCL_DIR = $(LOCAL_SRC)\otcl-1.0a7</HTML:OL>
			</HTML:FONT>
		</HTML:OL>
		<HTML:OL>
		第二點 : 編輯c:\ns2\tclcl-1.0b11\makefile.vc 將所有內容是 $(RM) $@ 的行整行刪除. 如把
			<HTML:OL>embedded-tclobj.cc: tcl-object.tcl tcl-import.tcl tcl-http.tcl $(TCL2C) $(RM) $@
			$(TCL2C) et_tclobject tcl-object.tcl tcl-import.tcl tcl-http.tcl > $@</HTML:OL>
			<HTML:OL>改成</HTML:OL>
			<HTML:FONT color="red">
			<HTML:OL>embedded-tclobj.cc: tcl-object.tcl tcl-import.tcl tcl-http.tcl $(TCL2C)
			$(TCL2C) et_tclobject tcl-object.tcl tcl-import.tcl tcl-http.tcl > $@</HTML:OL>
			</HTML:FONT>
		</HTML:OL>
		<HTML:OL>
		第三點 : 在命令模式下執行cd c:\ns2\tclcl-1.0b11	
		</HTML:OL>
		<HTML:OL>
		第四點 : 在命令模式下執行nmake -f makefile.vc
		</HTML:OL>	
	</content>	
	<content>
	<subject>→ 複製檔案</subject>
	依序執行下列動作 :
		<HTML:OL>
			<HTML:LI>在命令模式下執行mkdir c:\ns2\bin</HTML:LI>
			<HTML:LI>在命令模式下執行cd c:\ns2\bin</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\tcl8.3.2\win\release\*.dll</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\tcl8.3.2\win\release\*.exe</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\tk8.3.2\win\release\*.dll</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\tk8.3.2\win\release\*.exe</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\otcl-1.0a7\*.exe</HTML:LI>
			<HTML:LI>在命令模式下執行copy c:\ns2\tclcl-1.0b11\*.exe</HTML:LI>
			<HTML:LI>將ns-2.1b8a.exe複製至c:\ns2\bin並改名為ns2.exe</HTML:LI>
			<HTML:LI>將c:\ns2\tcl8.3.2\library複製至c:\ns2\lib\</HTML:LI>
			<HTML:LI>將資料夾c:\ns2\lib\library改名成c:\ns2\lib\tcl8.3</HTML:LI>
			<item>	
			ps. 上兩指令就是把c:\ns2\tcl8.3.2\library內的所有東西都搬到,  c:\ns2\lib\tcl8.3內.
			</item>
			<HTML:LI>將c:\ns2\tk8.3.2\library複製至c:\ns2\lib\</HTML:LI>
			<HTML:LI>將資料夾c:\ns2\lib\library改名成c:\ns2\lib\tk8.3</HTML:LI> 
			<item>	
			ps. 上兩指令就是把c:\ns2\tk8.3.2\library內的所有東西都搬到c:\ns2\lib\tk8.3內
			</item>
		</HTML:OL>
	如此就可以把 ns2 給裝起來了.	
	<HTML:BR/>
	<HTML:BR/>
	<item>
	參考來源 : 
	</item>
	<item>
	<HTML:A href="http://tkwu.mis.mhit.edu.tw/wireless/ns2/NS2Build.htm">
	http://tkwu.mis.mhit.edu.tw/wireless/ns2/NS2Build.htm
	</HTML:A>
	</item>
	<item>
	<HTML:A href="http://eagle.ee.ntu.edu.tw/ntwk-sw/install.html">
	http://eagle.ee.ntu.edu.tw/ntwk-sw/install.html
	</HTML:A>
	</item>
	<HTML:BR/>
	<HTML:BR/>
	<item>
	isi ftp site : 
	<HTML:A href="ftp://ftp.isi.edu/nsnam">ftp://ftp.isi.edu/nsnam</HTML:A>
	這邊有許多工具可以下載
	</item>
	</content>	
</document>

