Welcome to LQ.
[code omitted because of length], etc. :
This is a well known error. > LQ Search, and Google.
Happens, when nam is compiled with a wrong version of tcl , tk.
ns-allinone-2.29 : ns-allinone-2.29.3.tar.gz is to be used :
...............About the patch 'tk-8.4-lastevent.patch'
Remove all tcl, tk with your package manager = Synaptic.
And redo " ./install "
'tcl, tk version 8.4.1x can usually be reinstalled after the ns2 build.
If you have further issues : The used version of Ubuntu,
like Ubuntu 9.10 Karmic, must be told by every question ..
Useful info : http://nsnam.isi.edu/nsnam/index.php/User_Information