Purpose


NS(version 2)´Â UC Berkely¿¡¼­ C++°ú OTcl·Î ¾´ object-orientÀÎ ÀÌ»ê»ç°Ç ±¸µ¿ ½Ã¹Ä·¹ÀÌÅͷμ­ LAN°ú WANÀ» ½Ã¹Ä·¹ÀÌÆ® Çϴµ¥ ¸Å¿ì À¯¿ëÇÏ´Ù. NS´Â ½Ã¹Ä·¹ÀÌÅ͸¦ Çѹø ¾Ë°ÔµÇ¸é ºñ·Ï ½±Áö¸¸, óÀ½À¸·Î »ç¿ëÇÏ´Â »ç¶÷¿¡°Ô´Â ¸Å¿ì ¾î·Æ±â ¶§¹®¿¡ »ç¿ëÀÚ¿¡°Ô ±×¸® Àͼ÷ÇÏÁö´Â ¾Ê´Ù. ½Ã¹Ä·¹ÀÌÅ͸¦ ±íÀÌ ÀÖ°Ô ¼³¸íÇÑ, °³¹ßÀÚ¿¡ ÀÇÇØ ¾²¿©Áø Document°¡ ¸¹ÀÌ ÀÖ±â´Â ÇÏÁö¸¸ ±×°ÍÀº NS¿¡ Àͼ÷ÇÑ UserÀÇ ±íÀÌ·Î ¾²¿©Á® ÀÖ´Ù. ÀÌ projectÀÇ ¸ñÀûÀº ÁÖ·Î °£´ÜÇÑ ¿¹¿Í ¿ì¸®ÀÇ °æÇèÀ» Åä´ë·Î ÇÑ °£·«ÇÑ ¼³¸íÀ» °çµé¿© »õ·Î¿î User¿¡°Ô ½Ã¹Ä·¹ÀÌÅ͸¦ µ¿ÀÛÇÏ´Â ¹æ¹ý°ú ³×Æ®¿öÅ©¸¦ setupÇÏ´Â ¹æ¹ý, ½Ã¹Ä·¹ÀÌÅÍ code¿¡ ÀÖ´Â Network ±¸¼º¿ä¼Ò¿¡ ´ëÇÑ Áøº¸µÈ Á¤º¸¸¦ ¾îµð¼­ ã´Â°¡, ¶ÇÇÑ »õ·Î¿î Network ±¸¼º¿ä¼Ò¸¦ ¾î¶»°Ô ¸¸µå´Â°¡ ÇÏ´Â ¹æ¹ý µîÀ» Á¦°øÇϱâ À§ÇÑ °ÍÀÌ´Ù. ºñ·Ï ÀÌ ÇÁ·ÎÁ§Æ®¿¡¼­ ½Ã¹Ä·¹ÀÌÅÍÀÇ ¸ðµç »ç¿ë ¿¹³ª, °¡´ÉÇÑ ³×Æ®¿öÅ© ½Ã¹Ä·¹ÀÌ¼Ç setupÀÌ coverµÇÁö ¾Ê´Â´Ù ÇÏ´õ¶óµµ, ÀÌ ÇÁ·ÎÁ§Æ®´Â »õ·Î¿î »ç¿ëÀÚ¿¡°Ô º¸´Ù ºü¸£°Ô Á¢±ÙÇÒ ¼ö ÀÖµµ·Ï ÇØÁÙ °ÍÀÌ´Ù.

http://perform.wpi.edu/NS/index.html





 

1. OverView

NS´Â UC Berkeley¿¡¼­ °³¹ßÇÑ Event ±¸µ¿ ³×Æ®¿öÅ© ½Ã¹Ä·¹ÀÌÅÍ·Î, ´Ù¾çÇÑ IP ³×Æ®¿öÅ©¸¦ ½Ã¹Ä·¹ÀÌÆ®ÇÑ´Ù. ±×°ÍÀº TCP¿Í UDP¿Í °°Àº ³×Æ®¿öÅ© ÇÁ·ÎÅäÄÝ, FTP, Telnet, Web, CBR°ú VBR ±×¸®°í Drop Tail, RED¿Í CBQ¿Í °°Àº router queue °ü¸® ¸ÞÄ«´ÏÁò, Dijkstra µî°ú °°Àº routing ¾Ë°í¸®ÁòÀ» ±¸ÇöÇÑ´Ù.

NS´Â ¶ÇÇÑ multicasting°ú LAN ½Ã¹Ä·¹À̼ÇÀ» À§ÇÑ MAC layer ÇÁ·ÎÅäÄÝÀÇ ¸¹Àº ºÎºÐÀ» ±¸ÇöÇÑ´Ù. NS ÇÁ·ÎÁ§Æ®´Â ÇöÀç ½Ã¹Ä·¹ÀÌ¼Ç °á°ú¸¦ Ç¥½Ã, ºÐ¼® ¹× Àß ¾Ë·ÁÁø »ý¼º±â¿¡ ÀÇÇØ »ý¼ºµÈ ³×Æ®¿öÅ© Topology¸¦ NS formatÀ¸·Î º¯È¯Çϱâ À§ÇÑ VINT ProjectÀÇ ÀϺκÐÀÌ´Ù. ÇöÀç C++°ú OTcl(Tcl script language with Object-oriented extensions developed at MIT)·Î ¾²¿©Áø NS(version 2)°¡ À¯¿ëÇÏ´Ù. ÀÌ document´Â NSÀÇ ±âº»ÀûÀÎ ±¸Á¶¿¡ ´ëÇØ¼­ °£·«ÇÏ°Ô À̾߱âÇϸç, ´ëºÎºÐ ¿¹¸¦ µé¾î¼­ NS¸¦ ¾î¶»°Ô »ç¿ëÇϴ°¡¸¦ »ó¼¼È÷ ¼³¸íÇÑ´Ù. NS ±âº» ±¸Á¶¸¦ ±â¼úÇϴµ¥ »ç¿ëµÈ ´ëºÎºÐÀÇ ±×¸²°ú ³×Æ®¿öÅ© ±¸¼º¿ä¼ÒµéÀº 5th VINT/NS Simulator Tutorial/Workshop ½½¶óÀ̵å¿Í Çʿ信 µû¶ó ¾à°£ º¯ÇüÇÑ NS Notes and Document·ÎºÎÅÍ »ç¿ëÇß´Ù. NS¿Í °ü·ÃµÈ Tool¿¡ ´ëÇÑ º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸´Â VINT project home page¸¦ ¹æ¹®ÇØ º¸¶ó.



±×¸² 1. Simplified User's View of NS

 

°£´ÜÇÑ User's view¿¡ ÀÖ´Â ±×¸²1.¿¡¼­ NS´Â ½Ã¹Ä·¹ÀÌ¼Ç event scheduler¿Í network ±¸¼º object libraries, network setup(plumbing:¹è°ü, ¼³ºñ, Àç´Â °Í, ÀÌÇØÇÏ´Â °Í) module libraries(½ÇÁ¦, plumbing module´Â ±âº» ½Ã¹Ä·¹ÀÌÅÍ objectÀÇ member ÇÔ¼ö·Î ±¸ÇöµÈ´Ù.)¸¦ °®´Â Otcl script ÀÎÅÍÇÁ¸®ÅÍÀÌ´Ù. ´Ù½Ã ¸»Çؼ­ NS¸¦ »ç¿ëÇÑ´Ù´Â °ÍÀº OTcl script language¾È¿¡¼­ ÇÁ·Î±×·¥ ÇÑ´Ù´Â °ÍÀÌ´Ù. ½Ã¹Ä·¹ÀÌ¼Ç ³×Æ®¿öÅ©¸¦ setupÇÏ°í µ¿ÀÛ½Ã۱â À§Çؼ­ »ç¿ëÀÚ´Â event scheduler¸¦ ½ÃÀÛÇÏ´Â OTcl script¸¦ ¾²°í, library¿¡ ÀÖ´Â plumbing ÇÔ¼ö¿Í network object¸¦ »ç¿ëÇÏ´Â network topology¸¦ setupÇϸç, event scheduler¸¦ ÅëÇÏ¿© Àü¼ÛµÇ´Â ÆÐŶÀ» ½ÃÀÛÇϰí Á¤ÁöÇÒ ¶§ traffic source¸¦ ¾Ë·ÁÁà¾ß ÇÑ´Ù. Network¸¦ setupÇÏ´Â °ÍÀº ÀûÁ¤ÇÑ objectÀÇ ÁÖ¼Ò·Î objectÀÇ Æ÷ÀÎÅ͸¦ "neighbor"·Î setting ÇÔÀ¸·Î½á,Network object »çÀÌ¿¡¼­ °¡´ÉÇÑ data °æ·Î¸¦ Àç´Â °ÍÀ̱⠴빮¿¡ "Plumbing"Ç×Àº ³×Æ®¿öÅ© setup¸¦ À§Çؼ­ »ç¿ëµÈ´Ù.

»ç¿ëÀÚ°¡ »õ·Î¿î network object¸¦ ¸¸µé±â ¿øÇÒ ¶§, »õ·Î¿î object¸¦ ¾²°Å³ª, object library·ÎºÎÅÍ ÇÕ¼ºµÈ object¸¦ ¸¸µé°Å³ª, ¶Ç´Â object¸¦ Åë°úÇÏ´Â data¸¦ plumbÇÔÀ¸·Î½á ½±°Ô object¸¦ ¸¸µé ¼ö ÀÖ´Ù. À̰ÍÀº º¹ÀâÇÑ ÀÏ·Î º¸ÀÏÁö ¸ð¸£³ª, plumbing OTcl ¸ðµâÀº ½ÇÁ¦ÀûÀ¸·Î ¸Å¿ì ½±°Ô jobÀ» ¸¸µç´Ù. NSÀÇ power´Â ÀÌ plumbingÀ¸·ÎºÎÅÍ ¿Â´Ù. network object¿Ü¿¡ NSÀÇ ´Ù¸¥ major ±¸¼º¿ä¼Ò´Â event schedulerÀÌ´Ù. NS¿¡ ÀÖ´Â event´Â scheduleµÈ timeÀ» °¡Áø packet¿¡ ´ëÇØ À¯ÀÏÇÑ, event¸¦ Á¶Á¤ÇÏ´Â object¸¦ °¡¸®Å°´Â packet IDÀÌ´Ù. NS¿¡¼­ event scheduler´Â ½Ã¹Ä·¹ÀÌ¼Ç timeÀÇ trackÀ» À¯ÁöÇϸç, Àû´çÇÑ network ±¸¼º¿ä¼Ò(±×°ÍÀº º¸Åë event¸¦ ¹ß»ý½ÃŰ´Â »ç¶÷À̸ç, ±×µéÀ» event¿¡ ÀÇÇØ ÁöÀûµÈ packet°ú °ü·ÃµÈ ÀûÁ¤ÇÑ ÇàÀ§¸¦ Çϵµ·Ï ÇÑ´Ù.)µéÀ» ºÒ·¯³¿À¸·Î½á ÇöÀç ½Ã°£¿¡ ´ëÇØ scheduleµÈ event queue¿¡ ÀÖ´Â ¸ðµç eventµéÀ» ÀÚ±ØÇÑ´Ù. Network ±¸¼º¿ä¼ÒµéÀº ´Ù¸¥ passing packet°ú Åë½ÅÇÑ´Ù. ±×·¯³ª, À̰ÍÀº ½ÇÁ¦ÀûÀÎ ½Ã¹Ä·¹ÀÌ¼Ç ½Ã°£À» ¼Ò¸ðÇÏÁö´Â ¾Ê´Â´Ù. packet(Áö¿¬ Çʿ伺 µî)À» Á¶Á¤ÇÏ´Â ¸¹Àº ½Ã¹Ä·¹ÀÌ¼Ç timeÀ» ¼ÒºñÇØ¾ßÇÒ Çʿ䰡 ÀÖ´Â ¸ðµç network ±¸¼º¿ä¼ÒµéÀº packet¿¡ ´ëÇÑ event¸¦ ¹ßÇàÇÔÀ¸·Î½á, packet¸¦ Á¶Á¤ÇÏ´Â ³ªÁßÀÇ µ¿ÀÛÀ» Çϱâ Àü¿¡ ±× ÀÚ½ÅÀ» ÀÚ±ØÇϱâ À§ÇÑ event¸¦ ±â´Ù¸²À¸·Î½á, event scheduler¸¦ »ç¿ëÇÑ´Ù. ¿¹¸¦ µé¾î, 20§ÁÀ¸·Î ½ºÀ§Ä¡¸¦ ½Ã¹Ä·¹ÀÌÆ®ÇÏ´Â network ±¸¼º¿ä¼Ò´Â 20§ÁÈÄÀÇ event·Î¼­ schedulerfhf º¯È¯µÇ´Â packet¿¡ ´ëÇÑ event¸¦ ¹ßÇàÇÑ´Ù. 20§ÁÈÄÀÇ scheduler´Â event¸¦ dequeueÇϸç, ½ºÀ§Ä¡ ±¸¼º¿ä¼Ò¿¡°Ô ±×°ÍÀ» ÀÚ±ØÇÑ´Ù. ±×¶§ ±×°ÍÀº Àû´çÇÑ Ãâ·Â¸µÅ© ±¸¼º¿ä¼Ò¿¡ packetÀ» Àü´ÞÇÑ´Ù.

event schedulerÀÇ ¶Ç ´Ù¸¥ »ç¿ëÀº timerÀÌ´Ù. ¿¹¸¦ µé¾î, TCP´Â ÀçÀü¼Û(´Ù¸¥ NS packet ID¸¦ Á¦¿ÜÇÑ µ¿ÀÏÇÑ TCP packet ¹øÈ£¸¦ °¡Áø packetÀÇ Àü¼Û)¿¡ ´ëÇÑ packet Àü¼Û time-outÀÇ trackÀ» À¯ÁöÇϱâ À§ÇÑ timer¸¦ ÇÊ¿ä·Î ÇÑ´Ù. Timer´Â delay°¡ ÇÏ´Â ºñ½ÁÇÑ ¹æ¹ýÀ¸·Î event scheduler¸¦ »ç¿ëÇÑ´Ù. ¿À·ÎÁö ´Ù¸¥ Á¡Àº timer´Â packet°ú °ü·ÃµÈ time °ªÀ» ÃøÁ¤Çϸç, ¾î¶² ½Ã°£ÀÌ Áö³ª°£ ÈÄ¿¡ ±× packet°ú °ü·ÃµÈ ÀûÁ¤ÇÑ µ¿ÀÛÀ» Çϰí, delay¸¦ ½Ã¹Ä·¹ÀÌÆ® ÇÏÁö ¾Ê´Â´Ù´Â °ÍÀÌ´Ù.

NS´Â OTcl »Ó¸¸ ¾Æ´Ï¶ó C++·Î ¾²¿©Á³´Ù. ÀÌ·¯ÇÑ ´É·Â ¶§¹®¿¡, NS´Â Á¦¾î°æ·Î ±¸ÇöÀ¸·ÎºÎÅÍ data °æ·Î ±¸ÇöÀ» ºÐ¸®ÇÑ´Ù. packet¿Í event ó¸® ½Ã°£(½Ã¹Ä·¹ÀÌ¼Ç ½Ã°£ÀÌ ¾Æ´Ï°í)À» ÁÙÀ̱â À§ÇÏ¿©, event scheduler¿Í data °æ·Î¿¡ ÀÖ´Â ±âº»ÀûÀÎ network ±¸¼º¿ä¼Ò object´Â C++À» »ç¿ëÇÏ¿© ¾²¿©Áö°í compileµÈ´Ù. ÀÌ·¯ÇÑ compileµÈ object´Â C++ objectÀÇ °¢°¢ ¿ä¼Òµé°ú matchingµÇ´Â OTcl object¸¦ »ý¼ºÇϰí Á¦¾îÇÔ¼ö¿Í member ÇÔ¼ö·Î µ¿ÀÛÇÏ´Â C++ object¿¡ ÀÇÇØ ±ÔÁ¤µÈ ±¸¼º °¡´ÉÇÑ º¯¼ö, ±×¸®°í ÀÏÄ¡ÇÏ´Â OTcl objectÀÇ member º¯¼ö¸¦ ¸¸µå´Â OTcl ¸µÅ©¸¦ ÅëÇØ OTcl ÀÎÅÍÇÁ¸®ÅÍ·Î À¯¿ëÇÏ°Ô ¸¸µé¾îÁø´Ù. ÀÌ·¯ÇÑ ¹æ¹ýÀ¸·Î C++ objectÀÇ Á¦¾î°¡ OTcl·Î ÁÖ¾îÁø´Ù. C++ linked OTcl object·Î member ÇÔ¼ö¿Í º¯¼öµéÀ» Ãß°¡ÇÏ´Â °ÍÀº °¡´ÉÇÏ´Ù. ½Ã¹Ä·¹À̼ǿ¡¼­ Á¦¾îµÇ°Å³ª, ´Ù¸¥ object¿¡ ÀÇÇØ ³»ºÎÀûÀ¸·Î »ç¿ëµÉ Çʿ䰡 ¾ø´Â C++¿¡ ÀÖ´Â objectµéÀº OTcl¿¡ ¸µÅ©µÉ Çʿ䰡 ¾ø´Ù. ¸¶Âù°¡Áö·Î object(data °æ·Î¿¡ ÀÖÁö ¾ÊÀº)´Â OTcl¿¡¼­ ÀüÀûÀ¸·Î ±¸ÇöµÉ ¼ö ÀÖ´Ù. ±×¸²2´Â C++°ú OTcl¿¡ ÀÖ´Â object hierachyÇÑ ¿¹¸¦ º¸¿©ÁØ´Ù. ±×¸²¿¡¼­ ÁÖ¸ñÇÒ ¸¸ÇÑ Çϳª´Â hierarcy¸¦ ±¸¼ºÇÏ´Â OTcl ¸µÅ©¸¦ °®´Â C++ object¿¡ ´ëÇÑ °ÍÀÌ´Ù. °Å±â¿¡´Â C++°ú ¸Å¿ì À¯»çÇÏ°Ô matchingµÇ´Â OTcl object hierachy°¡ ÀÖ´Ù.



±×¸² 2. C++ and OTcl: The Duality
 


±×¸² 3. Architectural View of NS

±×¸²3Àº NSÀÇ ÀϹÝÀûÀÎ ±¸Á¶¸¦ º¸¿©ÁØ´Ù. ÀÌ ±×¸²¿¡¼­ ÀÏ¹Ý user(NS °³¹ßÀÚ°¡ ¾Æ´Ñ)´Â OTcl library¿¡ ÀÖ´Â ½Ã¹Ä·¹ÀÌÅÍ object¸¦ »ç¿ëÇÏ´Â Tcl¿¡¼­ ½Ã¹Ä·¹À̼ÇÀ» ¼³°èÇÏ°í µ¿ÀÛÇÏ´Â ¿ÞÂÊ ¾Æ·¡ Äڳʿ¡ ÀÖ´Â °ÍÀ¸·Î »ý°¢µÈ´Ù. event scheduler¿Í ´ëºÎºÐÀÇ network ±¸¼º¿ä¼ÒµéÀº C++¿¡¼­ ±¸ÇöµÇ¸ç, tclclÀ» »ç¿ëÇÏ¿© ±¸ÇöµÇ´Â OTcl ¸µÅ©¸¦ ÅëÇØ OTcl·Î °¡¿ëµÈ´Ù. NS¸¦ ÇÔ²² ¸¸µå´Â ¸ðµç ÀϵéÀº network simulator library¿Í ´õºÒ¾î OO È®ÀåµÈ Tcl ÀÎÅÍÇÁ¸®ÅÍÀÌ´Ù.

ÀÌ section¿¡¼­ NSÀÇ ÀϹÝÀûÀÎ ±¸¼º°ú ±¸Á¶¸¦ °£·«ÇÏ°Ô ¼³¸íÇß´Ù. ÀÌ Á¡¿¡¼­, »ç¶÷µéÀº NS ½Ã¹Ä·¹ÀÌ¼Ç °á°ú¸¦ ¾î¶»°Ô ¾ò´À³Ä ÇÏ´Â °Í¿¡ ´ëÇØ Àǹ®À» °¡ÁúÁö ¸ð¸¥´Ù. ±×¸²1.¿¡¼­ º¸´Â¹Ù¿Í °°ÀÌ ½Ã¹Ä·¹À̼ÇÀÌ ³¡³¯ ¶§, NS´Â ÀÔ·Â Tcl(º¸´Ù »ó¼¼ÇϰԴ OTcl)¿¡¼­ ±×·¸°Ô Çϵµ·Ï ±ÔÁ¤ÇÏ¿´´Ù¸é, »ó¼¼ÇÑ ½Ã¹Ä·¹ÀÌ¼Ç data¸¦ Æ÷ÇÔÇÏ´Â Çϳª ȤÀº ±× ÀÌ»óÀÇ text-based Ãâ·ÂÆÄÀÏÀ» »ý¼ºÇÑ´Ù. ±× data´Â ½Ã¹Ä·¹ÀÌ¼Ç ºÐ¼®(µÎ °³ÀÇ ½Ã¹Ä·¹ÀÌ¼Ç °á°ú ºÐ¼®ÀÇ ¿¹°¡ ´ÙÀ½Àý¿¡ ÀÖ´Ù)À» À§ÇØ »ç¿ëµÇ°Å³ª, VINT ÇÁ·ÎÁ§Æ®ÀÇ ÀϺηΠ°³¹ßµÈ Network Animator(NAM)À¸·Î ºÒ¸®´Â graphical ½Ã¹Ä·¹ÀÌ¼Ç display tool·Î ÀÇ ÀÔ·ÂÀ¸·Î »ç¿ëµÉ ¼ö ÀÖ´Ù. NAMÀº CD palyer(play, fast forward, rewind, pause and so on)¿Í ºñ½ÁÇÏ°Ô ÈǸ¢ÇÑ graphical user ÀÎÅÍÆäÀ̽º¸¦ °¡Á³À¸¸ç display speed controller¸¦ °¡Á³´Ù. ³ª¾Æ°¡, ±×°ÍÀº ºñ·Ï graphical Á¤º¸°¡ ÀûÁ¤ÇÑ ½Ã¹Ä·¹ÀÌ¼Ç ºÐ¼®À» À§ÇØ »ç¿ëµÇÁö ¸øÇÑ´Ù ÇÏ´õ¶óµµ throughput°ú packetÀÌ °¢ ¸µÅ©¿¡¼­ dropµÇ´Â ¼ýÀÚ¿Í °°Àº Á¤º¸¸¦ graphicalÇÏ°Ô Ç¥ÇöÇÒ ¼ö ÀÖ´Ù.




















 

2. Basics

2.1 OTcl: The User Language

¾ð±ÞµÈ overview section¿¡¼­Ã³·³, NS´Â ±âº»ÀûÀ¸·Î network simulation object library¿Í ÇÔ²² ÇÏ´Â OTcl ÀÎÅÍÇÁ¸®ÅÍÀÌ´Ù. NS¸¦ »ç¿ëÇϱâ À§ÇØ OTcl¿¡¼­ ¾î¶»°Ô ÇÁ·Î±×·¥ Çϴ°¡¸¦ ¾Æ´Â °ÍÀº ¸Å¿ì À¯¿ëÇÏ´Ù. À̹ø Àý¿¡¼­´Â »ç¶÷µéÀÌ OTcl¿¡¼­ ÇÁ·Î±×·¡¹Ö¿¡ ´ëÇÑ ±âº»ÀûÀÎ idea¸¦ °¡ÁüÀ¸·Î½á Tcl°ú OTcl script¸¦ ÀÛ¼ºÇÏ´Â ¿¹¸¦ º¸¿©ÁØ´Ù. ÀÌ ¿¹µéÀº 5¼Ò VINT/NS simulation Tutorial/WorkshopÀ¸·ÎºÎÅÍ °¡Á®¿Ô´Ù. ÀÌ Àý°ú ÀÌÈÄÀÇ ÀýµéÀº µ¶ÀÚ°¡ NS¸¦ ÀνºÅçÇÏ¿´°í, C¿Í C++¿¡ Àͼ÷ÇÑ °ÍÀ¸·Î °¡Á¤ÇÑ´Ù.

¿¹ 1Àº Procedure¸¦ »ý¼ºÇÏ°í ±×°ÍÀ» È£ÃâÀ» ¾î¶»°Ô Çϴ°¡ ÇÏ´Â °ÍÀ» º¸¿©ÁÖ´Â ÀϹÝÀûÀÎ Tcl scriptÀÌ´Ù. OTclÀº TclÀÇ Object-oriented extensionÀ̸ç C¿Í C++ÀÇ °ü°è¿Í °°ÀÌ TclÀÇ ¸ðµç ¸í·ÉÀº OTcl»ó¿¡¼­ µ¿ÀÛÇÑ´Ù. ÀÌ script¸¦ µ¿ÀÛ½Ã۱â À§Çؼ­´Â ex-tcl.tclÀ» ´Ù¿î¹ÞÀ¸½Ã¿À. ±×¸®°í shell prompt¿¡¼­ "ns ex-tcl.tcl"À» ÀÔ·ÂÇϽÿÀ. "ns" ¸í·É¾î´Â NS(OTcl ÀÎÅÍÇÁ¸®ÅÍ)¸¦ ±âµ¿ÇÑ´Ù. ¸¸ÀÏ tcl8.0ÀÌ installµÇ¾î ÀÖ´Ù¸é, "tcl ex-tcl.tcl"À» ÀÔ·ÂÇØµµ °°Àº °á°ú¸¦ ¾òÀ» °ÍÀÌ´Ù.

 

Example 1. A simple Tcl Script

# Writing a procedure called "test"

proc test {} {

set a 43

set b 27

set c [expr $a + $b]

set d [expr [expr $a - $b] * $c]

for {set k 0} {$k < 10} {incr k} {

if {$k < 5} {

puts "k < 5, pow = [expr pow($d, $k)]"

} else {

puts "k >= 5, mod = [expr $d % $k]"

}

}

}

# Calling the "test" procedure created above

test

-. Tcl¿¡¼­ keyword proc´Â procedure¸¦ Á¤ÀÇÇϱâ À§ÇØ »ç¿ëµÇ¸ç

µÚ¿¡ ÇÁ·Î¼¼Á®ÀÇ À̸§°ú { }°¡ »ç¿ëµÈ´Ù.

-. keyword set´Â º¯¼ö¿¡ °ªÀ» ÇÒ´çÇϱâ À§ÇØ »ç¿ëµÈ´Ù.

-. [expr ...]´Â keyword µÚ¿¡ braket¿¡ Àִ ǥÇöÀÇ °ªÀ» °è»êÇÏ´Â ÀÎÅÍÇÁ ¸®Å͸¦ ¸¸µå´Â °ÍÀÌ´Ù.

-. $´Â º¯¼ö À̸§°ú ÇÔ²² »ç¿ëµÈ´Ù.

-. puts´Â double quotation mark ³»¿¡ ÀÖ´Â ½ºÆ®¸µÀ» Ãâ·ÂÇÑ´Ù.

´ÙÀ½Àº ¿¹Á¦1ÀÇ °á°ú¸¦ º¸¿©ÁØ´Ù.

k < 5, pow = 1.0

k < 5, pow = 1120.0

k < 5, pow = 1254400.0

k < 5, pow = 1404928000.0

k < 5, pow = 1573519360000.0

k < 5, pow = 0

k < 5, pow = 4

k < 5, pow = 0

k < 5, pow = 0

k < 5, pow = 4

´ÙÀ½ ¿¹´Â OTcl¿¡¼­ object-oriented programming ¿¹ÀÌ´Ù. ÀÌ ¿¹´Â ¸Å¿ì ´Ü¼øÇϳª, object°¡ OTcl¿¡¼­ »ý¼ºµÇ°í »ç¿ëµÇ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù. Åë»óÀûÀÎ NS »ç¿ëÀÚ´Â ÀÚ½ÅÀÇ object¸¦ ¾µ ±âȸ°¡ µå¹° °ÍÀÌ´Ù. ±×·¯³ª, NS simulation programming¿¡¼­ »ç¿ëÇÏ´Â ¸ðµç NS project°¡ C++·Î ¾²¿©Á³´ÂÁö ¾Æ´ÑÁö OTcl ³»¿¡¼­¸¸ ¾²¿©Á³´ÂÁö, link¸¦ °æÀ¯ÇÏ¿© OTclÀÌ À¯¿ëÇÏ°Ô ¸¸µé¾îÁ³´ÂÁöÀÇ ¹®Á¦ ¶§¹®¿¡ OTcl object¸¦ ÀÌÇØÇÏ´Â °ÍÀÌ µµ¿òÀÌ µÈ´Ù.

¿¹Á¦2´Â "mom"°ú "kid"µÎ °³ÀÇ object class¸¦ Á¤ÀÇÇÏ´Â OTcl scriptÀÌ´Ù. °Å±â¿¡¼­ "kid"´Â "mom"ÀÇ child classÀ̸ç, member ÇÔ¼ö´Â °¢ class¿¡ ´ëÇØ "greet"¸¦ È£ÃâÇÏ¿´´Ù. class Á¤ÀÇ ÈÄ¿¡, °¢ object instance´Â ¹«½ÃµÇ¸ç, °¢ instanceÀÇ "age" º¯¼ö´Â 45(for mom)¿Í 15(for kid)·Î setµÈ´Ù. ±×¸®°í °¢ object instanceÀÇ member ÇÔ¼ö "greet"°¡ È£ÃâµÈ´Ù. keyword Class´Â object class¸¦ »ý¼ºÇÏ´Â °ÍÀ̸ç, instproc´Â object class·Î member ÇÔ¼ö¸¦ Á¤ÀÇÇÏ´Â °ÍÀÌ´Ù, Class »ó¼ÓÀº keyword -superclass¸¦ »ç¿ëÇÏ¿© ±ÔÁ¤µÈ´Ù. member ÇÔ¼ö¸¦ Á¤ÀÇÇÔ¿¡ À־, $self´Â C++¿¡¼­ "this" pointer¿Í °°ÀÌ µ¿ÀÛÇÑ´Ù.
 

Example 2. A sample OTcl Script

# Create a class call "mom" and

# add a member function call "greet"

Class mom

mom instproc greet {} {

$self instvar age_

puts "$age_ years old mom say:

How are you doing?"

}

# Create a child class of "mom" called "kid"

# and overide the member function "greet"

Class kid -superclass mom

kid instproc greet {} {

$self instvar age_

puts "$age_ years old kid say:

What's up, dude?"

}

# Create a mom and a kid object set each age

set a [new mom]

$a set age_ 45

set b [new kid]

$b set age_ 15

# Calling member function "greet" of each object

$a greet

$b greet


±×¸®°í, instvar´Â ¸¸ÀÏ ´ÙÀ½ º¯¼ö À̸§ÀÌ ±× ÀÚ½ÅÀÇ class³ª superclass¿¡¼­ ÀÌ¹Ì ¼±¾ðµÇ¾ú´ÂÁö¸¦ Á¡°ËÇÑ´Ù. ÁÖ¾îÁø º¯¼ö À̸§ÀÌ ÀÌ¹Ì ¼±¾ðµÈ °ÍÀ̶ó¸é, ±× º¯¼ö°¡ ÂüÁ¶µÈ´Ù. ±×·¸Áö ¾Ê´Ù¸é »õ·Î¿î À̸§ÀÌ ¼±¾ðµÈ´Ù. °á°úÀûÀ¸·Î, object instance¸¦ »ý¼ºÇϱâ À§Çؼ­ keyword new°¡ ¿¹¿¡¼­ º¸´Â¹Ù¿Í °°ÀÌ »ç¿ëµÈ´Ù.

ex-otcl.tclÀ» DownlodingÇϰí "ns ex-otcl.tcl"À» ½ÇÇàÇÏ¸é ´ÙÀ½°ú °°Àº °á°ú¸¦ ¾òÀ» °ÍÀÌ´Ù.


45 years old mom say:

How are you doing ?

15 years old kid say:

What's up, dude ?




2.2 Simple Simulation Example

ÀÌ sectionÀº °£´ÜÇÑ NS simulation script¸¦ º¸¿©ÁÖ¸ç, °¢ lineÀÌ ¹«¾ùÀ» ÇÏ´ÂÁö¸¦ ¼³¸íÇÑ´Ù. ¿¹Á¦3 Àº °£´ÜÇÑ network ±¸¼ºÀ» »ý¼ºÇÏ´Â OTcl scriptÀ̸ç, ±×¸²4.¿¡ ÀÖ´Â ½Ã¹Ä·¹ÀÌ¼Ç scenario¸¦ µ¿ÀÛÇÑ´Ù. ÀÌ ½Ã¹Ä·¹À̼ÇÀ» µ¿ÀÛÇϱâ À§Çؼ­ "ns-simple"¸¦ ´Ù¿î¹Þ°í, shell prompt¿¡¼­ "ns ns-simple.tcl"À» ÀÔ·ÂÇ϶ó.


fig 4. A simple Network Topology and Simulation Scenario
 

ÀÌ network´Â 4°³ÀÇ node(n0, n1, n2, n3)¸¦ À§ÀÇ ±×¸²¿¡¼­ º¸´Â¹Ù¿Í °°ÀÌ ±¸¼ºÇÑ´Ù. n0¿Í n2, n1°ú n2 »çÀÌÀÇ duplex linkµéÀº 2 MbpsÀÇ ´ë¿ªÆø°ú 10ms Áö¿¬À» °¡Áø´Ù. n2¿Í n3»çÀÌÀÇ duplex link´Â 1.7MbpsÀÇ ´ë¿ªÆø°ú 20ms Áö¿¬À» °¡Áø´Ù. °¢ node´Â ÃÖ´ë Å©±â°¡ 10ÀÎ DropTail queue¸¦ »ç¿ëÇÑ´Ù. "tcp" Agent´Â n0¿¡ Á¢¼ÓµÇ¸ç, ¿¬°áÀº n3¿¡ Á¢¼ÓµÈ tcp "sink" agent·Î ¼³Á¤µÈ´Ù. "tcp" agent°¡ »ý¼ºÇÒ ¼ö ÀÖ´Â packetÀÇ ÃÖ´ë Å©±â´Â default·Î 1KByteÀÌ´Ù. tcp "sink" agent´Â ACK packetÀ» »ý¼ºÇϰí, sender(tcp agent)·Î º¸³»¸ç, ¼ö½ÅµÈ packetÀ» ÀÚÀ¯·Ó°Ô ÇÑ´Ù.

n1¿¡ Á¢¼ÓµÈ "udp" agent´Â n3¿¡ Á¢¼ÓµÈ "null" agent¿Í ¿¬°áµÈ´Ù. "null" agent´Â ¼ö½ÅµÈ packet¸¦ ¹Ù·Î ÀÚÀ¯·Ó°Ô ÇÑ´Ù. "ftp"¿Í "cbr" Æ®·¡ÇÈ »ý¼º±â´Â "tcp"¿Í "udp" agent¿¡ °¢±â Á¢¼ÓµÇ¾îÀÖ´Ù. ±×¸®°í "cbr"´Â 1MbpsÀÇ ¼Óµµ¿¡¼­ 1KByte packet¸¦ »ý¼ºÇϵµ·Ï ±¸¼ºµÇ¾îÀÖ´Ù. "cbr"Àº 0.1ÃÊ¿¡¼­ startÇϰí 4.5ÃÊ¿¡¼­ stopÇϵµ·Ï setµÇ¾î ÀÖ´Ù. ±×¸®°í "ftp"´Â 1.0ÃÊ¿¡¼­ start, 4.0ÃÊ¿¡¼­ stopÇϵµ·Ï setµÇ¾î ÀÖ´Ù.


Example 3. A Simple NS Simulation Script

#Create a simulator object

set ns [new Simulator]

#Define different colors for data flows (for NAM)

$ns color 1 Blue

$ns color 2 Red

#Open the NAM trace file

set nf [open out.nam w]

$ns namtrace-all $nf

#Define a 'finish' procedure

proc finish {} {

global ns nf

$ns flush-trace

#Close the NAM trace file

close $nf

#Execute NAM on the trace file

exec nam out.nam &

exit 0

}

#Create four nodes

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

#Create links between the nodes

$ns duplex-link $n0 $n2 2Mb 10ms DropTail

$ns duplex-link $n1 $n2 2Mb 10ms DropTail

$ns duplex-link $n2 $n3 1.7Mb 20ms DropTail

#Set Queue Size of link (n2-n3) to 10

$ns queue-limit $n2 $n3 10

#Give node position (for NAM)

$ns duplex-link-op $n0 $n2 orient right-down

$ns duplex-link-op $n1 $n2 orient right-up

$ns duplex-link-op $n2 $n3 orient right

#Monitor the queue for link (n2-n3). (for NAM)

$ns duplex-link-op $n2 $n3 queuePos 0.5

#Setup a TCP connection

set tcp [new Agent/TCP]

$tcp set class_ 2

$ns attach-agent $n0 $tcp

set sink [new Agent/TCPSink]

$ns attach-agent $n3 $sink

$ns connect $tcp $sink

$tcp set fid_ 1

#Setup a FTP over TCP connection

set ftp [new Application/FTP]

$ftp attach-agent $tcp

$ftp set type_ FTP

#Setup a UDP connection

set udp [new Agent/UDP]

$ns attach-agent $n1 $udp

set null [new Agent/Null]

$ns attach-agent $n3 $null

$ns connect $udp $null

$udp set fid_ 2

#Setup a CBR over UDP connection

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set type_ CBR

$cbr set packet_size_ 1000

$cbr set rate_ 1mb

$cbr set random_ false

#Schedule events for the CBR and FTP agents

$ns at 0.1 "$cbr start"

$ns at 1.0 "$ftp start"

$ns at 4.0 "$ftp stop"

$ns at 4.5 "$cbr stop"

#Detach tcp and sink agents (not really necessary)

$ns at 4.5 "$ns detach-agent $n0 $tcp ; $ns detach-agent $n3 $sink"

#Call the finish procedure after 5 seconds of simulation time

$ns at 5.0 "finish"

#Print CBR packet size and interval

puts "CBR packet size = [$cbr set packet_size_]"

puts "CBR interval = [$cbr set interval_]"

#Run the simulation

$ns run


´ÙÀ½Àº À§ script¿¡ ´ëÇÑ ¼³¸íÀÌ´Ù. ÀϹÝÀûÀ¸·Î NS script´Â Simulator object instance¸¦ ¸¸µé¾î¼­ ½ÃÀÛÇÑ´Ù.

 

¡Û set ns[new Simulator]:

NS simulator object instance¸¦ »ý¼ºÇϸç, º¯¼ö ns·Î ±×°ÍÀ» ÇÒ´çÇÑ´Ù.(italicsÀº ÀÌ section¿¡¼­ º¯¼ö¿Í °ªÀ¸·Î »ç¿ëµÈ´Ù.) ÀÌ ¶óÀÎÀÇ ¿ªÇÒÀº ´ÙÀ½°ú °°´Ù.

-. packet format¸¦ ÃʱâÈ­(¿©±â¼­´Â À̰ÍÀ» ¹«½Ã)

-. scheduler¸¦ »ý¼º(default´Â calendar schedulerÀÓ)

-. default address format¸¦ ¼±ÅÃ(¿©±â¼­´Â À̰ÍÀ» ¹«½Ã)

ÀÌ "Simulator" object´Â ´ÙÀ½ÀÇ ÀÏÀ» ÇÏ´Â member ÇÔ¼ö¸¦ °¡Áø´Ù.

-. node¿Í link°°Àº º¹ÇÕ object¸¦ »ý¼º(desired later)

-. »ý¼ºµÈ network ±¸¼º object¸¦ ¿¬°á(ex. attach-agent)

-. network ±¸¼º parameter¸¦ set(mostly for compound object)

-. agent »çÀÌÀÇ ¿¬°á »ý¼º(ex. "tcp"¿Í "sink"»çÀÌÀÇ ¿¬°áÀ» ¸¸µç´Ù)

-. NAM display optionÀ» ±ÔÁ¤

-. Etc.

member ÇÔ¼öÀÇ ´ëºÎºÐÀº simulation setup(Overview section¿¡¼­ plumbing ÇÔ¼ö¿Í °ü·ÃµÈ)°ú schedulingÀ» À§Çؼ­ ÀÖ´Ù. ±×·¯³ª, ±×µé Áß ´ëºÎºÐÀº NAM display¸¦ À§Çؼ­ ÀÖ´Ù. "Simulator" object member ÇÔ¼ö ±¸ÇöÀº "ns-2/tcl/lib/ns-lib.tcl" file³»¿¡ À§Ä¡ÇØ ÀÖ´Ù.

 

¡Û $ns color fid color:

flow id(fid)¿¡ ÀÇÇØ ±ÔÁ¤µÈ flow¿¡ ´ëÇÑ packetÀÇ color¸¦ set ÇÏ´Â °Í. ÀÌ "Simulator" objectÀÇ member ÇÔ¼ö´Â NAM display¸¦ À§ÇÑ °ÍÀÌ´Ù. ±×¸®°í ½ÇÁ¦ÀûÀÎ ½Ã¹Ä·¹ÀÌ¼Ç »ó¿¡ ¾î¶² È¿°úµµ ¹ÌÄ¡Áö ¾Ê´Â´Ù.

 

¡Û $ns namtrace-all file-descriptor:

ÀÌ member ÇÔ¼ö´Â NAM input format¿¡ ÀÖ´Â simulation trace¸¦ ±â·ÏÇϱâ À§ÇÑ ½Ã¹Ä·¹ÀÌÅ͸¦ ¸»ÇÑ´Ù. ±×°ÍÀº ¶ÇÇÑ trace°¡ $ns flush-trace ¸í·É¿¡ ÀÇÇØ ³ªÁß¿¡ ¾²¿©Áú file nameÀ» ÁØ´Ù.

 

¡Û proc finish {}:

ÀÌ ½Ã¹Ä·¹ÀÌ¼Ç µÚ¿¡ $ns at 5.0 "finish" ¸í·É¿¡ ÀÇÇØ È£ÃâµÈ´Ù. ÀÌ ÇÔ¼ö¿¡¼­ post-simulation process°¡ ±ÔÁ¤µÈ´Ù.

 

¡Û set n0 [$ns node]:

member ÇÔ¼ö node´Â node¸¦ »ý¼ºÇÑ´Ù. NS¿¡ ÀÖ´Â node´Â address¿Í port classifierµé·Î ¸¸µé¾îÁø º¹ÇÕ objectÀÌ´Ù.(´ÙÀ½ section¿¡¼­ ±â¼úµÈ´Ù) »ç¿ëÀÚ´Â ÁÖ¼Ò¿Í port classifier object¸¦ ºÐ¸®ÇÏ¿© »ý¼ºÇϰí, ±×µéÀ» ÇÔ²² ¿¬°áÇÔÀ¸·Î½á node¸¦ »ý¼ºÇÒ ¼ö ÀÖ´Ù. ±×·¯³ª, ÀÌ Simulator objectÀÇ member ÇÔ¼ö´Â job¸¦ º¸´Ù ½±°Ô ¸¸µç´Ù. node°¡ »ý¼ºµÇ´Â ¹æ¹ýÀ» º¸±â À§ÇØ file "ns-2/tcl/libs/ns-lib.tcl" °ú "ns-2/tcl/ns-node.tcl"À» »ìÆìº¸¶ó.

 

¡Û $ns duplex-link node1 node2 bandwidth delay queue-type:

»ó¼úµÈ bandwidth¿Í delayÀÇ µÎ °³ÀÇ simplex link¸¦ »ý¼ºÇϸç, µÎ °³ÀÇ »ó¼úµÈ node¸¦ ¿¬°áÇÑ´Ù. NS¿¡¼­ nodeÀÇ Ãâ·Â queue´Â linkÀÇ ºÎºÐÀ¸·Î ±¸ÇöµÈ´Ù. ±×·¯¹Ç·Î, user´Â link¸¦ »ý¼ºÇÒ ¶§ queue type¸¦ »ó¼úÇØ¾ß ÇÑ´Ù. À§ÀÇ ½Ã¹Ä·¹ÀÌ¼Ç script¿¡¼­, DropTail queue°¡ »ç¿ëµÈ´Ù. ¸¸ÀÏ µ¶ÀÚ°¡ RED queue¸¦ »ç¿ëÇϱ⸦ ¿øÇÑ´Ù¸é, °£´ÜÇÏ°Ô DropTailÀ» RED·Î ´ëÄ¡ÇÏ¸é µÈ´Ù. linkÀÇ NS ±¸ÇöÀº ´ÙÀ½ section¿¡¼­ º¸¿©Áø´Ù. nodeó·³, linkµµ compound objectÀ̸ç user´Â ±×°ÍÀÇ sub-object¸¦ »ý¼ºÇÏ°í ±×µé°ú node¸¦ ¿¬°áÇÒ ¼ö ÀÖ´Ù. Link source code´Â "ns-2/tcl/libs/ns-lib.tcl"°ú "ns-2/tcl/libs/ns-link.tcl" ÆÄÀÏ¿¡¼­ ãÀ» ¼ö ÀÖ´Ù. ÁÖ¸ñÇØ¾ßÇÏ´Â Çϳª´Â ´ç½ÅÀÌ lossy link(½ÇÁ¦ user´Â ¾î¶² network object¸¦ ¸¸µé°í »ðÀÔÇÒ ¼ö ÀÖ´Ù.) ¸¦ ½Ã¹Ä·¹ÀÌÆ® Çϱâ À§Çؼ­ link component ¾È¿¡¼­ error module¸¦ »ðÀÔÇÒ ¼ö ÀÖ´Ù. À̰ÍÀ» ¾î¶»°Ô ã´Â°¡ ÇÏ´Â °ÍÀº NS document¸¦ Âü°íÇ϶ó.

 

¡Û $ns queue-limit node1 node2 number:

ÀÌ ¶óÀÎÀº »ó¼úµÈ ¼ýÀÚ·Î node1°í node2¸¦ ¿¬°áÇÏ´Â µÎ °³ÀÇ simplex linkÀÇ queue limit¸¦ setÇÑ´Ù. ÀÌ Á¡¿¡¼­, ÀúÀÚ´Â ¾ó¸¶³ª ¸¹Àº ½Ã¹Ä·¹ÀÌÅÍ objectÀÇ member ÇÔ¼öÀÇ Á¾·ùµéÀÌ À¯¿ëÇÑÁö, ±×¸®°í ±×°ÍµéÀÌ ¹«¾ùÀÎÁö¸¦ ¾ËÁö ¸øÇÑ´Ù. "ns-2/tcl/libs/ns-lib.tcl"°ú "ns-2/tcl/libs/ns-link.tcl"À» ã¾Æº¸°Å³ª, º¸´Ù ÀÚ¼¼ÇÑ Á¤º¸¸¦ ãÀ¸·Á¸é NS document¸¦ Âü°íÇ϶ó.

 

¡Û $ns duplex-link-op node1 node2...:

lineÀÇ ´ÙÀ½ couple´Â NAM display¸¦ À§Çؼ­ »ç¿ëµÈ´Ù. ÀÌ ¶óÀÎÀÇ È¿°ú¸¦ º¸±â À§Çؼ­ user´Â ÀÌ ¶óÀÎÀ» ±¸¼ºÇÏ°í ½Ã¹Ä·¹À̼ÇÀ» ½ÃµµÇÒ ¼ö ÀÖ´Ù.

Áö±Ý, ±âº»ÀûÀÎ network setupÀÌ ÇàÇØÁ³´Ù. ´ÙÀ½¿¡ ÇØ¾ßÇÒ ÀÏÀº TCP¿Í UDP °°Àº traffic agent, FTP¿Í CBR°°Àº traffic source¸¦ setupÇÏ´Â °ÍÀÌ´Ù. ±×¸®°í ±×°ÍµéÀ» °¢°¢ node¿Í agent·Î Á¢¼ÓÇÏ´Â °ÍÀÌ´Ù.

 

¡Û set tcp[new Agent/TCP]:

ÀÌ ¶óÀÎÀº TCP agent¸¦ »ý¼ºÇÏ´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù. ±×·¯³ª, ÀϹÝÀûÀ¸·Î user´Â ÀÌ·± ¹æ¹ýÀ¸·Î ¾î¶² agent³ª traffic source¸¦ »ý¼ºÇÒ ¼ö ÀÖ´Ù. Agent¿Í traffic source´Â »ç½Ç»ó ±âº»ÀûÀÎ object(not compound object)À̸ç, ´ëºÎºÐ C++¿¡¼­ ±¸ÇöµÇ°í OTcl·Î ¸µÅ©µÈ´Ù. ±×·¯¹Ç·Î, ÀÌ·¯ÇÑ object instance¸¦ »ý¼ºÇϴ Ư¼öÇÑ Simulator object member ÇÔ¼ö´Â ¾ø´Ù. Agentsk traffic source¸¦ »ý¼ºÇϱâ À§Çؼ­, User´Â object class À̸§(Agent/TCP, Agent/TCPSink, Application/FTP µîµî)À» ¾Ë¾Æ¾ß ÇÑ´Ù. ÀÌ Á¤º¸´Â NS document³ª ÀÌ document¿¡¼­ ºÎºÐÀûÀ¸·Î ãÀ» ¼ö ÀÖ´Ù. ±×·¯³ª, one shortcut´Â "ns-2/tcl/libs/ns-default.tcl" fileÀ» º¸´Â °ÍÀÌ´Ù. ÀÌ fileÀº °¡¿ëÇÑ network object¿¡ ´ëÇÑ default ±¸¼º parameter °ª settingÀ» Æ÷ÇÔÇÑ´Ù. ±×·¯¹Ç·Î, ±×°ÍÀº ¾î¶² Á¾·ùÀÇ network object°¡ NS¿¡ À¯¿ëÇѰ¡ ±×¸®°í ±¸¼º parameter°¡ ¹«¾ùÀΰ¡¿¡ ´ëÇÑ ÈǸ¢ÇÑ indicator·Î¼­ µ¿ÀÛÇÑ´Ù.

 

¡Û $ns attach-agent node agent:

attach-agent member ÇÔ¼ö´Â node object·Î »ý¼ºµÈ agent object¸¦ Á¢¼ÓÇÑ´Ù. ½ÇÁ¦ÀûÀ¸·Î, ÀÌ ÇÔ¼ö´Â ±ÔÁ¤µÈ nodeÀÇ attach member ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù. ±×°ÍÀº ±× ÀÚ½ÅÀ¸·Î ÁÖ¾îÁø agent¸¦ Á¢¼ÓÇÑ´Ù. ±×·¯¹Ç·Î, user´Â ¿¹¸¦ µé¸é, $n0 attach $tcp¿¡ ÀÇÇØ µ¿ÀÏÇÑ ÀÏÀ» ÇÒ ¼ö ÀÖ´Ù. À¯»çÇϰÔ, °¢ agent object´Â ±× ÀÚ½ÅÀ¸·Î traffic source object¸¦ Á¢¼ÓÇÏ´Â member ÇÔ¼ö attach-agent¸¦ °¡Áø´Ù.

 

¡Û $ns connect agent1 agent2:

¼­·Î°£¿¡ Åë½ÅÀ» ÇÒ µÎ °³ÀÇ agent°¡ »ý¼ºµÈ ÈÄ¿¡, ´ÙÀ½ ÀÏÀº ±×µé »çÀÌ¿¡ logical network ¿¬°áÀ» ¼³Á¤ÇÏ´Â °ÍÀÌ´Ù. ÀÌ ¶óÀÎÀº °¢±â ´Ù¸¥ network¿Í port address pair·Î ¸ñÀûÁö address¸¦ settingÇÔÀ¸·Î¼­ network ¿¬°áÀ» ¼³Á¤ÇÑ´Ù.

network ±¸¼ºÀÌ ¸ðµÎ ¿Ï·áµÇ¾ú´Ù°í °¡Á¤Çϸé, ´ÙÀ½¿¡ ÇØ¾ßÇÒ ÀÏÀº simulation ½Ã³ª¸®¿À(½Ã¹Ä·¹ÀÌ¼Ç scheduling µî)¸¦ ¾²´Â ÀÏÀÌ´Ù. Simulator object´Â ¸¹Àº scheduling member ÇÔ¼ö¸¦ °®´Â´Ù. ±×·¯³ª, ´ëºÎºÐ »ç¿ëµÇ´Â ¹æ¹ýÀº ´ÙÀ½°ú °°´Ù.

 

¡Û $ns at time "string":

Simulator objectÀÇ member ÇÔ¼ö´Â ÁÖ¾îÁø simulation time¿¡ ±ÔÁ¤µÈ stringÀÇ ½ÇÇàÀ» scheduleÇϱâ À§ÇØ scheduler(scheduler_ ´Â script ½ÃÀÛ ºÎºÐ¿¡¼­ [net scheduler] ¸í·É¿¡ ÀÇÇØ »ý¼ºµÈ scheduler object¸¦ Áö½ÃÇÏ´Â º¯¼öÀÌ´Ù.)¸¦ ¸¸µç´Ù. ¿¹¸¦ µé¾î, $ns at 0.1 "$cbr start"´Â data Àü¼ÛÀ» À§ÇØ CBRÀ» ½ÃÀÛÇÏ´Â CBR traffic source objectÀÇ start member ÇÔ¼ö¸¦ È£ÃâÇÏ´Â call¸¦ ¸¸µé °ÍÀÌ´Ù. NS¿¡¼­ º¸Åë traffic source°¡ ½ÇÁ¦ÀûÀÎ data¸¦ Àü¼ÛÇÏÁö´Â ¾ÊÁö¸¸ ±×°ÍÀº Àü¼ÛÇØ¾ßÇÏ´Â data°¡ ¸¹À¸¸ç, Àü¼ÛÇÒ data°¡ ¾ó¸¶³ª ¸¹ÀºÁö ¾Ë°í ÀÖ´Ù´Â °ÍÀ» ±âÃÊÀûÀÎ Agent¿¡°Ô °øÁöÇϰí packetÀ» »ý¼ºÇÏ¸ç ±×°ÍµéÀ» Àü¼ÛÇÑ´Ù.

¸ðµç network ±¸¼º ÈÄ¿¡, scheduling°ú post-simulation ÀýÂ÷ specificationÀÌ ÇàÇØÁø´Ù. ³²¾ÆÀÖ´Â À¯ÀÏÇÑ ÀÏÀº ½Ã¹Ä·¹À̼ÇÀ» ÀÛµ¿½ÃŰ´Â °ÍÀÌ´Ù. À̰ÍÀº $ns runÀ¸·Î ½ÇÇàµÈ´Ù.






























 

2.3 Event Scheduler

ÀÌ sectionÀº NSÀÇ discrete event scheduler¿¡ °üÇØ ¼³¸íÇÑ´Ù. ¾ÕÀÇ section¿¡¼­ ±â¼úÇÑ ¹Ù¿Í °°ÀÌ, event schedulerÀÇ main user´Â packet-handling delay¸¦ ½Ã¹Ä·¹ÀÌÆ® Çϰųª, ½Ã°£À» ÇÊ¿ä·Î ÇÏ´Â network ±¸¼º¿ä¼ÒµéÀÌ´Ù. ±×¸²5´Â event scheduler¸¦ »ç¿ëÇÏ´Â °¢ network object¸¦ ¸ð¿©ÁØ´Ù. event¸¦ ¹ßÇàÇÏ´Â network object´Â scheduleµÈ ½Ã°£¿¡¼­ µÚ¿¡ event¸¦ Á¶Á¤ÇÏ´Â »ç¶÷ÀÓÀ» ÁÖ¸ñÇ϶ó. ¶ÇÇÑ, network objectµé °£ÀÇ data path°¡ event path¿Í ´Ù¸£´Ù´Â °Íµµ ÁÖ¸ñÇ϶ó. ½ÇÁ¦ÀûÀ¸·Î, packetµéÀº ÇϳªÀÇ network object·ÎºÎÅÍ senderÀÇ ¹æ¹ýÀÎ send(Packet* P) {target_ -> recv(p)};¿Í receiverÀÇ ¹æ¹ýÀÎ recv(Packet*, Handler*h=0)¸¦ »ç¿ëÇÏ´Â ´Ù¸¥ object¿¡°Ô Àü´ÞµÈ´Ù.



fig 5. Discrete Event Scheduler

 

NS´Â ±¸ÇöµÈ event schedulerÀÇ µÎ °³ÀÇ ´Ù¸¥ typeÀ» °¡Áö°í ÀÖ´Ù. À̵éÀº real-time°ú non-real-time schedulerÀÌ´Ù. non-real-time-scheduler¿¡ ´ëÇØ¼­´Â ±×µéÀÌ ¸ðµÎ °°Àº °ÍÀ» ³í¸®ÀûÀ¸·Î ¼öÇàÇÑ´Ù ÇÏ´õ¶óµµ, ¼¼ °³ÀÇ ±¸Çö(List, Heap¿Í Calendar)ÀÌ °¡¿ëÇÏ´Ù. À̰ÍÀº backward ȣȯ¼º: »ç¿ëÀÚ(package¿¡ Æ÷ÇÔµÈ ¿ø·¡ »ç¿ëÀÚ°¡ ¾Æ´Ñ)¿¡ ÀÇÇØ ºÎ°¡µÈ network ±¸¼º¿ä¼ÒµéÀÇ Á¶±â±¸ÇöÀÇ ´ëºÎºÐÀº public ÇÔ¼ö¸¦ ÅëÇØ¼­ »Ó¸¸ ¾Æ´Ï¶ó ³»ºÎ ÁÖÀ§¸¦ ºóµÕ°Å¸®´Â schedulerÀÇ Æ¯¼öÇÑ typeÀ» »ç¿ëÇϱ⠶§¹®ÀÌ´Ù. Calendar non-real-time scheduler´Â default·Î setµÈ´Ù. real-time scheduler´Â emulationÀ» À§ÇÑ °ÍÀ̸ç, ±×°ÍÀº ½Ã¹Ä·¹ÀÌÅͰ¡ real networkÀ¸·Î »óÈ£ ÀÛ¿ëÇÏ´Â °ÍÀ» Çã¿ëÇÑ´Ù. ÇöÀç, emulationÀº experimental versionÀÌ À¯¿ëÇÔÀ» Åë°úÇÏ°í °³¹ß Áß¿¡ ÀÖ´Ù. ´ÙÀ½Àº Ư¼öÇÑ event scheduler¸¦ ¼±ÅÃÇÏ´Â ¿¹ÀÌ´Ù.

...

set ns[new Simulator]

$ns use-scheduler Heap

...

event schedulerÀÇ ¶Ç ´Ù¸¥ »ç¿ëÀº ¿¹ÄÁ´ë, FTP ÀÀ¿ëÀ» ½ÃÀÛÇÒ ¶§, ½Ã¹Ä·¹À̼ÇÀ» ³¡³¾ ¶§, ½Ã¹Ä·¹À̼ÇÀÌ µ¿ÀÛ¿¡ ¾Õ¼­ ½Ã¹Ä·¹ÀÌ¼Ç ½Ã³ª¸®¿À¸¦ »ý¼ºÇϱâ À§ÇÔ µîÀÇ simulation event¸¦ scheduleÇÏ´Â °ÍÀÌ´Ù. event scheduler object´Â ±× ÀÚ½ÅÀÌ Æ¯¼öÇÑ ½Ã¹Ä·¹ÀÌ¼Ç time¿¡ AtEvent·Î ºÒ¸®´Â Ư¼öÇÑ event¸¦ ¹ßÇàÇÏ´Â at time "string"°ú °°Àº simulation scheduling member ÇÔ¼ö¸¦ °¡Áö°í ÀÖ´Ù. "AtEvent"´Â ½ÇÁ¦ÀûÀ¸·Î "Event"ÀÇ child classÀ̸ç, ±×°ÍÀº ÁÖ¾îÁø stringÀ» holdÇϱâ À§ÇÑ ºÎ°¡ÀûÀÎ º¯¼ö¸¦ °¡Áö°í ÀÖ´Ù. ±×·¯³ª, ±×°ÍÀº event scheduler ³»¿¡¼­ normal(packet related) event¿Í °°ÀÌ Ãë±ÞµÈ´Ù. ½Ã¹Ä·¹À̼ÇÀÌ ½ÃÀÛµÉ ¶§, ±×¸®°í event queue¿¡ ÀÖ´Â AtEvent¿¡ ´ëÇÑ ¿¹Á¤µÈ ½Ã°£ÀÌ µÉ ¶§, AtEvent´Â Çѹø »ý¼ºµÈ "AtEvent handler"·Î ³Ñ¾î°£´Ù. ±×¸®°í ¸ðµç AtEvent¸¦ Á¶Á¤Çϸç, AtEvevtÀÇ string field¿¡ ÀÇÇØ ±ÔÁ¤µÈ OTcl ¸í·É¾î°¡ ½ÇÇàµÈ´Ù. ´ÙÀ½Àº À§ ¿¹ÀÇ ¹öÀüÀ» ºÎ°¡ÇÑ simulation event scheduling lineÀÌ´Ù.

...

set ns[new Simulator]

$ns use-scheduler Heap

$ns at 300.5 "complete_sim"

...

proc complete_sim{} {

....

}

´ç½ÅÀº À§ÀÇ ¿¹·ÎºÎÅÍ at time "string"ÀÌ Simulator object(set ns[new Simulator])ÀÇ member ÇÔ¼öÀÓÀ» ÁÖ¸ñÇß´Ù. ±×·¯³ª, ¹æ±ÝÀÇ ½Ã¹Ä·¹ÀÌÅÍ object´Â user interface·Î µ¿ÀÛÇϸç, ±×°ÍÀº ½ÇÁ¦ÀûÀ¸·Î real job¸¦ ÇàÇÏ´Â network object³ª scheduler objectÀÇ member ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù´Â °ÍÀ» ±â¾ïÇ϶ó. ´ÙÀ½Àº ºÎºÐÀûÀÎ listÀ̸ç, scheduler member ÇÔ¼ö¿¡ Á¤ÇÕÇÏ´Â Simulator object member ÇÔ¼ö¿¡ ´ëÇÑ °£·«ÇÑ ±â¼úÀÌ´Ù.

Simulator instproc now #return scheduler's notion of current time

Simulator instproc at args #schedule execution of code at specified time

Simulator instproc at-now args #schedule execution of code at now

Simulator instproc after n args #schedule execution of code after n secs

Simulator instproc run args #start scheduler

Simulator instproc halt #stop(pause) scheduler





























 

2.4 Network Components

ÀÌ sectionÀº ´ëºÎºÐ È¥ÇÕ network componentÀÎ NS components¿¡ °üÇØ¼­ ¼³¸íÇÑ´Ù. ±×¸²6.Àº NSÀÇ ºÎºÐÀûÀÎ OTcl class °èÃþ±¸Á¶¸¦ º¸¿©ÁØ´Ù. À̰ÍÀº ±âº»ÀûÀÎ network component¸¦ ÀÌÇØÇϴµ¥ µµ¿òÀ» ÁØ´Ù. NS class °èÃþ±¸Á¶¸¦ ¿Ï¼ºÇϱâ À§Çؼ­ http://www-sop.inria.fr/rodeo/personnel/Antoine.Clerget/ns¸¦ ¹æ¹®Ç϶ó.


fig 6. Class Hierarchy (partial)

 

°èÃþ±¸Á¶ÀÇ root´Â ¸ðµç OTcl library object(scheduler, network components, timer¿Í NAM °ü·ÃÇÑ °ÍµéÀ» Æ÷ÇÔÇÏ´Â ´Ù¸¥ objectµé)ÀÇ superclassÀÎ TclObjectÀÌ´Ù. TclObject¸¦ ¼±Á¶ class·Î °®´Â NSObject class´Â packetÀ» Á¶Á¤ÇÏ´Â ¸ðµç ±âº»ÀûÀÎ network component objectÀÇ superclassÀÌ´Ù. ±×°ÍÀº node¿Í link¿Í °°Àº È¥ÇÕ network object¸¦ ±¸¼ºÇÑ´Ù. ±âº»ÀûÀÎ network ±¸¼º¿ä¼Ò´Â °¡´ÉÇÑ Ãâ·Â data °æ·ÎÀÇ ¼ö¿¡ ±â¹ÝÀ» µÐ Connector¿Í ClassfierÀÇ µÎ °³ÀÇ subclass·Î ´õ ³ª´µ¾î Áø´Ù. ÇϳªÀÇ Ãâ·Â data °æ·Î¸¸À» °®´Â ±âº»ÀûÀÎ network object´Â Connector classÇÏ¿¡ ÀÖ´Ù. ±×¸®°í multiple Ãâ·Â data °æ·Î¸¦ °®´Â switching object´Â Classfier classÇÏ¿¡ ÀÖ´Ù.

Node¿Í Routing

node´Â node entry object¿Í ±×¸² 7.¿¡¼­ º» classfier·Î ±¸¼ºµÈ È¥ÇÕ objectÀÌ´Ù. NS¿¡´Â µÎ typeÀÇ node°¡ ÀÖ´Ù. unicast node´Â routingÀ» unicastÇÏ´Â address classfier¿Í port classfier¸¦ °¡Áö°í ÀÖ´Ù. multicast node´Â unicast packetÀ¸·ÎºÎÅÍ multicast packetÀ» ºÐ¸®ÇÏ´Â classfier¿Í multicast routingÀ» ¼öÇàÇÏ´Â multicast classfier¸¦ °¡Áö°í ÀÖ´Ù.



fig 7. Node(Unicast and Multicast)
 

NS¿¡¼­ Unicast node´Â default nodeÀÌ´Ù. Multicast node¸¦ »ý¼ºÇϱâ À§Çؼ­´Â »ç¿ëÀÚ´Â scheduler object¸¦ »ý¼ºÇÏ´Â right afterÀ» »ç¿ëÇÏ¿©, ÀÔ·Â OTcl script³»¿¡ ¸íÈ®ÇÏ°Ô ¸í½Ã¸¦ ÇØ¾ßÇÑ´Ù. »ý¼ºµÉ ¸ðµç node´Â multicast nodeµéÀÌ´Ù. node typeÀ» ±ÔÁ¤ÇÑ ÈÄ¿¡ user´Â default¸¦ »ç¿ëÇÏ´Â °Í°ú´Â ´Ù¸¥ Ư¼öÇÑ routing protocolÀ» ¼±ÅÃÇÒ ¼ö ÀÖ´Ù.

 

¡Û Unicast

-. $ns rtproto type

-. type: Static, Session, DB, cost, multi-path

 

¡Û Multicast

-. $ns multicast (right after set $ns[new Scheduler])

-. $ns mrtproto type

-. type: CtrMcast, DM, ST, BST

routing¿¡ °üÇÑ »ó¼¼ÇÑ Á¤º¸´Â NS document¸¦ Âü°íÇ϶ó. documentationÀº unicast¿Í multicast routing¿¡ °üÇÏ¿© ¼³¸íÇÏ´Â chapter°¡ ÀÖ´Ù.



Link

link´Â NS¿¡ ÀÖ´Â ¶Ç ´Ù¸¥ º¹ÇÕ objectÀÌ´Ù. user°¡ simulator objectÀÇ member ÇÔ¼öÀÎ duplex-link¸¦ »ç¿ëÇÏ´Â link¸¦ »ý¼ºÇÒ ¶§, ¾ç ¹æÇâ¿¡ ÀÖ´Â µÎ °³ÀÇ simplex linkµéÀÌ ±×¸²8.¿¡ º¸´Â ¹Ù¿Í °°ÀÌ »ý¼ºµÈ´Ù.



fig 8. Link
 

ÁÖ¸ñÇÒ Çϳª´Â nodeÀÇ Ãâ·Â queue°¡ ½ÇÁ¦ÀûÀ¸·Î simplex link objectÀÇ ÀϺηΠ±¸ÇöµÈ´Ù´Â °ÍÀÌ´Ù. queue·ÎºÎÅÍ dequeueµÈ PacketµéÀº link delay¸¦ ½Ã¹Ä·¹ÀÌÆ®ÇÏ´Â Delay object·Î ÅëÇÑ´Ù. ±×¸®°í queue¿¡¼­ dropµÈ PacketµéÀº Nul Agent·Î º¸³»Áö¸ç °Å±â¼­ ÀÚÀ¯·Ó°Ô µÈ´Ù. °á°úÀûÀ¸·Î, TTL object´Â ¼ö½ÅµÈ °¢ packet¿¡ ´ëÇÑ TTL parameter¸¦ °è»êÇϰí PacketÀÇ TTL field¸¦ °»½ÅÇÑ´Ù.

 

¡Û Tracing

NS¿¡¼­, network activeµéÀº simplex link ÁÖÀ§·Î traceµÈ´Ù. ¸¸ÀÏ simulator°¡ network activities¸¦ traceÇϵµ·Ï Áö½Ã¸¦ ¹Þ´Â´Ù¸é($ns trace-all file ȤÀº $ns namtrace-all file), ¸í·É µÚ¿¡ »ý¼ºµÈ link´Â ±×¸²9.¿¡¼­ º¸´Â ¹Ù¿Í °°ÀÌ »ðÀÔµÈ ÈÄ¼Ó trace object¸¦ °¡Áú °ÍÀÌ´Ù. User´Â ¶ÇÇÑ create-trace {type file src dst} ¸í·ÉÀ» »ç¿ëÇÏ¿© src¿Í dst node »çÀÌ¿¡ typeÀ¸·Î Á¤ÀÇÇÑ typeÀÇ trace object¸¦ ¸íÈ®ÇÏ°Ô »ý¼ºÇÒ °ÍÀÌ´Ù.


fig 9. Inserting Trace Objects
 

°¢ »ðÀÔµÈ trace object(EnqT, DeqT, DrpT, RecvT µî)°¡ packet¸¦ ¼ö½ÅÇÒ ¶§, ±×°ÍÀº ¾î¶² ½Ã¹Ä·¹ÀÌ¼Ç time¿¡ ÀÇÇØ ¼ÒºñÇÔÀÌ ¾øÀÌ ±ÔÁ¤µÈ trace file¿¡ ±â·ÏÇÑ´Ù. ±×¸®°í ´ÙÀ½ network object·Î packet¸¦ Àü´ÞÇÑ´Ù. trace formatÀº General Analysis Example section¿¡¼­ ½ÃÇèµÉ °ÍÀÌ´Ù.

 

¡Û Queue Monitor

±âº»ÀûÀ¸·Î, object¸¦ tracingÇÏ´Â °ÍÀº ±×°ÍµéÀÌ À§Ä¡ÇÑ °÷¿¡¼­ packet arrival timeÀ» ±â·ÏÇϱâ À§Çؼ­ ¼³°èµÈ´Ù. ºñ·Ï user°¡ trace·ÎºÎÅÍ ÃæºÐÇÑ Á¤º¸¸¦ ¾ò´Â´Ù ÇÏ´õ¶óµµ, Ưº°ÇÑ Ãâ·Â queue ³»ºÎ¿¡¼­ ¹«¾ùÀÌ Áö³ª°¡°í ÀÖ´ÂÁö¿¡ °üÇØ Èï¹Ì°¡ ÀÖÀ» °ÍÀÌ´Ù. ¿¹¸¦ µé¾î, RED queue µ¿ÀÛ¿¡ °ü½ÉÀÖ´Â user´Â Æò±Õ queue Å©±âÀÇ dynamics ¹× Ưº°ÇÑ RED queue(queue monitoringÀÌ ÇÊ¿äÇÑ µîµî)ÀÇ ÇöÀç queue Å©±â¸¦ ÃøÁ¤Çϱ⸦ ¿øÇÒ °ÍÀÌ´Ù. Queue monitoringÀº ±×¸² 10¿¡ º¸´Â ¹Ù¿Í °°ÀÌ queue monitor object¿Í snoop queue object¸¦ »ç¿ëÇÏ¿© ¾òÀ» ¼ö ÀÖ´Ù.



fig 10. Monitoring Queue
 

packetÀÌ µµÂøÇÒ ¶§, snoop queue object´Â ÀÌ eventÀÇ queue monitor object¸¦ ÁÖ½ÃÇÑ´Ù. ÀÌ Á¤º¸¸¦ »ç¿ëÇÏ´Â queue monitor´Â queue¸¦ monitorÇÑ´Ù. RED queue monitoring ¿¹´Â RED queue monitor Example section¿¡ ¼­ º¸¿©Áø´Ù. snoop object´Â ºñ·Ï ±×°ÍÀÌ À§ ±×¸²¿¡¼­ º¸¿©ÁöÁö ¾Ê´Â´Ù ÇÏ´õ¶óµµ object¸¦ tracingÇÏ´Â °Í°ú º´·Ä·Î »ç¿ëµÉ ¼ö ÀÖ´Ù´Â Á¡À» ÁÖ¸ñÇ϶ó.

Packet Flow Example

Áö±Ý±îÁö µÎ °³ÀÇ °¡Àå Áß¿äÇÑ network ±¸¼º¿ä¼Ò(node¿Í link)°¡ ½ÃÇèµÇ¾ú´Ù. ±×¸²11.Àº ¿¹Á¦ simulation network setup°ú packet flowÀÇ ³»ºÎ¸¦ º¸¿©ÁØ´Ù. network´Â network address°¡ °¢°¢ 0°ú 1ÀÎ µÎ °³ÀÇ node(n0¿Í n1)¸¦ ±¸¼ºÇÑ´Ù. port 0À» »ç¿ëÇÏ¿© no¿¡ Á¢¼ÓµÈ TCP agent´Â port 0¿Í n1¿¡ Á¢¼ÓµÈ TCP sink object¿Í Åë½ÅÇÑ´Ù. °á±¹, FTP application(ȤÀº traffic source)´Â ¿ª°£ ¸¹Àº data¸¦ Àü¼ÛÇÒ °ÍÀ» ¿äûÇÏ´Â TCP agent¿¡ Á¢¼ÓµÈ´Ù.



fig 11. Packet Flow Example
 

À§ ±×¸²Àº FTP over TCPÀÇ Á¤È®ÇÑ µ¿ÀÛÀ» º¸¿©ÁÖÁö´Â ¾Ê´Â´Ù´Â °Í¿¡ ÁÖ¸ñÇ϶ó. ±×°ÍÀº ¿ÀÁ÷ simulation network setup°ú packet flowÀÇ »ó¼¼ÇÑ ³»ºÎ¸¦ º¸¿©ÁÙ »ÓÀÌ´Ù.






















 

2.5 Packet

NS packetÀº headerµéÀÇ stack°ú optional data space·Î ±¸¼ºµÈ´Ù. "Simple Simulation Example" section¿¡¼­ °£´ÜÈ÷ ¾ð±ÞµÈ °Íó·³, packet header formatÀº Simulator object°¡ »ý¼ºµÉ ¶§ ÃʱâÈ­µÇ¸ç, ÇÊ¿äÇÑ ¸¸Å­ ¾î¶² object¿¡ ÀÇÇØ Åë»óÀûÀ¸·Î »ç¿ëµÇ´Â common header Áï, IP header, TCP header, RTP header(UDP´Â RTP header¸¦ »ç¿ëÇÑ´Ù.)¿Í trace header¿Í °°Àº (¾Æ¸¶ »ç¿ë °¡´ÉÇÑ)header¸¦ ¸ðµç stackÀÌ µî·ÏÇÑ °÷¿¡¼­ Á¤ÀǵǸç, stack¿¡ ÀÖ´Â °¢ headerÀÇ offsetÀÌ ±â·ÏµÈ´Ù. À̰ÍÀÌ ÀǹÌÇÏ´Â ¹Ù´Â, Ư¼öÇÑ header°¡ »ç¿ëµÇ´ÂÁö ¾Æ´ÑÁö ÇÏ´Â °ÍÀ̸ç, µî·ÏµÈ ¸ðµç header·Î ±¸¼ºµÈ stackÀº packetÀÌ agent¿¡ ÀÇÇØ ÇÒ´çµÉ ¶§ »ý¼ºµÇ°í, network object°¡ packetÀÇ stack¿¡ ÀÖ´Â ¾î¶² headerµµ accessÇÒ ¼ö ÀÖ´Ù´Â °ÍÀÌ´Ù.



fig 12. NS Packet Format
 

º¸Åë, header stack(±×¸®°í nullÀÎ data space pointer)À» °¡Áö±â¸¸ ÇÑ´Ù. ºñ·Ï packetÀÌ data space ÇÒ´ç¿¡ ÀÇÇØ ÀÀ¿ëÀ¸·ÎºÎÅÍ ½ÇÁ¦ÀûÀÎ data¸¦ ¿î¹ÝÇÒ ¼ö ÀÖ´Ù ÇÏ´õ¶óµµ, ¸Å¿ì ±Ø¼Ò¼öÀÇ ÀÀ¿ë°ú agent implementationµéÀÌ À̰ÍÀ» Áö¿øÇÑ´Ù. À̰ÍÀº non-real-time simulation ÁÖÀ§¿¡ ÀÖ´Â data¸¦ ¿î¹ÝÇÏ´Â °ÍÀº ÀÇ¹Ì ¾ø´Â °ÍÀ̱⠶§¹®ÀÌ´Ù. ±×·¯³ª, ¸¸ÀÏ ´ç½ÅÀÌ networkÀ» Ⱦ´ÜÇÏ¿© ´Ù¸¥ ÀÀ¿ë¿¡°Ô talkÇÏ´Â ÀÀ¿ëÀ» ±¸ÇöÇϱ⸦ ¿øÇÑ´Ù¸é, ±âÃÊÀûÀÎ agent ±¸Çö¿¡¼­ ¾à°£ÀÇ º¯ÇüÀ» °¡ÇÑ °ÍÀ» »ç¿ëÇϱ⠿øÇÒ °ÍÀÌ´Ù. ¶Ç ´Ù¸¥ °¡´ÉÇÑ approach´Â ÀÀ¿ëÀ» À§ÇÑ »õ·Î¿î header¸¦ »ý¼ºÇϰí, ÀÀ¿ë¿¡¼­ »õ·Î¿î header·Î ¼ö½ÅµÈ data¸¦ ¾²±â À§ÇØ ±âÃÊÀûÀÎ agent¸¦ º¯ÇüµÉ °ÍÀÌ´Ù. second approach´Â "Add New Application and Agent"¶ó ºÒ¸®´Â ¸¶Áö¸· sectionÀÇ ¿¹·Î º¸¿©Áø´Ù.

 

 

 

 

 

3. Post Simulation


3.1 Trace Analysis Example

ÀÌ sectionÀº trace ºÐ¼® ¿¹¸¦ º¸¿©ÁØ´Ù. Example 4.´Â trace fileÀ» ¿­°í ±×°Í¿¡ trace¸¦ ¾²±â À§ÇØ ¾à°£ÀÇ lineÀÌ ºÎ°¡µÈ "Simple Simulation Example" section¿¡ ÀÖ´Â °Í°ú µ¿ÀÏÇÑ OTcl scriptÀÌ´Ù. ½Ã¹Ä·¹ÀÌ¼Ç ½Ã³ª¸®¿À¸¦ »ý¼ºÇÏ´Â network topology´Â "Simple Simulation Example" section¿¡ ÀÖ´Â ±×¸²4.¸¦ Âü°íÇ϶ó. ÀÌ scrip¸¦ µ¿ÀÛ½Ã۱â À§Çؼ­ "ns-simple-trace.tcl"À» down ¹Þ°í, shell prompt¿¡¼­ "ns ns-simple-trace.tcl"À» ÀÔ·ÂÇ϶ó.

 

Example 4. Trace Enabled Simple NS Simulation Script

(Modified from Example 3)

......

#Open the NAM trace file

set nf [open out.nam w]

$ns namtrace-all $nf

#Open the Trace file

set tf [open out.tr w]

$ns trace-all $tf

#Define a 'finish' procedure

proc finish {} {

global ns nf tf

$ns flush-trace

#Close the NAM trace file

close $nf

#Close the Trace file

close $tf

#Execute NAM on the trace file

exec nam out.nam &

exit 0

}

......



À§ÀÇ script¸¦ µ¿ÀÛÇÔÀ¸·Î½á, NAM¿¡ ÀÔ·ÂÀ¸·Î »ç¿ëµÇ´Â NAM trace file°ú ½Ã¹Ä·¹ÀÌ¼Ç ºÐ¼®À» À§ÇØ »ç¿ëµÉ "out.tr"·Î ºÒ¸®´Â trace file¸¦ »ý¼ºÇÑ´Ù. ±×¸²13Àº trace format°ú "out.tr"·ÎºÎÅÍÀÇ ¿¹Á¦ trace data¸¦ º¸¿©ÁØ´Ù.





fig 13. Trace Format Example
 

°¢ trace lineÀº µÚ¿¡ event simulation time(´ÜÀ§: ÃÊ)°ú ¹ß»ýµÈ event »ó¿¡ ÀÖ´Â link¸¦ ±¸º°ÇÏ´Â from node, to node¸¦ µÚ¿¡ µÐ event(+, -, d, r) ¼­¼úÀÚ·Î ½ÃÀÛÇÑ´Ù. °¢ event typeÀÌ ¾îµð¿¡ ÀÖ´Â link¿¡¼­ trace µÇ´ÂÁö º¸±â À§Çؼ­´Â "Network Component" section¿¡ ÀÖ´Â ±×¸² 9¸¦ º¸¶ó. flag(setµÈ flag°¡ ¾ø±â ¶§¹®¿¡ "------"·Î Ç¥½ÃµÇ´Â)¾Õ line¿¡ ÀÖ´Â ´ÙÀ½ Á¤º¸´Â Packet type°ú size(in Bytes)ÀÌ´Ù. ÇöÀç NS´Â Explicit Congestion Notification(ECN) bit¸¸ ±¸ÇöÇϸç, ³²Àº bits´Â »ç¿ëµÇÁö ¾Ê´Â´Ù. ´ÙÀ½ field´Â user°¡ ÀÔ·Â OTcl script¿¡¼­ °¢ flow¸¦ À§ÇØ setÇÒ ¼ö ÀÖ´Â IPv6ÀÇ flow id(fid)ÀÌ´Ù. ºñ·Ï fid field°¡ ½Ã¹Ä·¹ÀÌ¼Ç ³»¿¡¼­ »ç¿ëµÇÁö ¾Ê´Â´Ù ÇÏ´õ¶óµµ user´Â ºÐ¼®À» À§Çؼ­ ÀÌ field¸¦ »ç¿ëÇÒ ¼ö ÀÖ´Ù. fid field´Â NAM display¸¦ À§ÇØ stream color¸¦ ±ÔÁ¤ÇÒ ¶§µµ »ç¿ëµÉ ¼ö ÀÖ´Ù. ´ÙÀ½ µÎ °³ÀÇ field´Â "node.port"ÀÇ ÇüÅ·ΠµÈ source¿Í destination ÁÖ¼ÒÀÌ´Ù. ´ÙÀ½ field´Â network layer protocolÀÇ packet sequence number¸¦ º¸¿©ÁØ´Ù. ºñ·Ï UDP ±¸ÇöÀÌ sequence number¸¦ »ç¿ëÇÏÁö ¾Ê´Â´Ù ÇÏ´õ¶óµµ NS´Â ºÐ¼® ¸ñÀûÀ» À§ÇØ UDP packet sequence numberÀÇ trackÀ» À¯ÁöÇÑ´Ù. ¸¶Áö¸· field´Â packetÀÇ unique id¸¦ º¸¿©ÁØ´Ù.

simulation trace data¸¦ ¾ò¾úÀ¸¹Ç·Î, ¸ðµç »ç¶÷Àº °ü½ÉÀÖ´Â dataÀÇ subsetÀ» ÀÌÇØÇÒ ¼ö ÀÖ´Â Á¤º¸·Î º¯Çü½ÃŰ°í ±×°ÍÀ» ºÐ¼®ÇØ¾ß ÇÑ´Ù. ¾Æ·¡¿¡ ÀÖ´Â °ÍÀº ÀÛÀº data Àü¼ÛÀÇ ¿¹ÀÌ´Ù. ÀÌ ¿¹´Â ÁÖ¾îÁø ÀÔ·ÂÀÇ columnÀ» ¼±ÅÃÇÏ´Â "column"À¸·Î ºÒ¸®´Â perl¿¡¼­ ¾²¿©Áø ¸í·ÉÀ» »ç¿ëÇÑ´Ù. ´ç½ÅÀÇ machine¿¡¼­ µ¿ÀÛÇÏ´Â ¿¹¸¦ ¸¸µé±â À§Çؼ­, ´ç½ÅÀº "column"À» down¹Þ°í ±×°ÍÀ» ½ÇÇàÇÒ ¼ö ÀÖµµ·Ï ¸¸µé¶ó ("chmod 755 column "À» »ç¿ë). ´ÙÀ½Àº "out.tr"¿¡ ÀÖ´Â data¸¦ »ç¿ëÇÏ¿© ¼ö½Å node(n3)¿¡¼­ CBR traffic jitterÀ» °è»êÇϰí, "jitter.txt"¿¡¼­ °á°ú data¸¦ ÀúÀåÇÏ´Â awk·Î Á¶ÇÕµÈ tunneled shell ¸í·É¾îÀÌ´Ù.

Âü°í :


How to get things done with awk ?

Author: Sakari Mattila

Updated: 30-Mar-1999

Updated: 22-Jan-1996

awk is a pattern matching program. It takes two inputs: data file and command file. The data file contains text, that is lines containing words. Data file need not be usual text, any data composed of character groups (words) and lines is suitable. Default character group separator is space, but other separators may be defined on awk starting command line. More on awk starting command is at the end of this document. The command file contains pattern matching instructions, it is equal to ordinary computer program. Feel free to thing awk as an interpreter executing commands from the command file on the data file.

awk comes with all Unix and Linux operating systems. It is a command line utility. awk is also included in several Unix-like utilities packages for MS Windows 95/98, MS Windows NT and other operating systems. Cygwin http://sourceware.cygnus.com/cygwin in one source of these packages. awk source code in C is available with full Linux packages and GNU packages.

awk can be used to extract parts from a large text body.





cat out.tr | grep " 2 3 cbr " | grep ^r | column 1 10 | awk '{dif = $2 - old2; if(dif==0) dif = 1; if(dif > 0) {printf("%d\t%f\n", $2, ($1 - old1) / dif); old1 = $1; old2 = $2}}' > jitter.txt

ÀÌ shell ¸í·ÉÀº n3¿¡¼­ "CBR packet receive" event¸¦ ¼±ÅÃÇϰí, time(column 1)°ú sequence number (column 10)À» ¼±ÅÃÇϰí, ¸¶Áö¸· packet ¼ö½Å½Ã°£°ú °¢ sequence number¿¡ ´ëÇÑ sequence number(loss packet¿¡ ´ëÇÑ)¿¡¼­ÀÇ Â÷ÀÌ·Î ³ª´« Â÷À̸¦ °è»êÇÑ´Ù. ´ÙÀ½Àº gnuplot¸¦ »ç¿ëÇÏ¿© »ý¼ºµÈ jitter graphÀÌ´Ù. XÃàÀº packet sequence numberÀ̸ç, YÃàÀº ÃÊ´ç simulation ½Ã°£ÀÌ´Ù.

Âü°í :

The gnuplot program for plotting 2D and 3D graphs

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

SHAZAM provides an interface to GNUPLOT. This is described in the PLOTS AND GRAPHS chapter in the SHAZAM User's Reference Manual. SHAZAM will produce a simple gnuplot command file. You can then customize the command file with many of the gnuplot features that are available.

Gnuplot web site

For downloading gnuplot, a number of file options are given at the gnuplot download page. The following files are recommended for use with SHAZAM.


gnuplot name required by SHAZAM

gnuplot file download

Windows SHAZAM

wgnuplot.exe

gp371cyg.zip

SHAZAMD

MSDOS command prompt

gnuplot.exe

gp371dyg.zip




fig 14. CBR Jitter at The Receiving Node(n3)
 

º¸´Ù ¸¹Àº utility¸¦ º¸±â À§Çؼ­ http://perform.wpi.edu/NS/utilities¸¦ Á¡°ËÇØ º¸¶ó.

ÀÌ sectionÀº NS¿¡¼­ trace¸¦ »ý¼ºÇÏ°í ±×°ÍÀ» interpretÇϸç, trace·ÎºÎÅÍ À¯¿ëÇÑ Á¤º¸¸¦ ¾ò´Â ¹æ¹ýÀÇ ¿¹¸¦ º¸¿© ÁÖ¾ú´Ù. ÀÌ ¿¹¿¡¼­, post simulation process´Â ½Ã¹Ä·¹ÀÌ¼Ç ÈÄ¿¡ shell prompt¿¡¼­ ÇàÇØÁø´Ù. ±×·¯³ª, ÀÌ process´Â input OTcl script¿¡ Æ÷Ç﵃ ¼ö ÀÖ´Ù. ±×°ÍÀº ´ÙÀ½ section¿¡¼­ º¸¿©ÁØ´Ù.

 

 

 


 

3.2 RED Queue Monitor Example

ÀÌ sectionÀº RED queue monitoring ¿¹Á¦¸¦ º¸¿©ÁØ´Ù. ¿¹Á¦5´Â Polly Huang¿¡ ÀÇÇØ ¾²¿©Áø OTcl scriptÀ̸ç, ±×°ÍÀº network topology¸¦ setupÇÏ°í ±×¸²15.¿¡ ³ªÅ¸³­ ½Ã¹Ä·¹ÀÌ¼Ç ½Ã³ª¸®¿À¸¦ µ¿ÀÛÇÑ´Ù.

25 packet±îÁö hold up ÇÒ ¼ö ÀÖ´Â RED queue°¡ link r1-r2¿¡ »ç¿ëµÇ¾úÀ¸¸ç, ¿ì¸®´Â current¿Í average queue sizeÀÇ dynamics¸¦ ÃøÁ¤ÇÔÀ¸·Î½á RED queue°¡ ¾î¶»°Ô µ¿ÀÛÇÏ´ÂÁö º¸±â¸¦ ¿øÇÑ´Ù´Â °ÍÀ» ÁÖ¸ñÇ϶ó. ÀÌ script¸¦ µ¿ÀÛ½Ã۱â À§Çؼ­, "red.tcl"À» ´Ù¿î¹Þ°í "ns red.tcl"À» ÀÔ·ÂÇ϶ó.



fig 15. RED Monitor Example Setup



 



Example 5. RED Queue Monitor Simulation Script

# Polly Huang 8-7-98

set ns [new Simulator]

#

# Create a simple six node topology:

#

# s1 s3

# \ /

# 10Mb,2ms \ 1.5Mb,20ms / 10Mb,4ms

# r1 --------- r2

# 10Mb,3ms / \ 10Mb,5ms

# / \

# s2 s4

#

set node_(s1) [$ns node]

set node_(s2) [$ns node]

set node_(r1) [$ns node]

set node_(r2) [$ns node]

set node_(s3) [$ns node]

set node_(s4) [$ns node]

$ns duplex-link $node_(s1) $node_(r1) 10Mb 2ms DropTail

$ns duplex-link $node_(s2) $node_(r1) 10Mb 3ms DropTail

$ns duplex-link $node_(r1) $node_(r2) 1.5Mb 20ms RED

$ns queue-limit $node_(r1) $node_(r2) 25

$ns queue-limit $node_(r2) $node_(r1) 25

$ns duplex-link $node_(s3) $node_(r2) 10Mb 4ms DropTail

$ns duplex-link $node_(s4) $node_(r2) 10Mb 5ms DropTail

$ns duplex-link-op $node_(s1) $node_(r1) orient right-down

$ns duplex-link-op $node_(s2) $node_(r1) orient right-up

$ns duplex-link-op $node_(r1) $node_(r2) orient right

$ns duplex-link-op $node_(r1) $node_(r2) queuePos 0

$ns duplex-link-op $node_(r2) $node_(r1) queuePos 0

$ns duplex-link-op $node_(s3) $node_(r2) orient left-down

$ns duplex-link-op $node_(s4) $node_(r2) orient left-up

set tcp1 [$ns create-connection TCP/Reno $node_(s1) TCPSink $node_(s3) 0]

$tcp1 set window_ 15

set tcp2 [$ns create-connection TCP/Reno $node_(s2) TCPSink $node_(s3) 1]

$tcp2 set window_ 15

set ftp1 [$tcp1 attach-source FTP]

set ftp2 [$tcp2 attach-source FTP]

# Tracing a queue

set redq [[$ns link $node_(r1) $node_(r2)] queue]

set tchan_ [open all.q w]

$redq trace curq_

$redq trace ave_

$redq attach $tchan_

$ns at 0.0 "$ftp1 start"

$ns at 3.0 "$ftp2 start"

$ns at 10 "finish"

# Define 'finish' procedure (include post-simulation processes)

proc finish {} {

global tchan_

set awkCode {

{

if ($1 == "Q" && NF>2) {

print $2, $3 >> "temp.q";

set end $2

}

else if ($1 == "a" && NF>2)

print $2, $3 >> "temp.a";

}

}

set f [open temp.queue w]

puts $f "TitleText: red"

puts $f "Device: Postscript"

if { [info exists tchan_] } {

close $tchan_

}

exec rm -f temp.q temp.a

exec touch temp.a temp.q

exec awk $awkCode all.q

puts $f \"queue

exec cat temp.q >@ $f

puts $f \n\"ave_queue

exec cat temp.a >@ $f

close $f

exec xgraph -bb -tk -x time -y queue temp.queue &

exit 0

}

$ns run



À§ script¿¡¼­ ÁÖ¸ñÇÒ ¸¸ÇÑ °ÍÀÌ µÎ °÷ÀÌ ÀÖ´Ù. ù°, º¸´Ù Áøº¸µÈ Simulator member ÇÔ¼ö create-connectionÀÌ TCP ¿¬°áÀ» »ý¼ºÇϱâ À§ÇØ »ç¿ëµÇ¾ú´Ù. µÑ°, scriptÀÇ queue tracing(monitoring) part¿¡¼­ ¸ÚÁø ¸ð½ÀÀ» º¸¶ó. ÀÌ ¶óÀεéÀº RED queue object¸¦ °¡¸®Å°´Â º¯¼ö¸¦ ¸¸µé°í ÇöÀç queue size(curq_)¿Í Æò±Õ queue size(avg_)¸¦ monitorÇϱâ À§Çؼ­ ±×°ÍÀÇ member ÇÔ¼ö trace¸¦ È£ÃâÇÑ´Ù. ±×¸®°í ±×°ÍµéÀÌ °á°ú¸¦ "all.q" file¿¡ ¾²µµ·Ï ÇÑ´Ù. ´ÙÀ½Àº Æò±Õ queue size¿Í ÇöÀç queue size¿¡ ´ëÇÑ µÎ °³ÀÇ queue trace Ãâ·Â formatµéÀÌ´Ù.

a time avg_q_size

Q time crnt_q_size

Áö±Ý RED queue monitoringÀ» À§ÇØ ÇÊ¿äÇÑ ¸ðµç ¸í·É¾îµéÀº ½Ã¹Ä·¹À̼ÇÀÌ ÇàÇØÁú ¶§ "all.q" fileÀ» ´Ý´Â °ÍÀ» Á¦¿ÜÇϰí ÇàÇØÁø´Ù. ³²Àº ÀÛ¾÷Àº post-simulation process¸¦ ¼³°èÇÑ´Ù. awk¸¦ »ç¿ëÇÏ´Â ÀÌ script´Â XGraph(a plotter) ÀÔ·Â format ¼ÓÀ¸·Î monitored informationÀ» Àü¼ÛÇÏ´Â process¸¦ ¼öÇàÇÑ´Ù. ±×¸®°í ÁÖ¾îÁø Á¤º¸(see ±×¸²16)¸¦ ±×¸®±â À§ÇØ ±×°ÍÀ» ³»º¸³½´Ù.








fig 16. RED Queue Trace Graph

 

 

Trace Analysis Utilities

¿©±â¿¡ À¯¿ëÇÑ trace ºÐ¼® utilityÀÇ ¸ðÀ½ÀÌ ÀÖ´Ù. :

¡Û ¸¸ÀÏ columnÀ» ÃßÃâÇÒ ¼ö ÀÖ´Ù¸é ¸¹Àº ¹®ÀåÀÇ ºÐ¼®ÀÌ ½±°ÔµÈ´Ù. ¿©±â¿¡ whitespace¿¡ ÀÇÇØ ºÐ¸®µÈ column ¼ÓÀ¸·Î text Ãâ·ÂÀ» ºÐ¼®ÇÏ´Â "column"À¸·Î ºÒ¸®´Â helper-perl utility°¡ ÀÖ´Ù.

 

column

#!/usr/bin/perl

# Mark Claypool

# Last significantly modified: April 27, 1994

# This program prints out fields of an indicated column.

# The columns are numbered 1, 2, 3 ...

&ParseCommandLine;

$line = <STDIN>;

while ($line) {

$line =~ s/^\s+//; # remove initial white-space

$line =~ s/\s+/ /g; # turn double-space into single space

@word = split('\s+',$line); # columns will then be $1, $2, $3 ...

$i =0;#

while ($i <= $#col) {

print "@word[@col[$i]]\t";

$i += 1;

}

print "\n";

$line = <STDIN>;

}

exit;

 

#######################################################################

# ParseCommandLine

# check for the right number of command line arguments

# print usage message and quit if there is an error

# global variables are @col

sub ParseCommandLine

{

while ($#ARGV >= 0) {

$arg = shift(@ARGV);

if ($arg =~ /^(\d+)/) {

push(@col, $1);

} else {

&usage;

}

}

if ($#col < 0) {

&usage;

}

}

##########################################################################

# usage

# print a usage maessage and quit

sub usage

{

print STDERR "column: print fields from an indicated column\n";

print STDERR "Usage: column <flags>, where flags are:\n";

print STDERR " {# [#...]}\tcolumn(s) to print, numbered 0,1,2...\n";

exit;

}


 


±×°ÍÀº ¾Æ·¡ÀÇ ¸¹Àº script¿¡ ÀÇÇØ »ç¿ëµÈ´Ù.

¡Û ¿©±â¿¡ Ãâ·Â file stats.trÀÇ bottleneck link(ÀÌ °æ¿ì¿¡´Â node1¿¡¼­ node2)¸¦ µû¶ó¼­ ¾î¶² »óŸ¦ Ãâ·ÂÇÏ´Â stat.pl script¶ó ºÒ¸®´Â °£´ÜÇÑ perlÀÌ ÀÖ´Ù.

´ÙÀ½ÀÇ ¸í·É¾î·Î ±×°ÍÀ» µ¿ÀÛÇ϶ó.: stats.pl -l1 1 -l2 2 -max 1.5 stats.tr

¡Û ¿©±â¿¡ awk·Î Á¶ÇÕµÈ jitter.sh·Î ºÒ¸®´Â tunneled shell ¸í·ÉÀÌ ÀÖ´Ù. ±×°ÍÀº "out.tr"¿¡ ÀÖ´Â data¸¦ »ç¿ëÇÏ´Â ¼ö½Å node(n3)¿¡¼­ CBR traffic jitter¸¦ °è»êÇÑ´Ù. ±×¸®°í, "jitter.txt"¿¡ °á°ú data¸¦ ÀúÀåÇÑ´Ù. ÀÌ shell ¸í·ÉÀº n3¿¡¼­ "CBR packet receive" event¸¦ ¼±ÅÃÇϰí, time(column 1)°ú sequence number (column 10)À» ¼±ÅÃÇϰí, ¸¶Áö¸· packet ¼ö½Å½Ã°£°ú °¢ sequence number¿¡ ´ëÇÑ sequence number(loss packet¿¡ ´ëÇÑ)¿¡¼­ÀÇ Â÷ÀÌ·Î ³ª´« Â÷À̸¦ °è»êÇÑ´Ù.

 

 

 

 

4. Extending NS


4.1 Where to Find What ?

NS¸¦ ¾î¶»°Ô È®ÀåÇϴ°¡ ÇÏ´Â ³íÀÇ¿¡ µé¾î°¡±â Àü¿¡, ¹«½¼ Á¤º¸°¡ ¾î¶² µð·ºÅ丮³ª file¿¡ ÀúÀåµÇ´Â°¡ ÇÏ´Â °ÍÀ» °£·«ÇÏ°Ô ½ÃÇèÇØ º¸µµ·Ï ÇÏÀÚ. ±×¸² 17Àº ns-allinone-2.1b package¸¦ »ç¿ëÇÏ¿© install ÇßÀ» ¶§ÀÇ ½Ã¹Ä·¹ÀÌÅÍ µð·ºÅ丮 ±¸Á¶ÀÇ ÀϺκÐÀ» º¸¿©ÁØ´Ù.



fig 17. NS Directory Structure

 

ns-allinone-2.1bÀÇ sub-directory °¡¿îµ¥, ns-2´Â ¸ðµç ½Ã¹Ä·¹ÀÌÅÍÀÇ ±¸ÇöÀ»(OTcl¿¡¼­ ȤÀº C++¿¡¼­) Áï, validation test OTcl script¿Í example OTcl script¸¦ °¡Áö°í ÀÖ´Â Àå¼ÒÀÌ´Ù. ÀÌ µð·ºÅ丮 ³»ºÎ¿¡ ÀÖ´Â ¸ðµç OTcl code¿Í test/example scriptµéÀº sub-directory tcl ¹Ø¿¡ À§Ä¡ÇØ ÀÖ´Ù. ±×¸®°í WWW¿Í °ü·ÃµÈ °ÍÀ» Á¦¿ÜÇϰí, event scheduler¿Í basic network component object class¸¦ ±¸ÇöÇÏ´Â C++ code ´ëºÎºÐÀº main level¿¡ À§Ä¡ÇØ ÀÖ´Ù. ¿¹¸¦ µé¾î, ´ç½ÅÀÌ UDP agentÀÇ ±¸ÇöÀ» º¸±â ¿øÇÑ´Ù¸é, ´ç½ÅÀº "ns-allinone-2.1b/ns-2" µð·ºÅ丮·Î °¡¼­ "udp.h", "udp.cc"¿Í ÇÊ¿äÇÑ UDPÀÇ ¼±Á¶ calssÀÇ ±¸ÇöÀ» Æ÷ÇÔÇÏ´Â fileÀ» open ÇØ¾ßÇÑ´Ù. ³×Æ®¿öÅ© ±¸¼º¿ä¼ÒµéÀÇ class °èÃþ ±¸Á¶¿¡ ´ëÇØ¼­´Â "Network Components" section¿¡ ÀÖ´Â Figure 6.À» Âü°íÇ϶ó. ¾ÕÀ¸·Î´Â ´ç½ÅÀÌ ÀÌ¹Ì "ns-allinone-2.1b" µð·ºÅ丮¿¡ ÀÖ´Â °ÍÀ¸·Î °¡Á¤ÇÑ´Ù.

°¡Àå ±âº»ÀûÀ̸ç NS ±¸Çö(agent, node, link, packet, address, routing, and etc.)ÀÇ °¡Àå ÇÊ¿äÇÑ ºÎºÐÀ» À§ÇÑ OTcl source code¸¦ Æ÷ÇÔÇÏ´Â lib µð·ºÅ丮µé °¡¿îµ¥¼­ sub-directory¸¦ °¡Áö°í ÀÖ´Â tcl µð·ºÅ丮´Â user·Î¼­ ¶Ç´Â developer·Î¼­ °¡Àå ºó¹øÈ÷ ¹æ¹®ÇÏ°Ô µÇ´Â °÷ÀÌ´Ù. LAN, Web, Multicast ±¸Çö¿¡ ´ëÇÑ OTcl source code´Â tclÀÇ ºÐ¸®µÈ subdirectory ³»¿¡ À§Ä¡Çϰí ÀÖ´Ù´Â °ÍÀ» ÁÖ¸ñÇ϶ó.

´ÙÀ½Àº "ns-2/tcl/lib" µð·ºÅ丮¿¡ ÀÖ´Â fileÀÇ ºÎºÐÀûÀÎ listÀÌ´Ù.

 

¡Û ns-lib.tcl:

simulator class¿Í ±×°ÍÀÇ member ÇÔ¼ö Á¤ÀÇÀÇ ´ëºÎºÐ(LAN, Web, Multicast¿Í °ü°èµÈ °ÍµéÀ» Á¦¿ÜÇϰí)ÀÌ ¿©±â¿¡ À§Ä¡ÇØ ÀÖ´Ù. ¸¸ÀÏ, ´ç½ÅÀÌ simulator object classÀÇ member ÇÔ¼ö°¡ À¯¿ëÇÑÁö ±×¸®°í ±×°ÍµéÀÌ ¾î¶»°Ô µ¿ÀÛÇÏ´ÂÁö¸¦ ¾Ë±â ¿øÇÑ´Ù¸é, ÀÌ °÷À» º¸¸é µÈ´Ù.

 

¡Û ns-default.tcl:

´Ù¾çÇÑ network ±¸¼º¿ä¼ÒµéÀ» À§ÇÑ ±¸¼º °¡´ÉÇÑ parameter¿¡ ´ëÇÑ default °ªµéÀÌ ¿©±â¿¡ ÀÖ´Ù. network ±¸¼º¿ä¼ÒÀÇ ´ëºÎºÐÀÌ C++·Î ±¸ÇöµÇ¾ú±â ¶§¹®¿¡, ±¸¼º °¡´ÉÇÑ parameterµéÀº OTcl linkage ÇÔ¼öÀÎ bind(C++_variable_name, OTcl_variable_name)¸¦ °æÀ¯ÇÏ¿© OTcl¿¡ À¯¿ëÇÏ°Ô ¸¸µé¾îÁø ½ÇÁ¦ÀûÀÎ C++ º¯¼öµéÀÌ´Ù. C++ code·ÎºÎÅÍ OTcl linkage¸¦ ¾î¶»°Ô ¸¸µé °ÍÀΰ¡ ÇÏ´Â °ÍÀº ´ÙÀ½ section¿¡¼­ ±â¼úµÈ´Ù.

 

¡Û ns-packet.tcl:

packet header format initialization implementationÀÌ ¿©±â¿¡ À§Ä¡ÇØ ÀÖ´Ù. ´ç½ÅÀÌ »õ·Î¿î packet header¸¦ »ý¼ºÇÒ ¶§, ´ç½ÅÀº header stack format ¼ÓÀ¸·Î ´ç½ÅÀÇ header¸¦ Æ÷ÇÔ½Ã۰í, stack¿¡ ÀÖ´Â ´ç½ÅÀÇ headerÀÇ offset¸¦ ´ç½Å¿¡°Ô ÁÖ±â À§ÇÑ packet header initialization process¸¦ ¸¸µé±â À§Çؼ­ ÀÌ file³»¿¡ header¸¦ µî·ÏÇØ¾ß ÇÑ´Ù. »õ·Î¿î header »ý¼º ¿¹Á¦´Â "Add New Application and Agent" section¿¡¼­ º¸¿©ÁØ´Ù.

 

¡Û other OTcl files:

ÀÌ µð·ºÅ丮¿¡ ÀÖ´Â ´Ù¸¥ OTcl fileµéÀº network object¸¦ Á¶ÇÕÇÑ OTcl ±¸ÇöÀ̳ª, C++¿¡ ÀÖ´Â networkÀÇ front end(control part)¸¦ Æ÷ÇÔÇÑ´Ù. FTPÀÀ¿ëÀº OTcl¿¡¼­ ¿Ïº®ÇÏ°Ô ±¸ÇöµÇ¾î ÀÖ´Ù. ±×¸®°í source code´Â "ns-source.tcl"¿¡ À§Ä¡ÇØ ÀÖ´Ù.

Ưº°ÇÑ ½Ã¹Ä·¹À̼ÇÀÇ ¼³°è¸¦ ¾î¶»°Ô ÇÏ´ÂÁö ¾Ë±â¸¦ ¿øÇÏ´Â user¿¡°Ô Èï¹ÌÀÖ´Â tclÀÇ µÎ °³ÀÇ sub-directories´Â ex¿Í testÀÌ´Ù. ex µð·ºÅ丮´Â ´Ù¾çÇÑ ¿¹Á¦ ½Ã¹Ä·¹ÀÌ¼Ç script¸¦ Æ÷ÇÔÇϰí ÀÖÀ¸¸ç, test µð·ºÅ丮´Â ´Ù¾çÇÑ ½Ã¹Ä·¹À̼ÇÀ» µ¿ÀÛ½ÃŰ°í ¿¹»óµÈ °á°ú¿Í ±× °á°ú¸¦ ºñ±³ÇÔÀ¸·Î½á ´ç½ÅÀÇ ÄÄÇ»ÅÍ¿¡ ÀνºÅçµÇ¾î ÀÖ´Â NSÀÇ À¯È¿¼ºÀ» ½ÃÇèÇÏ´Â ½Ã¹Ä·¹ÀÌ¼Ç script¸¦ Æ÷ÇÔÇÑ´Ù.
































4.2 OTcl Linkage

º¸Åë »õ·Î¿î ±âº»ÀûÀÎ network object¸¦ Ãß°¡ÇÔÀ¸·Î½á NS¸¦ È®Àå½ÃŰ´Â °ÍÀº C++ code·ÎºÎÅÍ OTcl linkage¸¦ ¸¸µå´Â ÀϵéÀ» Æ÷ÇÔÇÑ´Ù. µû¶ó¼­, data °æ·Î¿¡ ÀÖ´Â object class´Â È¿À²¼º ÀÌÀ¯·Î ÀÎÇØ C++·Î ¾²¿©Á®¾ß ÇÑ´Ù. ÀÌ sectionÀº ¾î¶² agent µ¿ÀÛµµ ÇÏÁö ¾Ê´Â(packetÀÇ »ý¼º°ú Àü¼ÛÀÌ ¾ø´Â) "MyAgent"¶ó ºÒ¸®´Â °£´ÜÇÏ°í µÐÇÑ(dull) agent¸¦ »ý¼ºÇÏ´Â ¿¹Á¦¸¦ ÁÜÀ¸·Î½á NS¿¡¼­ °¡¿ëÇÑ C++/OTcl linkageµéÀ» ¼Ò°³ÇÑ´Ù. ±×¸² 18~21Àº ÇÔ²² ¿Ïº®ÇÑ ±¸Çö(3 extra header lineÀ» °¡Áö°í)À» ¸¸µå´Â "MyAgent"¿¡ ´ëÇÑ C++ source fileÀÇ ÀϺθ¦ º¸¿©ÁØ´Ù. ¶ÇÇÑ, ´ç½ÅÀÌ "MyAgent"¸¦ ½ÃÇèÇÒ ¼ö ÀÖ´Â OTcl script´Â ÀÌ sectionÀÇ ¸»¹Ì¿¡ Ç¥½ÃµÇ¾î ÀÖ´Ù.

Export C++ class to OTcl

´ç½ÅÀÌ "Agent" class·ÎºÎÅÍ À¯µµµÈ "MyAgent"¶ó ºÎ¸£´Â C++ class¿¡¼­ »õ·Î¿î network class¸¦ »ý¼ºÇϰí, OTcl¿¡ ÀÖ´Â ÀÌ objectÀÇ instance¸¦ »ý¼ºÇÏ´Â °ÍÀÌ °¡´ÉÇϵµ·Ï Çϱ⸦ ¿øÇÑ´Ù°í °¡Á¤ÇÑ´Ù. À̰ÍÀ» Çϱâ À§Çؼ­ ´ç½ÅÀº "TclClass"·ÎºÎÅÍ À¯µµµÇ¾î¾ß ÇÏ´Â "MyAgentClass"¶ó ºÎ¸£´Â linkage object¸¦ Á¤ÀÇÇØ¾ß ÇÑ´Ù. ÀÌ linkage object´Â ±ÔÁ¤µÈ À̸§(ÀÌ ¿¹Á¦¿¡¼­´Â "Agent/MyAgentOtcl")ÀÇ OTcl object¸¦ »ý¼ºÇÑ´Ù. ±×¸®°í OTcl object¿Í C++ object»çÀÌ¿¡ linkage¸¦ »ý¼ºÇÑ´Ù. ±×°ÍÀÇ instance launching procedure´Â "create" member ÇÔ¼ö¿¡¼­ ±ÔÁ¤µÇ¾î ÀÖ´Ù. ±×¸² 18.Àº "MyAgent" class Á¤ÀÇ¿Í linkage class Á¤ÀǸ¦ º¸¿©ÁØ´Ù.

 


class MyAgent : public Agent {

public:

MyAgent();

protected:

int command(int argc, const char*const* argv);

private:

int my_var1;

double my_var2;

void MyPrivFunc (void);

};

 

static class MyAgentClass : public TclClass {

public:

MyAgentClass () : TclClass("Agent/MyAgentotcl") {}

TclObject* create(int, const char*const*) {

return(new MyAgent());

}

} class_my_agent;


fig 18. Example C++ Network Component and The Linkage Object

 


NS°¡ óÀ½ ½ÃÀÛµÉ ¶§, ±×°ÍÀº static variable "class_my_agent"¿¡ ´ëÇÑ constructor ÀÓ¹«¸¦ ¼öÇàÇÑ´Ù. ±×·¡¼­ "MyAgentClass"ÀÇ instance°¡ »ý¼ºµÈ´Ù. ¸® process¿¡¼­, "Agent/MyAgentOtcl" class¿Í ±×°ÍÀÇ ÀûÁ¤ÇÑ method(member functions)´Â OTcl space¿¡¼­ »ý¼ºµÈ´Ù. OTcl space¿¡ ÀÖ´Â user°¡ "new Agent/MyAgentOtcl" ¸í·É¾î¸¦ ÀÌ¿ëÇÏ¿© ÀÌ objectÀÇ instance¸¦ »ý¼ºÇÏ·Á°í ÇÒ ¶§, ±×°ÍÀº "MyAgent"ÀÇ instance¸¦ »ý¼ºÇÏ´Â "MyAgentClass::create"¸¦ ºÎ¸¥´Ù. ±×¸®°í ±× address¸¦ µÇµ¹¸°´Ù. OTcl·ÎºÎÅÍ C++ object instance¸¦ »ý¼ºÇÏ´Â °ÍÀº ´ç½ÅÀÌ member ÇÔ¼ö¸¦ ºÎ¸£°í (invoke), OTcl·ÎºÎÅÍ C++ object instanceÀÇ member º¯¼ö¸¦ accessÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ÀǹÌÇÏ´Â °ÍÀº ¾Æ´Ï¶ó´Â Á¡¿¡ ÁÖ¸ñÇ϶ó.

Export C++ class variables to OTcl

´ç½ÅÀÇ »õ·Î¿î C++ objectÀÎ "MyAgent"´Â ´ç½ÅÀÌ input simulation script¸¦ »ç¿ëÇÏ¿© OTcl·ÎºÎÅÍ ½±°Ô ±¸¼º(ȤÀº º¯È­)Çϱ⸦ ¿øÇÏ´Â "my_var1"°ú "my_var2"·Î ºÒ¸®´Â µÎ °³ÀÇ parameter º¯¼ö¸¦ °¡Á³´Ù°í °¡Á¤ÇÏÀÚ. À̰ÍÀ» Çϱâ À§Çؼ­ ´ç½ÅÀº exportÇϱ⸦ ¿øÇÏ´Â °¢ C++ class º¯¼ö¿¡ ´ëÇÑ binding ÇÔ¼ö¸¦ »ç¿ëÇØ¾ß¸¸ ÇÑ´Ù. binding ÇÔ¼ö´Â matchingµÇ´Â OTcl object class("Agent/MyAgentOtcl")¿¡¼­ ÁÖ¾îÁø À̸§(first argument)ÀÇ »õ·Î¿î member º¯¼ö¸¦ »ý¼ºÇÑ´Ù. ±×¸®°í, OTcl class º¯¼ö¿Í address°¡ µÎ ¹øÂ° º¯¼ö·Î ±ÔÁ¤µÈ C++ º¯¼ö »çÀÌ¿¡¼­ bi-directional bindings¸¦ »ý¼ºÇÑ´Ù, ±×¸²19´Â ±×¸² 18¿¡¼­ º¸¿©Áø "my_var1"°ú "my_var2"¿¡ ´ëÇÑ bindingÀ» ¸¸µå´Â ¹æ¹ýÀ» º¸¿©ÁØ´Ù.

 

±×¸² 19. Variable Binding Creation Example

MyAgent::MyAgent() : Agent(PT_UDP) {

bind("my_var1_otcl", &my_var1);

bind("my_var2_otcl", &my_var2);

}

 

binding ÇÔ¼ö´Â ÀÌ objectÀÇ instance°¡ »ý¼ºµÉ ¶§ bindingÀ» ¸¸µé±â À§Çؼ­ "MyAgent" constructor ÇÔ¼ö¿¡ ³õÀÌ°Ô µÈ´Ù. NS´Â ´ÙÀ½°ú °°ÀÌ 5°³ÀÇ ´Ù¸¥ º¯¼ö type¿¡ ´ëÇØ 4°³ÀÇ ´Ù¸¥ binding ÇÔ¼ö¸¦ Àç°øÇÑ´Ù.

- bind() : real or integer variables

- bind_time() : time variable

- bind_bw() : bandwidth variable

- bind_bool() : boolean variable

ÀÌ ¹æ¹ý¿¡¼­, OTcl script¸¦ »ç¿ëÇÏ¿© ½Ã¹Ä·¹À̼ÇÀ» ¼³°èÇÏ°í µ¿ÀÛ½ÃŰ´Â user´Â C++·Î ±¸ÇöµÈ network componentsÀÇ configurable parameter(ȤÀº variable values)¸¦ º¯°æÇϰųª accessÇÒ ¼ö ÀÖ´Ù. ´ç½ÅÀÌ C++ º¯¼ö¸¦ exportÇÒ ¶§¸¶´Ù, ´ç½ÅÀÌ "ns-2/tcl/lib/ns-lib.tcl" file¿¡ ÀÖ´Â º¯¼ö¿¡ ´ëÇÑ default °ªÀ» set ÇÏ´Â °ÍÀ» ±Ç°íÇÑ´Ù. ¹Ý¸é, ´ç½ÅÀº »õ·Î¿î objectÀÇ instance¸¦ »ý¼ºÇÒ ¶§ °æ°í ¸Þ½ÃÁö¸¦ º¸°ÔµÉ °ÍÀÌ´Ù.

Export C++ Object COntrol Command to OTcl

¾à°£ÀÇ C++ object º¯¼ö¸¦ exportÇÏ´Â °Í¿¡ ºÎ°¡ÇÏ¿©, OTcl¿¡ C++ objectÀÇ controlÀ» Áֱ⸦ ¿øÇÒÁöµµ ¸ð¸¥´Ù. À̰ÍÀº OTcl ¸í·É ÀÎÅÍÇÁ¸®ÅÍ·Î µ¿ÀÛÇÏ´Â C++ object("MyAgent")ÀÇ "command" member ÇÔ¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î½á ÇàÇØÁø´Ù. »ç½Ç»ó, C++ objectÀÇ "command" member ÇÔ¼ö¿¡¼­ Á¤ÀÇµÈ OTcl ÇÔ¼ö´Â user¿¡°Ô matching OTcl objectÀÇ member ÇÔ¼ö¿Í µ¿ÀÏÇÏ°Ô º¸ÀδÙ. ±×¸²20Àº ±×¸²18¿¡ ÀÖ´Â 'MyAgent"¿¡ ´ëÇÑ "command" member ÇÔ¼ö Á¤ÀÇ¿¹Á¦¸¦ º¸¿©ÁØ´Ù.

 

±×¸² 20. Example OTcl command interpreter

int MyAgent::command(int argc, const char*const* argv) {

if(argc ==2) {

if(strcmp(argv[1], "call-my-priv-func") == 0) {

MyPrivFunc();

return(TCL_OK);

}

}

return(Agent::command(argc, argv));

}



"MyAgent" object¿Í Á¤ÇյǴ shadow OTclÀÇ instance°¡ OTcl space(set myagent [new Agent/MyAgentOtcl] µî)¿¡¼­ »ý¼ºµÉ ¶§, ±×¸®°í user°¡ objectÀÇ member ÇÔ¼ö¸¦ È£Ãâ( $myagent call-my-priv-func µî)ÇÏ·Á°í ÇÒ ¶§, OTclÀº OTcl object¿¡¼­ ÁÖ¾îÁø member ÇÔ¼ö À̸§À» ã´Â´Ù. ¸¸ÀÏ ÁÖ¾îÁø member ÇÔ¼ö À̸§°ú argc/argv format¿¡ ÀÖ´Â Àμö°¡ ¹ß°ßµÇÁö ¾ÊÀ» ¶§, È£ÃâµÈ OTcl member ÇÔ¼ö¸¦ passingÇÏ´Â "MyAgent::command"¸¦ ¿äû(invoke)ÇÑ´Ù. ¸¸ÀÏ "command" member ÇÔ¼ö ³»¿¡ invokeµÈ OTcl member ÇÔ¼ö À̸§¿¡ ´ëÇÑ Á¤ÀÇÇÑ actionÀÌ ÀÖ´Ù¸é, ±×°ÍÀº Áú¹®µÈ ³»¿ëÀ» ¼öÇàÇÏ°í ±× °á°ú¸¦ µÇµ¹¸°´Ù. ¸¸ÀÏ ±×·¸Áö ¾Ê´Ù¸é, ±×°ÍÀÇ Á¶»ó(ancestor) object¿¡ ´ëÇÑ "command" ÇÔ¼ö´Â ±× À̸§ÀÌ Ã£¾ÆÁú ¶§±îÁö ¹Ýº¹ÀûÀ¸·Î È£ÃâÇÒ °ÍÀÌ´Ù. ¸¸ÀÏ ±× À̸§ÀÌ Á¶»ó(ancestor)Áß¿¡ ¾î´À °÷¿¡¼­µµ ¹ß°ßµÇÁö ¾Ê´Â´Ù¸é, error message°¡ OTcl object·Î µÇµ¹¾Æ ¿Â´Ù. ±×¸®°í OTcl object´Â user¿¡°Ô error message¸¦ ÁØ´Ù. ÀÌ·¯ÇÑ ¹æ¹ýÀ¸·Î OTcl space¿¡ ÀÖ´Â user´Â C++ objectÀÇ µ¿ÀÛÀ» Á¦¾îÇÒ ¼ö ÀÖ´Ù.

Execute an OTcl command from C++

´ç½ÅÀº C++¿¡ ÀÖ´Â »õ·Î¿î network object¸¦ ±¸ÇöÇÔÀ¸·Î½á, C++ object·ÎºÎÅÍ OTcl command¸¦ ½ÇÇàÇϱ⸦ ¿øÇÒ °ÍÀÌ´Ù. ±×¸² 21Àº ±×¸² 18¿¡ ÀÖ´Â "MtAgent"ÀÇ member ÇÔ¼öÀÎ "MyPrivFunc"ÀÇ ±¸ÇöÀ» º¸¿©ÁØ´Ù. ±×°ÍÀº OTcl interpreter°¡ "my_var1"°ú "my_var2" private member º¯¼ö¿¡ ÀÖ´Â °ªÀ» ÇÁ¸°Æ®ÇÏ´Â °ÍÀ» ¸¸µç´Ù.

 

±×¸² 21. Example OTcl command from a C++ Object

void MyAgent::MyPrivFunc(void) {

Tcl& tcl = Tcl::instance();

tcl.eval("puts \"Message From MyPrivFunc\" ");

tcl.evalf("puts \" my_var1 = %d\" ", my_var1);

tcl.evalf("puts \" my_var2 = %d\" ", my_var2);

}


C++·ÎºÎÅÍ OTcl command¸¦ ½ÇÇà½Ã۱â À§Çؼ­, ´ç½ÅÀº static member ÇÔ¼ö·Î ¼±¾ðµÈ "Tcl:;instance()"¿¡ ´ëÇÑ reference¸¦ ÃëÇØ¾ß ÇÑ´Ù. À̰ÍÀº ´ç½ÅÀÌ interpreter("MyPrivFunc"ÀÇ Ã¹ ¶óÀÎÀÌ À̰ÍÀ» ÇÑ´Ù)¿¡°Ô OTcl command¸¦ Àü´ÞÇϵµ·Ï ÇÏ´Â couple ÇÔ¼ö¸¦ ´ç½Å¿¡°Ô Á¦°øÇÑ´Ù. ÀÌ ¿¹Á¦´Â OTcl command passing ÇÔ¼öÀÇ ¿Ïº®ÇÑ list¿¡ ´ëÇØ¼­´Â NS document¸¦ ÂüÁ¶ÇϽÿÀ.


Compile, run and test "MyAgent"

Áö±Ý±îÁö, ¿ì¸®´Â "MyAgent" ¿¹Á¦¸¦ »ç¿ëÇÏ´Â NS¿¡¼­ À¯¿ëÇÑ essential OTcl linkageµéÀ» ½ÃÇèÇß´Ù. ÀÌ ¿¹Á¦¸¦ runningÇϰí testingÇÏ´Â °ÍÀÌ µ¶ÀÚÀÇ ÀÌÇØ¸¦ ´õ¿í µ½´Â´Ù°í °¡Á¤Çϰí, ¿ì¸®´Â ´ç½ÅÀÌ "MyAgent"¸¦ compileÇϰí, µ¿ÀÛ½Ã۸ç testÇÏ´Â °ÍÀ» µ½´Â ÀýÂ÷¸¦ º¸ÀδÙ.

1. "ex-linkage.cc" fileÀ» ´Ù¿î¹Þ°í, ±×°ÍÀ» "ns-2" directory¹Ø¿¡ ÀúÀåÇ϶ó.

2. "Makefile" fileÀ» ¿­°í, object file listÀÇ ³¡¿¡¼­ "ex-linkage.o"¸¦ Ãß°¡

3. "make" ¸í·ÉÀ» »ç¿ëÇÏ¿© NS¸¦ re-compile

4. OTcl ¸í·É¾îµéÀ» ½ÃÇèÇÏ´Â "MyAgent"¸¦ Æ÷ÇÔÇÏ´Â "ex-linkage.tcl"À» down ¹ÞÀ¸¶ó.(ÀÔ·Â script¿Í ±× °á°ú¿¡ ´ëÇØ¼­´Â ±×¸² 22¸¦ º¸¶ó)

5. "ns ex-linkage.tcl" ¸í·ÉÀ» »ç¿ëÇÏ¿© OTcl script¸¦ ½ÇÇàÇ϶ó.

 

ex-linkage.tcl


# Create MyAgent (This will give two warning message that

# no default values exist for my_var1_otcl and my_var2_otcl)

set myagent [new Agent/MyAgentOtcl]

# Set configurable parameters of MyAgent

$myagent set my_var1_otcl 2

$myagent set my_var2_otcl 3.14

# Give a command to MyAgent

$myagent call-my-priv-func


result

warning: no class variable Agnet/MyAgentOtcl::my_var1_otcl

see tcl-object.tcl in tclcl for info about this warning.

warning: no class variable Agent/MyAgentOtcl::my_var2_Otcl

Message From MyPrivFunc

my_var1 = 2

my_var2 = 3.140000

±×¸² 22. Test OTcl Script and The Result



 

 


 

4.3 Add New Application and Agent

Objective

¿ì¸®´Â UDP ¿¬°á »ó¿¡¼­ µ¿ÀÛÇÏ´Â multimedia applicationÀ» ¸¸µé±â ¿øÇÑ´Ù. ±×°ÍÀº encoding°ú scale parameter °ª°ú ¿¬°üÀÌ ÀÖ´Â transmission policy pairÀ» º¯È­½ÃÅ´À¸·Î½á ¾î¶² ¹üÀ§·Î network congestion¿¡ ÀÀ´äÇÒ ¼ö ÀÖ´Â "five rate media scaling"À» ±¸ÇöÇÏ´Â imaginary multimedia applicationÀÇ µ¿ÀÛÀ» ½Ã¹Ä·¹ÀÌÆ® ÇÑ´Ù.

Application Description

ÀÌ ±¸Çö¿¡¼­, ¿¬°áÀÌ ¼³¸³µÉ ¶§ sender¿Í receiver´Â encoding°ú transmission policy pair°£¿¡ 5°³ÀÇ ´Ù¸¥ set¿¡ ´ëÇØ µ¿ÀÇÇÑ´Ù´Â °ÍÀ» °¡Á¤ÇÑ´Ù. ±×¸®°í ±×°ÍµéÀ» 5°³ÀÇ scale °ª(0-4)À¸·Î °áÇÕ½ÃŲ´Ù°í °¡Á¤ÇÑ´Ù. ´Ü¼øÇÑ ÀÌÀ¯ ¶§¹®¿¡, constant transmission rateÀÌ encoding°ú transmission policy pairÀÇ °¢°¢¿¡ ´ëÇØ ¿ª½Ã °áÁ¤µÈ´Ù´Â °ÍÀ» °¡Á¤ÇÑ´Ù. ±×¸®°í ¸ðµç pair´Â encoding schemeÀÇ µ¿ÀÏÇÑ Å©±âÀÇ regardlessÀÇ packetÀ» »ç¿ëÇÑ´Ù.

±âº»ÀûÀ¸·Î, "five rate media scaling"Àº ´ÙÀ½°ú °°ÀÌ µ¿ÀÛÇÑ´Ù. sender´Â scale 0°ú °áÇÕÇÑ Àü¼Û ¼Óµµ·Î Ãâ¹ßÇÑ´Ù. ±×¸®°í ¼ö½ÅÃøÀÌ ÀÎÁöÇÏ´Â scale °ª¿¡ µû¶ó¼­ Àü¼Û¼Óµµ¸¦ º¯È­ÇÑ´Ù. receiver´Â network congestionÀ» monitorÇϰí scale factor¸¦ °áÁ¤ÇÒ Ã¥ÀÓÀÌ ÀÖ´Ù. congestion monitoringÀ» À§ÇØ °£´ÜÇÑ ÁÖ±âÀû(for every RTT second) packet loss monitoringÀÌ »ç¿ëµÈ´Ù. ±×¸®°í, °¢ Áֱ⿡ ´ëÇÑ ´ÜÀÏ packet loss±îÁö network congestionÀ¸·Î °£ÁֵȴÙ. ¸¸ÀÏ congestionÀÌ °ËÃâµÇ¸é, receiver´Â scale parameter °ªÀ» ¹ÝÀ¸·Î °¨¼Ò½Ã۸ç, ÀÌ °ªÀ» sender¿¡°Ô ¾Ë¸°´Ù. ¸¸ÀÏ, ¾Æ¹« packet loss°¡ °ËÃâµÇÁö ¾ÊÀ¸¸é receiver´Â 1¸¸Å­ ±× °ªÀ» Áõ°¡½ÃŰ¸ç ±×°ÍÀ» sender¿¡°Ô ¾Ë¸°´Ù.

Problem Analysis

ÀÌ ÀÀ¿ëÀ» ±¸ÇöÇϱâ Àü¿¡, UDP agent ±¸ÇöÀÌ ½ÃÇèµÇ°í ÇϳªÀÇ major ¹®Á¦°¡ ¹ß°ßµÈ´Ù. UDP agent°¡ network packetÀ» ÇÒ´çÇϰí Àü¼ÛÇϱ⠶§¹®¿¡, application level communication¿¡ ÇÊ¿äÇÑ ¸ðµç Á¤º¸´Â data streamÀ¸·Î¼­ UDP agent·Î Á¶Á¤µÇ¾î¾ß ÇÑ´Ù. ±×·¯³ª, UDP ±¸ÇöÀº header stack¸¸À» °®´Â packet¸¦ ÇÒ´çÇÑ´Ù. ±×·¯¹Ç·Î, ¿ì¸®´Â ÀÀ¿ëÀ¸·ÎºÎÅÍ ¼ö½ÅµÈ data¸¦ Àü¼ÛÇÏ´Â mechanismÀ» Ãß°¡Çϱâ À§ÇÑ UDP ±¸ÇöÀ» modify ÇØ¾ßÇÒ Çʿ䰡 ÀÖ´Ù. ±×°ÍÀº ¶ÇÇÑ IP router queue management mechanism »ó¿¡¼­ ÇâÈÄÀÇ ¿¬±¸¸¦ À§ÇØ ÀÌ ÀÀ¿ëÀ» »ç¿ëÇϱ⸦ ¿øÇÑ´Ù´Â Á¡À» ÁÖ¸ñÇϽÿÀ. ±×·¯¹Ç·Î, ¿ì¸®´Â ´Ù¸¥ stream typeÀ¸·ÎºÎÅÍ multimedia stream typeÀ» ±¸º°Çϱâ À§ÇÑ ¹æ¹ýÀÌ ÇÊ¿äÇÏ´Ù. ±×°ÍÀº ¿ì¸®°¡ ¶ÇÇÑ ÇöÀç »ç¿ëµÇÁö ¾Ê°í ÀÖ´Â IP header fieldÀÇ Çϳª¿¡ data typeÀ» ±â·ÏÇϱâ À§ÇÑ UDP agent¸¦ º¯°æÇÒ Çʿ䰡 ÀÖ´Ù´Â °ÍÀÌ´Ù.

Design and Implementation

ÀÀ¿ë¿¡ ´ëÇØ¼­, ¿ì¸®´Â CBR ±¸ÇöÀ» ÃëÇÏ°í ±×°ÍÀ» "five media scaling" Ư¡À» °®µµ·Ï º¯ÇüÇÒ °ÍÀ» °áÁ¤Çß´Ù. ¿ì¸®´Â C++ hierachy¸¦ ½ÃÇèÇϰí ÀÌ ÀÀ¿ëÀÇ class¸¦ "MmApp"·Î ¸í¸íÇϰí, "Application"ÀÇ child class·Î ±¸ÇöÇÒ °ÍÀ» °áÁ¤Çß´Ù. matchingµÇ´Â OTcl hierachy À̸§Àº "Application/MmApp"ÀÌ´Ù.

applicationÀÇ sender¿Í receiverÀÇ µ¿ÀÛÀº "MmApp"¿¡¼­ ÇÔ²² ±¸ÇöµÈ´Ù. "MmApp"¸¦ Á¦°øÇÏ´Â º¯ÇüµÈ UDP agent¿¡ ´ëÇØ¼­, ¿ì¸®´Â "UdpAmAgent"·Î ¸í¸íÇϰí, "UdpAgent"ÀÇ child class·Î ±×°ÍÀ» ±¸ÇöÇÒ °ÍÀ» °áÁ¤Çß´Ù. matchingµÇ´Â OTcl hierachy À̸§Àº "Agent/UDP/UDPmm"ÀÌ´Ù.

 

¡Û MmApp Header:

application levelÀÇ Åë½ÅÀ» À§ÇØ, ¿ì¸®´Â structure°¡ C++¿¡¼­ "hdr_mm"·Î ¸í¸íÇÑ header¸¦ Á¤ÀÇÇÒ °ÍÀ» °áÁ¤Çß´Ù. applicationÀÌ Àü¼ÛÇÒ Á¤º¸¸¦ °¡Áú ¶§¸¶´Ù, ±×°ÍÀº "hdr_mm" structure format¿¡ ÀÖ´Â "UdpMmAgent"·Î ±×°ÍÀ» Àü´ÞÇÑ´Ù. ±×¶§, "UdpMmAgent"´Â Çϳª ȤÀº ±× ÀÌ»óÀÇ packet(½Ã¹Ä·¹ÀÌÆ®µÈ data packet size¿¡ ´Þ·ÁÀÖ´Â)À» ÇÒ´çÇϰí, ±× data¸¦ °¢ packetÀÇ multimedia header¿¡ ±â·ÏÇÑ´Ù. ±×¸² 23Àº header¿Í header class object¿¡ ´ëÇÑ ±¸Á¶ ³»ºÎ¿¡¼­ "PacketHeaderClass"·ÎºÎÅÍ ÃßÃâµÇ¾î¾ß ÇÏ´Â "MultimediaHeaderClass"°¡ Á¤ÀǵǾî¾ß ÇÑ´Ù´Â header Á¤ÀǸ¦ º¸¿©ÁØ´Ù. ÀÌ class¸¦ Á¤ÀÇÇÏ´Â µ¥ À־, header("PacketHeader/Multimedia")¿¡ ´ëÇÑ OTcl À̸§°ú jdÀÇµÈ header structureÀÇ Å©±â°¡ ³ªÅ¸³ª ÀÖ´Ù.


C++¿¡ ÀÖ´Â header¸¦ Á¤ÀÇÇÑ µÚ¿¡, ¿ì¸®´Â »õ·Î¿î header offset OTcl º¯¼ö À̸§À¸·Î "off_mm_"·Î Á¤Çϰí, ±×¸² 24¿¡¼­ º¸´Â¹Ù¿Í °°ÀÌ OTcl header¿Í "ns-packet.tcl"·Î offset º¯¼ö À̸§ pair¸¦ ºÎ°¡ÇÏ¿´´Ù. À̰ÍÀº header stack format¼ÓÀ¸·Î ´ç½ÅÀÇ header¸¦ Æ÷ÇÔÇÏ´Â NS¸¦ ¸¸µé°í, ÁÖ¾îÁø offset º¯¼ö·Î stack¿¡ ÀÖ´Â ´ç½ÅÀÇ headerÀÇ offsetÀ» ÀúÀåÇÒ °ÍÀÌ´Ù.


header »ý¼º process°¡ ³¡³­ ½ÃÁ¡¿¡¼­, ±×¸®°í "UdpMmAgent"°¡ º¯¼ö¸¦ Á¤ÀÇÇÔÀ¸·Î½á »õ·Î¿î header¸¦ accessÇϰí "off_mm_" OTcl º¯¼ö·Î ±×°ÍÀ» bindÇÒ °ÍÀÌ´Ù. ÀÀ¿ëÀÇ ³ª¸ÓÁö ºÎºÐ°ú º¯ÇüµÈ UDP agent description¿¡ ´ëÇØ¼­´Â "mm-app.h", "mm-app.cc", "udp-mm.h"¿Í "udp-mm.cc"¸¦ ÂüÁ¶Ç϶ó.


 

¤· MmApp Sender:

sender´Â ´ÙÀ½ ÀÀ¿ë data packet Àü¼ÛÀ» schedulingÇϱâ À§ÇØ timer¸¦ »ç¿ëÇÑ´Ù. ¿ì¸®´Â "TimeHandler" class·ÎºÎÅÍ À¯µµÇÑ "SendTimer" class¸¦ Á¤ÀÇÇß´Ù. ±×¸®°í, "MmApp" objectfml "send_mm_pkt()" member ÇÔ¼ö¸¦ È£ÃâÇϱâ À§ÇØ ±×°ÍÀÇ "expire()" member ÇÔ¼ö writeÇß´Ù. ±×¶§, ¿ì¸®´Â "snd_timer_" ¸¸Å­ °ü·ÃµÈ "MmApp"ÀÇ private member·Î¼­ ÀÌ objectÀÇ instance¸¦ Æ÷ÇÔÇß´Ù. ±×¸² 25´Â "SendTimer" ±¸ÇöÀ» º¸¿©ÁØ´Ù.

 

ÀÌ timer¸¦ settingÇϱâ Àü¿¡, "MmApp"´Â ÀÔ·Â simualtion script(or use the default size)¿¡¼­ ÁÖ¾îÁø ÀÀ¿ë data packetÀÇ Å©±â¿Í ÇöÀç scale value¿Í °ü·ÃµÈ Àü¼Û rate¸¦ »ç¿ëÇÏ´Â next transmission timeÀ» Àç °è»êÇÑ´Ù. ACK ÀÀ¿ë packetÀÌ ¼ö½ÅÃøÀ¸·ÎºÎÅÍ µµÂøÇÒ ¶§ "MmApp" sender´Â scale parameter¸¦ °»½ÅÇÑ´Ù.

 

 

¡Û MmApp Receiver:

receiver´Â intervalÀÌ Æò±Õ RTT¿Í µ¿ÀÏÇÑ next application ACK packet Àü¼ÛÀ» scheduleÇϱâ À§Çؼ­ "ack_timer_"·Î À̸§Áö¾îÁø timer¸¦ »ç¿ëÇÑ´Ù. receiver´Â sender·ÎºÎÅÍ ÀÀ¿ë data packetÀ» ¼ö½ÅÇÒ ¶§, ¼ö½ÅµÈ packetÀÇ ¼ö¸¦ countÇϰí, packet sequence number¸¦ »ç¿ëÇÏ´Â lost packetÀÇ ¼ö¸¦ countÇÑ´Ù. "ack_timer_"°¡ ÃʰúÇÒ ¶§, ±×°ÍÀº ¼ö½ÅµÈ ±×¸®°í lostµÈ packet accounting Á¤º¸¸¦ ÁÖ½ÃÇÏ´Â scale value¸¦ Á¶Á¤ÇÏ´Â "MmApp"ÀÇ "send_ack_pkt" member ÇÔ¼ö¸¦ ºÒ·¯³»°í, ¼ö½ÅµÈ ±×¸®°í lostµÈ count¸¦ 0À¸·Î resetÇϸç, Á¶Á¤µÈ scale value·Î ACK packetÀ» Àü¼ÛÇÑ´Ù. receiver´Â ¾î¶² ¿¬°á ¼ö¸³À̳ª Àý´Ü method¸¦ °®°íÀÖÁö ¾Ê´Ù. ±×·¯¹Ç·Î, first packet arrival·ÎºÎÅÍ startÇÔÀ¸·Î½á, receiver´Â ÁÖ±âÀûÀ¸·Î ACK packetÀ» Àü¼ÛÇϰí Àý´ë stopÇÏÁö ¾Ê´Â´Ù.(À̰ÍÀº bugÀÌ´Ù.)

 

¡Û UdpMmAgent:

"UdpMmAgent"´Â ´ÙÀ½°ú °°Àº ºÎ°¡ÀûÀΠƯ¡À» °®´Â "UdpAgent"·ÎºÎÅÍ °»½ÅµÈ´Ù.

(1) "MmApp"·ÎºÎÅÍ ¼ö½ÅµÈ Á¤º¸¸¦ Àü¼ÛµÇ°í ÀÖ´Â data packet MM header¿¡ writing ÇÏ´Â °Í(ȤÀº ¼ö½ÅµÈ data packet MM header·ÎºÎÅÍ Á¤º¸¸¦ Àаí ÀÖ´Â)

(2) segmentation°ú re-assembly("UdpAgent"´Â segmentation¸¸À» ±¸ÇöÇÑ´Ù.)

(3) "MmApp" packetÀ» À§ÇØ 15(max priority)±îÁö priority bit(IPv6)¸¦ setting

 

¡Û Modify "agent.h":

´ç½ÅÀÇ NS distributionÀ¸·Î µ¿ÀÛÇÏ´Â »õ·Î¿î application°ú agent¸¦ ¸¸µé±â À§Çؼ­, ´ç½ÅÀº "Agent" class¸¦ publicÀ¸·Î ÇÏ´Â µÎ °³ÀÇ methods¸¦ ºÎ°¡ÇØ¾ß ÇÑ´Ù.


"MmApp"ÀÇ "command" member ÇÔ¼ö¿¡¼­, "attach-agent" OTcl command°¡ Á¤ÀǵǾî ÀÖ´Ù. ÀÌ ¸í·ÉÀÌ OTcl·ÎºÎÅÍ ¼ö½ÅµÉ ¶§, "MmApp"´Â ±× ÀÚ½ÅÀÌ underlying agent·Î Á¢¼ÓÇϵµ·Ï ³ë·ÂÇÑ´Ù. Á¢¼Ó Àü¿¡, ±×°ÍÀº underlying agent°¡ ¸ÖƼ¹Ìµð¾î Àü¼Û(ÀÀ¿ë¿¡¼­ ÀÀ¿ëÀ¸·Î data¸¦ ¿Å±æ ¼ö ÀÖ´ÂÁö µîµî)À» Áö¿øÇÏ´ÂÁö¸¦ Á¡°ËÇϱâ À§Çؼ­ underlying agentÀÇ "supportMM()" member ÇÔ¼ö¸¦ ºÒ·¯³½´Ù. ±×¸®°í, ¸¸ÀÏ ±×°ÍÀÌ ÇàÇØÁø´Ù¸é "enableMM()"À» ºÒ·¯³½´Ù. ºñ·Ï ÀÌ µÎ °³ÀÇ member ÇÔ¼ö°¡ "UdpMmAgent" class¿¡ Á¤ÀǵǾî ÀÖÁö¸¸, ±×°ÍÀº ±×°ÍÀÇ base Á¶»ó(ancestor) "Agent" class¿¡ Á¤ÀǵÇÁö ¾Ê°í, ÀϹÝÀûÀÎ "Agent" classÀÇ µÎ member ÇÔ¼öµéÀÌ È£ÃâµÈ´Ù. ±×·¯¹Ç·Î, ±× code¸¦ compileÇÏ·Á°í ÇÒ ¶§, ±×°ÍÀº error message¸¦ ÁÙ °ÍÀÌ´Ù. ´ÙÀ½°ú °°Àº "Agent" class(in "agent.h")ÀÇ public member ÇÔ¼ö·Î¼­ µÎ methods¸¦ »ðÀÔÇÔÀ¸·Î½á, ÀÌ ¹®Á¦¸¦ ÇØ°áÇÒ °ÍÀÌ´Ù.

 

 

¡Û Set default values for new parameter in the "ns-default.tcl":

ÀÀ¿ë°ú agentÀÇ ¸ðµç ºÎºÐÀ» ±¸ÇöÇÑ µÚ¿¡, ¸¶Áö¸·À¸·Î ÇÒ ÀÏÀº "ns-default.tcl" file¿¡ ÀÖ´Â »õ·Ó°Ô ¼Ò°³µÈ configurable parameter¿¡ ´ëÇÑ default °ªÀ» setÇÏ´Â °ÍÀÌ´Ù. ±×¸² 26Àº "MmApp"¿¡ ÀÇÇØ ¼Ò°³µÈ configurable parameter¿¡ ´ëÇÑ default °ªÀ» settingÇÏ´Â ¿¹¸¦ º¸¿©ÁØ´Ù.

 

Download and Compile

¿©±â¿¡ ´ç½ÅÀÇ NS¸¦ compileÇϱâ Àü¿¡ ÇØ¾ßÇÏ´Â checklist°¡ ÀÖ´Ù.

1. "ns-2" µð·ºÅ丮·Î "mm-app.h", "mm-app.cc", "udp-mm.h" and "udp-mm.cc"¸¦ downloadÇ϶ó.

2. »ó±â¿¡ ±ÔÁ¤µÈ °Íó·³ "ns-packet.tcl"¿¡¼­ »õ·Î¿î ÀÀ¿ë header¸¦ µî·ÏÇß´ÂÁö È®ÀÎÇ϶ó.

3. »ó±â¿¡ ±ÔÁ¤µÈ °Íó·³ "agent.h" file¿¡¼­ "Agent" class·Î µÎ °³ÀÇ method¸¦ ºÎ°¡Ç϶ó.

4. »ó±â¿¡ ±â¼úÇÑ ¹Ù¿Í °°ÀÌ "ns-default.tcl"¿¡ ÀÖ´Â »õ·Ó°Ô ¼Ò°³µÈ configurable parameter¿¡ ´ëÇÑ default °ªÀ» SetÇ϶ó.

ÀÌ checklist¿¡ ÀÖ´Â ¸ðµç °ÍÀ» ÇàÇÑ ÈÄ¿¡, ÇÊ¿äÇÑ ¸¸Å­(object file list¿¡ ÀÖ´Â "mm-app.o"¿Í "udp-mm.o"¸¦ Æ÷ÇÔÇÏ¿©) "Makefile"¸¦ °»½ÅÇϰí, NS¸¦ re-compileÇ϶ó. ÀϹÝÀûÀ¸·Î re-compileÇϱâ Àü¿¡ "Makefile"¿¡¼­ º¯°æÀ» ÇÑ ÈÄ¿¡ "make depend"¸¦ ÇÏ´Â °ÍÀº ÈǸ¢ÇÑ ½Ç½ÀÀÌ´Ù.

Test Simulation

±×¸²28Àº "MmApp"¸¦ ½ÃÇèÇϴµ¥ »ç¿ëµÇ´Â ½Ã¹Ä·¹ÀÌ¼Ç topology¿Í scenario¸¦ º¸¿©ÁØ´Ù. ±×¸®°í ±×¸² 29´Â test ½Ã¹Ä·¹ÀÌ¼Ç script¸¦ º¸¿©ÁØ´Ù. ÀÌ script¸¦ down ¹Þ°í »õ·Ó°Ô ºÎ°¡µÈ component¸¦ ½ÃÇèÇ϶ó.



 


±×¸² 29. "MmApp" Test Simulation Script

# Author: Jae Chung

# Date: 7/17/99

#

#

# s1 s3

# \ /

# 5Mb,3ms \ 2Mb,10ms / 5Mb,3ms

# r1 --------- r2

# 5Mb,3ms / \ 5Mb,3ms

# / \

# s2 s4

#

set ns [new Simulator]

#Define different colors for data flows

$ns color 1 Red

$ns color 2 Blue

#Open the nam trace file

set nf [open out.nam w]

set tf [open out.tr w]

$ns namtrace-all $nf

$ns trace-all $tf

#Define a 'finish' procedure

proc finish {} {

global ns nf tf

$ns flush-trace

#Close the trace file

close $nf

close $tf

#Execute nam on the trace file

exec nam out.nam &

exit 0

}

set node_(s1) [$ns node]

set node_(s2) [$ns node]

set node_(r1) [$ns node]

set node_(r2) [$ns node]

set node_(s3) [$ns node]

set node_(s4) [$ns node]

$ns duplex-link $node_(s1) $node_(r1) 5Mb 3ms DropTail

$ns duplex-link $node_(s2) $node_(r1) 5Mb 3ms DropTail

$ns duplex-link $node_(r1) $node_(r2) 2Mb 10ms RED

$ns duplex-link $node_(s3) $node_(r2) 5Mb 3ms DropTail

$ns duplex-link $node_(s4) $node_(r2) 5Mb 3ms DropTail

#Setup RED queue parameter

$ns queue-limit $node_(r1) $node_(r2) 20

Queue/RED set thresh_ 5

Queue/RED set maxthresh_ 10

Queue/RED set q_weight_ 0.002

Queue/RED set ave_ 0

$ns duplex-link-op $node_(r1) $node_(r2) queuePos 0.5

$ns duplex-link-op $node_(s1) $node_(r1) orient right-down

$ns duplex-link-op $node_(s2) $node_(r1) orient right-up

$ns duplex-link-op $node_(r1) $node_(r2) orient right

$ns duplex-link-op $node_(s3) $node_(r2) orient left-down

$ns duplex-link-op $node_(s4) $node_(r2) orient left-up

#Setup a MM UDP connection

set udp_s [new Agent/UDP/UDPmm]

set udp_r [new Agent/UDP/UDPmm]

$ns attach-agent $node_(s1) $udp_s

$ns attach-agent $node_(s3) $udp_r

$ns connect $udp_s $udp_r

$udp_s set packetSize_ 1000

$udp_r set packetSize_ 1000

$udp_s set fid_ 1

$udp_r set fid_ 1

#Setup a MM Application

set mmapp_s [new Application/MmApp]

set mmapp_r [new Application/MmApp]

$mmapp_s attach-agent $udp_s

$mmapp_r attach-agent $udp_r

$mmapp_s set pktsize_ 1000

$mmapp_s set random_ false

#Setup a TCP connection

set tcp [$ns create-connection TCP/Reno $node_(s2) TCPSink $node_(s4) 0]

$tcp set window_ 15

$tcp set fid_ 2

#Setup a FTP Application

set ftp [$tcp attach-source FTP]

#Simulation Scenario

$ns at 0.0 "$ftp start"

$ns at 1.0 "$mmapp_s start"

$ns at 7.0 "finish"

$ns run





 

 


 

4.4 Add New Queue

Objective

°£´ÜÇÑ drop-tailÀ» ¸¸µé±â À§ÇØ router´Â ("MmApp" over "UDPmm"À¸·ÎºÎÅÍ) priority 15 packets¿Í queue¿¡¼­ °øÁ¸ÇÏ´Â ´Ù¸¥ packetµé¿¡ ´ëÇÑ round-robin dequeue schedulingÀ» »ç¿ëÇÏ´Â queue¸¦ Ãâ·ÂÇÑ´Ù. ±×°ÍÀº °¢ typeÀÇ °¡Àå ¿À·¡µÈ packet¿Í ÀÏ´ë ÀÏ·Î ¹ø°¥¾Æ dequeueÇÑ´Ù.

 

Design

queue´Â total size°¡ physical queue(PQ)ÀÇ Å©±â¿Í µ¿ÀÏÇÑ(LQ1+LQ2=PQ µî) LQ1°ú LQ2¶ó°í ÇÏ´Â µÎ °³ÀÇ logical FIFO queue¸¦ °¡Áö°í ÀÖ´Ù.

normal drop-tail enqueue µ¿ÀÛÀ» ±¸ÇöÇϱâ À§Çؼ­, packetÀÌ enqueueµÉ ¶§, enqueue manager´Â LQ1+LQ2ÀÇ Å©±â°¡ Çã¿ëµÈ PQÀÇ ÃÖ´ë Å©±âº¸´Ù ÀÛÀºÁö¸¦ °Ë»çÇÑ´Ù. ¸¸ÀÏ ±×·¸´Ù¸é, packetÀº Àû´çÇÑ logical queue·Î enqueueµÉ °ÍÀÌ´Ù.

round-robin dequeue schedulingÀ» ±¸ÇöÇϱâ À§Çؼ­, dequeue manager´Â ÇÑ logical queue·ÎºÎÅÍ ÇϳªÀÇ packetÀ» dequeueÇϰí Â÷·Ê·Î ´Ù¸¥ logical queue·ÎºÎÅÍ ´ÙÀ½ packetÀ» dequeueÇÏ·Á°í ÇÑ´Ù. ¸¸ÀÏ ¾ç queue°¡ ¸ðµÎ packetÀ» °¡Á³´Ù¸é, µÎ °³ÀÇ logical queue¿¡ ÀÖ´Â packetµéÀº 1:1ÀÇ ºñÀ²·Î dequeueµÈ´Ù.

 

Implementation

¿ì¸®´Â ÀÌ queue object¿¡ ´ëÇÑ C++ À̸§À» "Queue" class·ÎºÎÅÍ À¯µµµÈ "DtRrQueue"(Drop-Tail Round_Robin Queue)¶ó ¸í¸íÇß´Ù. matchingµÇ´Â OTcl À̸§Àº "Queue/DTRR"ÀÌ´Ù. "Queue" class¿¡¼­(in "queue.cc") ±¸ÇöµÈ "recv" member ÇÔ¼ö°¡ packetÀ» ¼ö½ÅÇÒ ¶§, ±×°ÍÀº queue objectÀÌ "enqueue" member ÇÔ¼ö¸¦ È£ÃâÇϰí, link object°¡ blockµÇÁö ¾Ê´Â´Ù¸é "dequeue"¸¦ È£ÃâÇÑ´Ù. link°¡ blockµÈ »óÅ·κÎÅÍ ³ª¿ÔÀ» ¶§, ±×°ÍÀº ¶ÇÇÑ ±×°ÍÀÇ queue objectÀÇ "dequeue" member ÇÔ¼ö¸¦ È£ÃâÇÑ´Ù. ±×·¯¹Ç·Î, ¿ì¸®´Â "DtRrQueue" object classÀÇ member ÇÔ¼ö "enqueue"¿Í "dequeue"¸¦ ¾µ Çʿ䰡 ÀÖ´Ù. ±×¸² 30Àº "DtRrQueue" class Á¤ÀÇ¿Í "enqueue"¿Í "dequeue" member ÇÔ¼ö¸¦ º¸¿©ÁØ´Ù. ¿ÏÀüÇÑ ±¸ÇöÀ» À§Çؼ­, "dtrr-queue.h"¿Í "dtrr-queue.c" fileÀ» Âü°íÇ϶ó. ÀÌ code´Â ½ÇÁ¦·Î ÀÌÇØÇϱ⿡ ½±±â ¶§¹®¿¡ ´õ ÀÌ»óÀÇ ¼³¸íÀº ¾ø´Ù.

 

dtrr-queue.h

// Author: Jae Chung

// Date: 7/19/99, File: dtrr-queue.h

#include <string.h>

#include "queue.h"

#include "address.h"

class DtRrQueue : public Queue {

public:

DtRrQueue() {

q1_ = new PacketQueue;

q2_ = new PacketQueue;

pq_ = q1_;

deq_turn_ = 1;

bind("off_ip_", &off_ip_);

}

protected:

void enque(Packet*);

Packet* deque();

PacketQueue *q1_; // First FIFO queue

PacketQueue *q2_; // Second FIFO queue

int deq_turn_; // 1 for First queue 2 for Second

int off_ip_;

};


 

dtrr-queue.cc

// Author: Jae Chung

// Date: 7/19/99, File: dtrr-queue.cc

#include "dtrr-queue.h"

static class DtRrQueueClass : public TclClass {

public:

DtRrQueueClass() : TclClass("Queue/DTRR") {}

TclObject* create(int, const char*const*) {

return (new DtRrQueue);

}

} class_dropt_tail_round_robin;

void DtRrQueue::enque(Packet* p)

{

hdr_ip* iph = (hdr_ip*)p->access(off_ip_);

// if IPv6 priority = 15 enqueue to queue1

if (iph->prio_ == 15) {

q1_->enque(p);

if ((q1_->length() + q2_->length()) > qlim_) {

q1_->remove(p);

drop(p);

}

}

else {

q2_->enque(p);

if ((q1_->length() + q2_->length()) > qlim_) {

q2_->remove(p);

drop(p);

}

}

}


 

dtrr-queue.cc


Packet* DtRrQueue::deque()

{

Packet *p;

if (deq_turn_ == 1) {

p = q1_->deque();

if (p == 0) {

p = q2_->deque();

deq_turn_ = 1;

}

else {

deq_turn_ = 2;

}

}

else {

p = q2_->deque();

if (p == 0) {

p = q1_->deque();

deq_turn_ = 2;

}

else {

deq_turn_ = 1;

}

}

return (p);

}

±×¸² 30. "DtRrQueue" class implementation

 

 

Test Simulation

¿ì¸®´Â ¾ÕÀÇ section¿¡¼­ ¸µÅ© r1-r2¿¡ ´ëÇØ RED queue¸¦ DTRR queue·Î ¹Ù²ÞÀ¸·Î½á, "UDPmm"»óÀÇ "MmApp" ½ÃÇèÀ» À§ÇØ »ç¿ëµÈ simulation script¸¦ »ç¿ëÇß´Ù. ÀÌ script¸¦ down ¹Þ°í »õ·Ó°Ô ºÎ°¡µÈ queue component¸¦ ½ÃÇèÇ϶ó.


±×¸² 31. "DtRrQueue" test simulation script


# Author: Jae Chung, Date: 7/17/99

# s1 s3

# \ /

# 5Mb,3ms \ 2Mb,10ms / 5Mb,3ms

# r1 --------- r2

# 5Mb,3ms / \ 5Mb,3ms

# / \

# s2 s4

set ns [new Simulator]

#Define different colors for data flows

$ns color 1 Red

$ns color 2 Blue

#Open the nam trace file

set nf [open out.nam w]

set tf [open out.tr w]

$ns namtrace-all $nf

$ns trace-all $tf

#Define a 'finish' procedure

proc finish {} {

global ns nf tf

$ns flush-trace

#Close the trace file

close $nf

close $tf

#Execute nam on the trace file

exec nam out.nam &

exit 0

}

set node_(s1) [$ns node]

set node_(s2) [$ns node]

set node_(r1) [$ns node]

set node_(r2) [$ns node]

set node_(s3) [$ns node]

set node_(s4) [$ns node]

$ns duplex-link $node_(s1) $node_(r1) 5Mb 3ms DropTail

$ns duplex-link $node_(s2) $node_(r1) 5Mb 3ms DropTail

$ns duplex-link $node_(r1) $node_(r2) 2Mb 10ms DTRR

$ns duplex-link $node_(s3) $node_(r2) 5Mb 3ms DropTail

$ns duplex-link $node_(s4) $node_(r2) 5Mb 3ms DropTail

#Set DTRR queue size to 20

$ns queue-limit $node_(r1) $node_(r2) 20

$ns duplex-link-op $node_(r1) $node_(r2) queuePos 0.5

$ns duplex-link-op $node_(s1) $node_(r1) orient right-down

$ns duplex-link-op $node_(s2) $node_(r1) orient right-up

$ns duplex-link-op $node_(r1) $node_(r2) orient right

$ns duplex-link-op $node_(s3) $node_(r2) orient left-down

$ns duplex-link-op $node_(s4) $node_(r2) orient left-up

#Setup a MM UDP connection

set udp_s [new Agent/UDP/UDPmm]

set udp_r [new Agent/UDP/UDPmm]

$ns attach-agent $node_(s1) $udp_s

$ns attach-agent $node_(s3) $udp_r

$ns connect $udp_s $udp_r

$udp_s set packetSize_ 1000

$udp_r set packetSize_ 1000

$udp_s set fid_ 1

$udp_r set fid_ 1

#Setup a MM Application

set mmapp_s [new Application/MmApp]

set mmapp_r [new Application/MmApp]

$mmapp_s attach-agent $udp_s

$mmapp_r attach-agent $udp_r

$mmapp_s set pktsize_ 1000

$mmapp_s set random_ false

#Setup a TCP connection

set tcp [$ns create-connection TCP/Reno $node_(s2) TCPSink $node_(s4) 0]

$tcp set window_ 15

$tcp set fid_ 2

#Setup a FTP Application

set ftp [$tcp attach-source FTP]

#Simulation Scenario

$ns at 0.0 "$ftp start"

$ns at 1.0 "$mmapp_s start"

$ns at 7.0 "finish"

$ns run



















5. More Examples

 


 

5.1 LAN Example

ÀÌ ÀýÀº ¿¹Á¦ LAN simulation script¿¡ pointer¸¦ Æ÷ÇÔÇÑ´Ù. ±×¸®°í, ±×°ÍÀÇ network topology¿Í simulation scenario¸¦ º¸¿©ÁØ´Ù. "ns-2/tcl/ex/lantest.tcl"·ÎºÎÅÍ ¾à°£ º¯ÇüµÈ "ex-lan.tcl" fileÀ» down ¹Þ°í, ±×°ÍÀ» ½ÃÇèÇØ º¸¶ó.

 

 

ex-lan.tcl


# Author: Jae Chung

# Date: 7/20/99

#

# This file is modified from

# "ns-2/tcl/ex/lantest.tcl"

set opt(tr)"out.tr"

set opt(namtr)"out.nam"

set opt(seed)0

set opt(stop)5

set opt(node)8

set opt(qsize)100

set opt(bw)10Mb

set opt(delay)1ms

set opt(ll)LL

set opt(ifq)Queue/DropTail

set opt(mac)Mac/Csma/Ca

set opt(chan)Channel

set opt(tcp)TCP/Reno

set opt(sink)TCPSink

set opt(app)FTP

proc finish {} {

global ns opt trfd ntrfd

$ns flush-trace

close $trfd

close $ntrfd

exec nam $opt(namtr) &

exit 0

}

proc create-trace {} {

global ns opt

set trfd [open $opt(tr) w]

$ns trace-all $trfd

return $trfd

}

proc create-namtrace {} {

global ns opt

set ntrfd [open $opt(namtr) w]

$ns namtrace-all $ntrfd

}

proc create-topology {} {

global ns opt

global lan node source node0

set num $opt(node)

for {set i 0} {$i < $num} {incr i} {

set node($i) [$ns node]

lappend nodelist $node($i)

}

set lan [$ns newLan $nodelist $opt(bw) $opt(delay) \

-llType $opt(ll) -ifqType $opt(ifq) \

-macType $opt(mac) -chanType $opt(chan)]

set node0 [$ns node]

$ns duplex-link $node0 $node(0) 2Mb 2ms DropTail

$ns duplex-link-op $node0 $node(0) orient right

}

## MAIN ##

set ns [new Simulator]

set trfd [create-trace]

set ntrfd [create-namtrace]

create-topology

set tcp0 [$ns create-connection TCP/Reno $node0 TCPSink $node(7) 0]

$tcp0 set window_ 15

set ftp0 [$tcp0 attach-app FTP]

$ns at 0.0 "$ftp0 start"

$ns at $opt(stop) "finish"

$ns run




 


 

5.2 Multicasting Example

ÀÌ sectionÀº example multicasting simulation script¿¡ pointer¸¦ Æ÷ÇÔÇÏ°í ½Ã¹Ä·¹À̼ÇÀÇ NAM screen capture¸¦ º¸¿©ÁØ´Ù. "ex-mcast.tcl" fileÀ» down ¹Þ°í, ±×°ÍÀ» ½ÃÇèÇØ º¸¶ó. ÀÌ ¿¹Á¦´Â 5¼Ò VINT/NS Simulator Tutorial/Workshop·ÎºÎÅÍ °¡Á® ¿Ô´Ù.



 

 



ex-mcast.tcl

# Polly Huang 8-7-98

set ns [new Simulator]

$ns multicast

set f [open out.tr w]

$ns trace-all $f

$ns namtrace-all [open out.nam w]

$ns color 1 red

# prune/graft packets

$ns color 30 purple

$ns color 31 green

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

# Use automatic layout

$ns duplex-link $n0 $n1 1.5Mb 10ms DropTail

$ns duplex-link $n1 $n2 1.5Mb 10ms DropTail

$ns duplex-link $n1 $n3 1.5Mb 10ms DropTail

$ns duplex-link-op $n0 $n1 orient right

$ns duplex-link-op $n1 $n2 orient right-up

$ns duplex-link-op $n1 $n3 orient right-down

$ns duplex-link-op $n0 $n1 queuePos 0.5

set mrthandle [$ns mrtproto DM {}]

set cbr0 [new Application/Traffic/CBR]

set udp0 [new Agent/UDP]

$cbr0 attach-agent $udp0

$ns attach-agent $n1 $udp0

$udp0 set dst_ 0x8001

set cbr1 [new Application/Traffic/CBR]

set udp1 [new Agent/UDP]

$cbr1 attach-agent $udp1

$udp1 set dst_ 0x8002

$udp1 set class_ 1

$ns attach-agent $n3 $udp1

set rcvr [new Agent/LossMonitor]

#$ns attach-agent $n3 $rcvr

$ns at 1.2 "$n2 join-group $rcvr 0x8002"

$ns at 1.25 "$n2 leave-group $rcvr 0x8002"

$ns at 1.3 "$n2 join-group $rcvr 0x8002"

$ns at 1.35 "$n2 join-group $rcvr 0x8001"

$ns at 1.0 "$cbr0 start"

$ns at 1.1 "$cbr1 start"

$ns at 2.0 "finish"

proc finish {} {

global ns

$ns flush-trace

puts "running nam..."

exec nam out.nam &

exit 0

}

$ns run








 

 

 




5.3 Web Server Example

ÀÌ sectionÀº ¿¹Á¦ Web Server ½Ã¹Ä·¹ÀÌ¼Ç script¿¡ pointer¸¦ Æ÷ÇÔÇϰí, ±× network topology¸¦ º¸¿©ÁØ´Ù. "ex-web.tcl"°ú "dumbbell.tcl" fileÀ» down ¹Þ°í, ±×°ÍµéÀ» ½ÃÇèÇØ º¸¶ó. ´ç½ÅÀº ´ç½ÅÀÇ machine¿¡¼­ ±×°ÍÀ» µ¿ÀÛÇÏ°Ô Çϱâ À§Çؼ­ scriptÀÇ ½ÃÀÛ ºÎºÐ¿¡¼­ "http-mod.tcl"¿¡ ´ëÇÑ path¸¦ º¯°æÇؾßÇÑ´Ù´Â Á¡¿¡ ÁÖÀÇÇ϶ó.


 

 

 

 

dumbbell.tcl

# Polly Huang 8-7-98

# Initial setup

source ~/ns-allinone-2.1b4a/ns-2/tcl/http/http-mod.tcl

source dumbbell.tcl

global num_node n

set ns [new Simulator]

$ns set-address 7 24 ;# set-address <bits for node address> <bits for port>

# set up colors for nam

for {set i 1} {$i <= 30} {incr i} {

set color [expr $i % 6]

if {$color == 0} {

$ns color $i blue

} elseif {$color == 1} {

$ns color $i red

} elseif {$color == 2} {

$ns color $i green

} elseif {$color == 3} {

$ns color $i yellow

} elseif {$color == 4} {

$ns color $i brown

} elseif {$color == 5} {

$ns color $i black

}

}

# Create nam trace and generic packet trace

$ns namtrace-all [open out.nam w]

# trace-all is the generic trace we've been using

$ns trace-all [open out.tr w]

create_topology

########################### Modify From Here #####################

## Number of Pages per Session

set numPage 10

set httpSession1 [new HttpSession $ns $numPage [$ns picksrc]]

set httpSession2 [new HttpSession $ns $numPage [$ns picksrc]]

## Inter-Page Interval

## Number of Objects per Page

## Inter-Object Interval

## Number of Packets per Object

## have to set page specific attributes before createPage

## have to set object specific attributes after createPage

$httpSession1 setDistribution interPage_ Exponential 1 ;#in sec

$httpSession1 setDistribution pageSize_ Constant 1 ;# number of objects/page

$httpSession1 createPage

$httpSession1 setDistribution interObject_ Exponential 0.01 ;# in sec

$httpSession1 setDistribution objectSize_ ParetoII 10 1.2 ;# number of packets

# uses default

$httpSession2 createPage

$ns at 0.1 "$httpSession1 start" ;# in sec as well

$ns at 0.2 "$httpSession2 start"

$ns at 30.0 "finish"

proc finish {} {

global ns

$ns flush-trace

puts "running nam..."

# exec to run unix command

exec nam out.nam &

exit 0

}

# Start the simualtion

$ns run

# Created by Polly Huang

# Simple 4-node star topology

# 8 7 2 3

# \ | | /

# 9 -- 1 ----- 0 -- 4

# / | | \

# 10 11 6 5

proc create_topology {} {

global ns n num_node

set num_node 12

for {set i 0} {$i < $num_node} {incr i} {

set n($i) [$ns node]

}

$ns set src_ [list 2 3 4 5 6]

$ns set dst_ [list 7 8 9 10 11]

# EDGES (from-node to-node length a b):

$ns duplex-link $n(0) $n(1) 1.5Mb 40ms DropTail

$ns duplex-link $n(0) $n(2) 10Mb 20ms DropTail

$ns duplex-link $n(0) $n(3) 10Mb 20ms DropTail

$ns duplex-link $n(0) $n(4) 10Mb 20ms DropTail

$ns duplex-link $n(0) $n(5) 10Mb 20ms DropTail

$ns duplex-link $n(0) $n(6) 10Mb 20ms DropTail

$ns duplex-link $n(1) $n(7) 10Mb 20ms DropTail

$ns duplex-link $n(1) $n(8) 10Mb 20ms DropTail

$ns duplex-link $n(1) $n(9) 10Mb 20ms DropTail

$ns duplex-link $n(1) $n(10) 10Mb 20ms DropTail

$ns duplex-link $n(1) $n(11) 10Mb 20ms DropTail

$ns duplex-link-op $n(0) $n(1) orient left

$ns duplex-link-op $n(0) $n(2) orient up

$ns duplex-link-op $n(0) $n(3) orient right-up

$ns duplex-link-op $n(0) $n(4) orient right

$ns duplex-link-op $n(0) $n(5) orient right-down

$ns duplex-link-op $n(0) $n(6) orient down

$ns duplex-link-op $n(1) $n(7) orient up

$ns duplex-link-op $n(1) $n(8) orient left-up

$ns duplex-link-op $n(1) $n(9) orient left

$ns duplex-link-op $n(1) $n(10) orient left-down

$ns duplex-link-op $n(1) $n(11) orient down

}

# end of create_topology




 

 


 

6. Hot Links

¡Û VINT Project Home Page: http://netweb.usc.edu/vint

¡Û NS Home Page: http://www-mash.cs.berkeley.edu/ns

¡Û NS Installation: http://www-mash.cs.berkeley.edu/ns/ns-build.html

¡Û NS Documentation: http://www-mash.cs.berkeley.edu/ns/ns-documentation.html

¡Û NS Manual Page (very out of date): http://www-mash.cs.berkeley.edu/ns/ns-man.html

¡Û NS CVS history (directory structure): http://www-mash.cs.berkeley.edu/cgi-bin/cvsweb

¡Û NS Class Hierarchy: http://www-sop.inria.fr/rodeo/personnel/Antoine.Clerget/ns

¡Û5th VINT/NS Simulator Tutorial/Workshop: http://www-mash.cs.berkeley.edu/ns/ucb-tutorial.html

¡Û Tcl/Tk Quick Reference Guide: http://www.slac.stanford.edu/~raines/tkref.html

¡Û OTcl Tutorial (Berkeley Version): http://bmrc.berkeley.edu/research/cmt/cmtdoc/otcl

¡Û OTcl Tutorial (MIT Version): ftp://ftp.tns.lcs.mit.edu/pub/otcl/README.html

¡Û Guide to awk: http://www.canberra.edu.au/~sam/whp/awk-guide.html

¡Û GNU Plot: http://shazam.econ.ubc.ca/gnuplot.html

¡Û XGraph: http://jean-luc.ncsa.uiuc.edu/Codes/xgraph

¡Û Network Animator (NAM): http://www-mash.cs.berkeley.edu/nam/nam.html

 

contribution : Rahul Pradhan - SRM Example