Tag Archives: network simulator

Collection of NS2 Reading Material [Tutorials and Documents] – Wired and Wireless

Hi Folks,

In this post i am posting a sea of (network simulator) NS2 reading material (files and resources) that i have collected over the years. Many of us researchers usually face the problem of finding good reading material on ns2 and usually just type ns2 in Google and hourly browse through hundreds of links that Google shows up. That may prove fruitful although its tiring and agonizing. (I have done that quite a lot now). Also we search for problems being faced by us when we carry out simulations and in the end we find no solutions. (NS2 problems will be like that for many years to come. 😦 ) As far as NS2 is concerned my personal experience is that you are on your own.

This post would somewhat enthrall you and you might eventually like it as it contains lots of reading materials and resources that could be of much help to budding researchers like me in the field of networking. This is just a small effort from my side to the little known NS2 Research Community.

Please leave comments, suggestions, and an encouraging word of thanks in the comments.

CATEGORY I) Learning NS2 (Tons of Introductory Tutorials and Presentations)

1. http://www.mediafire.com/view/3grw7npzv4arnj7/NS2_Exercises.pdf
2. http://www.mediafire.com/view/3grw7npzv4arnj7/NS2_Exercises.pdf
3. http://www.mediafire.com/view/ak2haa67o899yka/NS2_Source_Code_Analysis_Method.ppt
4. http://www.mediafire.com/view/8s3via5iw119hyi/Network_Simulation_and_Protocol_Implementation_Using_Network_Simulator_2.pdf
5. http://www.mediafire.com/view/k8gdmh2byer8b1s/Simulating_Networks_with_Network_Simulator_NS2.pdf
6. http://www.mediafire.com/view/wmxyf3emuib30kc/NS2_Tutorial_Part_II_-_Inteface_OTCL_Linkage.pdf
7. http://www.mediafire.com/view/6ycwpxrfnjeazee/NS2_Laboratory_-_Professor_Chansu_Yu.pdf
8. http://www.mediafire.com/view/di5vwln85cd3gat/ns2_for_the_Impatient.pdf
9. http://www.mediafire.com/view/qdwx2ghrdfm5zhd/NS_Tutorial_-_Padma_Haldar.ppt
10. http://www.mediafire.com/view/kcdbt9u9qv84icb/Wireless_world_in_NS.pptx
11. http://www.mediafire.com/view/0big047k7cbo3t3/Network_Simulator_Version_2_-_Abu.doc
12. http://www.mediafire.com/view/bdomhdewwi4k8bc/ns2_Tutorial_-_Haobo_Yu,_Nader_Salehi.pdf
13. http://www.mediafire.com/view/rw1yt9dqt3t5qpy/NS2_Tutorial_-_Sung_Park.pptx
14. http://www.mediafire.com/view/umi8ui999z3d77q/ns2_Tut.pdf
15. http://www.mediafire.com/view/tqy99nihjs0vhu5/Report_On_NS2.doc
16. http://www.mediafire.com/view/tqy99nihjs0vhu5/Report_On_NS2.doc
17. http://www.mediafire.com/view/yu5e8udx47isut0/Using_NS2.pdf
18. http://www.mediafire.com/view/u0vll0pgm73ffvk/Extensions_to_NS2_-_Notes_and_Documentation.pdf
19. http://www.mediafire.com/view/qxsdbv7e113zxgz/Introduction_to_ns2_-_Donald_C_Wunsch.pdf
20. http://www.mediafire.com/view/jal0eomo2xlk4dz/Marc_Greis_Tutorial.pdf
21. http://www.mediafire.com/view/pd04i7k1ktrwihe/NS2_Workshop.ppt
22. http://www.mediafire.com/view/43r77l1nsecg6cn/Intro_to_ns2__-_Gayatri.ppt
23. http://www.mediafire.com/view/my1cr878twyewoy/The_Network_Simulator_NS2_-_Claudia_Canali.pdf
24. http://www.mediafire.com/view/0o2yhxvb41u6n4b/NS_Internals.ppt
25. http://www.mediafire.com/view/b41kdglhubdcbp7/NS_Training_Course_-_ns_modules_-_Chau_Chi_Wang.pdf
26. http://www.mediafire.com/view/5alciaxhi0153eq/ns2_Laboratory_-_Chanso_Yu.pdf
27. http://www.mediafire.com/view/mntojpd59m3ahp4/3rd_NS2_Simulator_Workshop.pdf
28. http://www.mediafire.com/view/q80rwswwig46t47/NS_By_Examples.pdf
29. http://www.mediafire.com/view/g4ban3kiwbr6b4y/Introduction_to_Network_Simulator_-_Giovani_Neglia.pdf
30. http://www.mediafire.com/view/zxx77zilbmsnksc/NS2_Tutorial_-_Michael_Welzi.pdf
31. http://www.mediafire.com/view/96rd4e2h9952vk0/ns2_Tutorial_-_institut_fur_Telematik.pdf
32. http://www.mediafire.com/view/fgo0b09bcdcomhh/NS2_Tutorial_-_Chi_Heng_Ke.pptx
33. http://www.mediafire.com/view/sw60it08h6i1dia/NS2_Fundamentals.pdf
34. http://www.mediafire.com/view/vhbfdwyenceikyw/An_Introduction_to_NS,_NAM_and_OTCL_-_Paul_Meeneghan_and_Declan_Delaney.pdf
35. http://www.mediafire.com/view/9958z37icc6uhnl/Design_and_simulation_of_Network_Using_NS2.pdf
36. http://www.mediafire.com/view/7o8afovbnkrn17n/NS-2_Introduction_-_Bahador_Bakshi.pdf
37. http://www.mediafire.com/view/7opg8nz45dyqeco/Network_Simulator_-_Integrated_Communication_Systems_Group.pdf
38. http://www.mediafire.com/view/2vlqlqrly2s9l0k/How_to_use_ns2_-_Jae_Pil_Yoo.pdf
39. http://www.mediafire.com/view/aljlsmlu2zxz2so/Network_Performance_and_NS2_-_Mohammed_M_Kadhun.pdf
40. http://www.mediafire.com/view/tm7ep912y1d2sk2/ns2_Tutorial_-_Kameswari_Chebrolu.pdf
41. http://www.mediafire.com/view/ng4xzwsbsq4fydq/ns2_Simulator_for_Beginners.pdf
42. http://www.mediafire.com/view/n0bm6uh1abcf5pg/NS2_Tutorial.pdf
43. http://www.mediafire.com/view/8ja111fzd16w1zi/The_ns_manual.pdf
44. http://www.mediafire.com/view/854k7ck6bn4q8tp/IPAM_Tutorial_-_Network_Modeling_and_Traffic_Analysis_with_ns2.pdf
45. http://www.mediafire.com/view/3y16z7w4cx1dp9i/NS2_Introduction_-_Osman_Ghazali(2).pdf
46. http://www.mediafire.com/view/lbj2q4t4t9fw5t2/Wireless_world_in_NS2_-_Padma_Haldar.pdf

CATEGORY II) Reading Material on OTcl and Tcl Languages

1. http://www.mediafire.com/view/93fxhj23f8x3v5h/Interpreted_C++,_Object_Oriented_Tcl,_What_Next.pdf
2. http://www.mediafire.com/view/ap5eedimlscvdmt/Overloading_Comparison_Operators.pdf
3. http://www.mediafire.com/view/a2h1aqnxa33b1vo/TCP_Performance_Simulations_Using_ns2.pdf
4. http://www.mediafire.com/view/t4lxst4mh3wwsev/OTcl_-_Object_Tcl_Extensions.pdf
5. http://www.mediafire.com/view/vprs8t8zm0qe4c0/Tcl_Fundamentals.pdf
6. http://www.mediafire.com/view/u9ix6kp5van32dy/Introduction_to_MIT_Object_Tool_Command_Language_(OTCL)_Part_1.pdf
7. http://www.mediafire.com/view/80u028i48tq7233/Introduction_to_OTcl_1.pdf
8. http://www.mediafire.com/view/jdvp0hk4tkn0wf3/Tcl_and_ns2_Tutorial_Outline_OTcl_Basics.pdf
9. http://www.mediafire.com/view/zk5hbdgxx9d17v8/IEEE_802.11b_Ad_Hoc_Networks_-_Performance_Measurements.pdf
10. http://www.mediafire.com/view/p6m8xkg0j07k71w/TCL_OTCL.pdf
11. http://www.mediafire.com/view/t3ydkox86bbmqky/An_Introduction_to_NS,_Nam_and_OTcl_scripting.pdf
12. http://www.mediafire.com/view/3qubmw6m3599c9v/OTcl_-_The_User_Language.pdf
13. http://www.mediafire.com/view/cqf03edf73grkkm/Tcl_Basics.pdf
14. http://www.mediafire.com/view/14hz9ru2yeqs3j0/TCL_%26_OTCL.pdf
15. http://www.mediafire.com/view/o00157ttco35hi0/Practical_Programming_in_Tcl_and_Tk.pdf
16. http://www.mediafire.com/view/a8875v058butojp/Tcl_and_OTcl_for_ns.pdf
17. http://www.mediafire.com/view/vmkdgrs1xi5zco4/Objects_in_TCL.pdf
18. http://www.mediafire.com/view/1eg59u199e992ln/tcl_objects.pdf
19. http://www.mediafire.com/view/y3kbfxncfofyyzu/TclTk_Integration.pdf
20. http://www.mediafire.com/view/s949uv2mthbbely/Tcl_Tk_-_A_Developer’s_Guide.pdf

CATEGORY III) Reading Material on Perl and Awk Scripting Languages

1. http://www.mediafire.com/view/armp5z7biteorb6/Awk_Cheat_Sheet.pdf
2. http://www.mediafire.com/view/armp5z7biteorb6/Awk_Cheat_Sheet.pdf
3. http://www.mediafire.com/view/armp5z7biteorb6/Awk_Cheat_Sheet.pdf
4. http://www.mediafire.com/view/djqc59am0a6fc40/Learn_Perl_by_Examples_-_Perl_Handbook_for_Beginners_-_Basics_of_Perl_Scripting_Language.pdf
5. http://www.mediafire.com/view/px4bbrd31ii9nez/A_Quick,_Painless_Introduction_to_the_Perl_Scripting_Language.pdf
6. http://www.mediafire.com/view/qs5mx7mzos9317a/The_Awk_manual.pdf
7. http://www.mediafire.com/view/a5sm1k24ej0cdzo/Effective_Awk_Programming.pdf
8. http://www.mediafire.com/view/3n5zhicunp5xngk/Perl_Tutorial_for_Beginners.pdf
9. http://www.mediafire.com/view/g26q3frpsdjmzwh/Learning_Perl_-_O_Reilly.pdf
10. http://www.mediafire.com/view/rh7nxiphm4iwr76/Perl_5_Tutorial_-_1st_Edition.pdf

CATEGORY IV) NS2 Reading Material on Wireless Simulations and MANETs

1. http://www.mediafire.com/view/a4lds3w4p2962w9/NS2_Wireless_Simulation_Tutorial_-_Zhibin_Hu.pdf
2. http://www.mediafire.com/view/w5vv75272q3p7sz/Radio_Propagation_Models_Implemented_in_NS2.pdf
3. http://www.mediafire.com/view/o84fi16fi65j11j/Simulation_of_Networks_of_Queues_in_NS2.pdf
4. http://www.mediafire.com/view/tkbtfp2mizdfrdu/Effects_of_Detail_in_Wireless_Network_Simulation.pdf
5. http://www.mediafire.com/view/n3jelnj2o80mfo9/MANET_Extensions_to_NS2.pdf
6. http://www.mediafire.com/view/kngl9liwqnmdr16/New_Implementation_in_ns2_for_wireless_routing.pdf
7. http://www.mediafire.com/view/tm49gbxdso1g4wm/NS2_Tutorial_-_Wireless_Network_Lab.pdf
8. http://www.mediafire.com/view/53qkvdd23z6zqwr/Directed_Diffusion_for_Wireless_Sensor_Networking.pdf
9. http://www.mediafire.com/view/81at8tdfwgkbmc5/A_Survey_of_Network_Simulators_Supporting_Wireless_Networks.pdf
10. http://www.mediafire.com/view/2g1849e04geuadu/Design_and_Simulation_of_Wireless_Network_using_NS2.pdf
11. http://www.mediafire.com/view/d2heucd213mq8xq/NS2_Tutorial_-_Running_Simulations_-_Mathias.pdf
12. http://www.mediafire.com/view/p74wkc6g64rsc61/AdHoc_Networking_-_Christian_Bettsetter.pdf

CATEGORY V) NS2 Tutorials and Reading Material on Implementing Ad Hoc Routing Protocols in MANETs

1. http://www.mediafire.com/view/mnujyehjd7ff3vn/Sample_Coding_Wireless_NS2.docx
2. http://www.mediafire.com/view/s9plgl7rocbkpg8/Implementing_a_Routing_Agent_with_manually_configured_routing_table_(Static_Table).pdf
3. http://www.mediafire.com/view/r84smueu0rwe4m7/How_to_implement_protocol_in_NS2_-_Shi_Feng_Yan.pdf
4. http://www.mediafire.com/view/r7g8ulgr2uo7iub/Analysis_of_DSR_in_ns2.pdf
5. http://www.mediafire.com/view/d99yemfp29w9fm9/Simulation_of_MANET_Routing_Protocols.pdf
6. http://www.mediafire.com/view/vs32ypkg5sdx43o/Implementing_a_MANET_Unicast_Routing_Protocol_for_MANETs.pdf
7. http://www.mediafire.com/view/7ca1rs2uzoqrwez/A_Tutorial_on_the_Implementation_of_AODV_protocol_in_NS2_-_Mubashir_Husain_Rehmani.pdf
8. http://www.mediafire.com/view/8zo9vb0341p6wn4/TCP_over_Ad_hoc_networks.pdf
9. http://www.mediafire.com/view/owv51txu105q1d9/Implementation_and_Performance_Evaluation_of_MFlood_Protocols_for_Wireless_Ad_Hoc_Networks.pdf
10. http://www.mediafire.com/view/owv51txu105q1d9/Implementation_and_Performance_Evaluation_of_MFlood_Protocols_for_Wireless_Ad_Hoc_Networks.pdf
11. http://www.mediafire.com/view/nq3x73kbrnnucj1/An_Overview_of_MANETs_Simulation.pdf
12. http://www.mediafire.com/view/kb2vj7wpu1e5dj3/Implementing_GPSR_routing_protocol.pdf
13. http://www.mediafire.com/view/fzqjftfii4di3pu/Tutorial_for_Simulation-based_Performance_Analysis_of_MANET_Routing_Protocols_in_ns-2_-_Kartik.doc
14. http://www.mediafire.com/view/64b05satg1300jy/How_to_Add_a_New_Protocol_in_NS2_-_Xu_Leiming.ppt
15. http://www.mediafire.com/view/r5dx1ir4u1fgtg8/Design_Routing_Protocol_Performance_Comparison_in_ns2_-_AODV_comparing_to_DSR_as_Example.pdf
16. http://www.mediafire.com/view/hy2qhqh41lgw2ay/Porting_AODVUU_Implementation_to_NS2_and_Enabling_Trace_Based_Simulations.pdf
17. http://www.mediafire.com/view/uie4di69lqpf6du/Performance_Analysis_of_Reliable_Multicast_routing_protocols.pdf
18. http://www.mediafire.com/view/caryqtwb33yjd6t/On_Demand_Routing_in_Multihop_wireless_mobile_ad_hoc_networks.pdf
19. http://www.mediafire.com/view/dn01puy5okws0ol/Performance_Evaluation_of_Ad_Hoc_Routing_Protocols.doc
20. http://www.mediafire.com/view/fg2ac65tdk6ugvq/MANET_Implementation_and_Test_-_Jaehoon_Jeong.pdf
21. http://www.mediafire.com/view/6z0arhz5y2qc299/Inspect_-_A_Visual_and_Analysis_for_NS2_Wireless_Simulations.pdf
22. http://www.mediafire.com/view/kbn2f94t8bc4889/Mobile_Ad_Hoc_Network_Routing_Protocols_-_Methodologies_and_Applications.pdf
23. http://www.mediafire.com/view/37ste5ym1f3dc6c/Temporaly_Ordered_Routing_Algorithm.pdf
24. http://www.mediafire.com/view/8zat9z37x48eibv/Introduction_to_Geographic_Greedy_Forwarding.pdf
25. http://www.mediafire.com/view/k1k9nhhgf9yt7eb/Survey_of_Routing_Protocols_in_Wireless_Body_Sensor_Networks.pdf

CATEGORY VI) NS2 Tutorials and Material on 802.11 Interface

1. http://www.mediafire.com/view/mur276gx5367rq5/Wireless_Routing_in_NS2.pdf
2. http://www.mediafire.com/view/a148kxg7l9c1gqt/Effects_of_Detail_in_Wireless_Network_Simulations.pdf
3. http://www.mediafire.com/view/1xmfino42djv0n1/Understanding_the_Implementation_of_IEEE_802.11_Standard_in_NS-2_-_Ke_Liu.pdf
4. http://www.mediafire.com/view/5ftc1lz3dxw37xm/Simulate_802.11b_within_NS2_-_Wu_Xiuchao.pdf
5. http://www.mediafire.com/view/h5rnc2mbjb7j9fg/A_Tutorial_of_802.11_Implementation_in_ns2_-_Yue_Wang.pdf
6. http://www.mediafire.com/view/dycvfhsstnwb6wn/A_Tutorial_on_Wireless_Implementation_in_ns2.pdf
7. http://www.mediafire.com/view/4v98nai3ljaqipv/Realistic_802.11b_in_ns2_(Simulation_vs_Real).pdf
8. http://www.mediafire.com/view/cysv4y4l71msw3r/IEEE-802.11_Overview_-_Mustafa_Ergen.ppt
9. http://www.mediafire.com/view/smv0k45qr56f57q/Basic_802.11_Statistics_-_Evan_Jones.pdf
10. http://www.mediafire.com/view/45p83tqcuk7iwep/NS2_Module_for_IEEE_802.22_Standard.pdf
11. http://www.mediafire.com/view/kx9l0lf2pkwxvm7/ANSI_IEEE_Std_802.11.pdf
12. http://www.mediafire.com/view/2i0yl855q5idq0a/Adding_Multiple_Interface_Support_in_NS2.pdf
13. http://www.mediafire.com/view/97o14958iha21ah/Simulation_of_Wireless_Multi-_Networks_in_NS-2.pdf

CATEGORY VII) NS2 Tips and Tricks (My Favorite 🙂 )

1. http://www.mediafire.com/view/dkh5djq1xqw8ahm/How_to_change_transmiision_range_in_NS2.pdf
2. http://www.mediafire.com/view/mj6615qba6zka93/Improvements_on_MAC_802-11_simulation.pdf
3. http://www.mediafire.com/view/37157by3g3h7ybg/Learning_Timers_NS2.pdf
4. http://www.mediafire.com/view/adnjo27v9e64nrq/Pedro_Vale_Estrela_-_Assorted_NS2_Tips.pdf
5. http://www.mediafire.com/view/3nauc6666m39fuc/Simulate_Random_MAC_Protocol_in_NS2_(Part_I).pdf
6. http://www.mediafire.com/view/uvumf7dk4jjo2je/Simulate_Random_MAC_Protocol_in_NS2_(Part_II).pdf
7. http://www.mediafire.com/view/c9cb79obrx1joab/Simulate_Random_MAC_Protocol_in_NS2_(Part_III)_-_Pearls_in_Life.pdf
8. http://www.mediafire.com/view/oqn7ncylyh327a2/Simulate_Random_MAC_Protocol_in_NS2_(Part_IV).pdf
9. http://www.mediafire.com/view/k37pvk4y9y9qi4s/Cross_Layer_Access_in_NS2.pdf
10. http://www.mediafire.com/view/3369jfcr9bu0jfq/Turn_off_ARP_in_ns2.pdf
11. http://www.mediafire.com/view/idcakr7irci8r8g/Kie_Liu’s_NS2_Code.pdf
12. http://www.mediafire.com/view/dy9cccs55tmk417/Routing_Performance_Analysis_from_Trace_Files.pdf
13. http://www.mediafire.com/view/bjav6m2mx58507k/Timer_Usage.pdf
14. http://www.mediafire.com/view/1ws1o8st66tbwga/Enhanced_Carrier_Sensing_ns2.pdf
15. http://www.mediafire.com/view/in4din9q451nnfa/Turn_off_energy_log_in_ns2.pdf
16. http://www.mediafire.com/view/qdjvl3mmm32c7qe/Understanding_Headers_and_Addresses_in_ns2.pdf
17. http://www.mediafire.com/view/ebchhqbgs9xn7n5/Adding_new_application_and_agent.doc
18. http://www.mediafire.com/view/zu99seoyud6r77v/How_to_-_Wireless_Network_Emulation_Using_ns2_and_User_Mode_Linux.pdf
19. http://www.mediafire.com/view/xcih8h8oo7lmvdc/Timers.pdf
20. http://www.mediafire.com/view/62vr7ncz0lna16n/ns2_Adding_Modules.pdf
21. http://www.mediafire.com/view/f7u045e13ly49e5/Energy_model_update_in_NS-2.pdfhttp://www.mediafire.com/view/f7u045e13ly49e5/Energy_model_update_in_NS-2.pdf
22. http://www.mediafire.com/view/f9an42la2sx3avz/Myth_of_Power_Control_in_Routing.pdf
23. http://www.mediafire.com/view/sh3l01u6y5powk7/Timers_ns2.pdf
24. http://www.mediafire.com/view/vyx7k3lcqhu7w17/Finding_Node_Position,Velocity_and_Speed_in_NS2.34_Mano.pdf
25. http://www.mediafire.com/view/a5m9yk4wkf6zaaz/NS2_Simple_Method_to_Analyze_Traces_-_Causal_Nexus.pdf
26. http://www.mediafire.com/view/567gj7rjx1ugq66/How_to_get_Neighbor_Nodes_of_a_Mobile_Node_in_Wireless_Simulations.pdf
27. http://www.mediafire.com/view/pgvmmjw58fx16lm/Routing_Table_Print_in_AODV.pdf
28. http://www.mediafire.com/view/8i13xwyhseevlle/NS2_SetDest_Acceleration_Enhancement.pdf
29. http://www.mediafire.com/view/lwh59dx1rnl5bqy/Improvements_on_MAC_802.11_Simulation_when_link_loss_ration_or_contention_is_considered.pdf
30. http://www.mediafire.com/view/1bhq4b5gyp12j1r/Obtaining_Node_Position_and_Energy_Dynamically_in_ns2.pdf
31. http://www.mediafire.com/view/woktraus2d2yx3u/Timer_Usage_in_ns2.pdf
32. http://www.mediafire.com/view/locmlkm8lxymoso/How_to_Recompile_Network_ns2.pdf
33. http://www.mediafire.com/view/oe2cbwwix8x860v/ECS_-_An_Enhanced_Carrier_Sensing_Mechanism_in_ns2.pdf
34. http://www.mediafire.com/view/h57yiso5ezah41n/Dynamic_Transmission_Power_Control_in_ns2.pdf
35. http://www.mediafire.com/view/p80lbtsib834nq7/How_to_patch_GPSR_routing_to_ns-2.34_-_Page_2.pdf
36. http://www.mediafire.com/view/gaednxjkk18l8nt/How_to_patch_GPSR_routing_to_ns-2.34_-_Page_3.pdf
37. http://www.mediafire.com/view/lbjh55hm3ho5m8y/Bryan’s_NS-2_Dynamic_Source_Routing_FAQ.pdf

CATEGORY VIII) NS2 Miscellaneous Reading Material

1. http://www.mediafire.com/view/3y75e86vej79hmp/xgraph_utitlity_of_ns2(2).pdf
2. http://www.mediafire.com/view/aqzc6u7gm4uz9hs/Integration_of_NS_BGP_with_NS-2.34(2).pdf
3. http://www.mediafire.com/view/qcw3j0nca1y0j39/Using_Ns2(2).doc
4. http://www.mediafire.com/view/12zlrnvqint08pj/Trace_Analyzer_for_NS-2(2).pdf
5. http://www.mediafire.com/view/mbasaywr7e9qccy/Using_NSG_Wired(2).doc
6. http://www.mediafire.com/view/ejeaxfiweheftbq/BonnMotion_Docu(2).pdf

I shall strive to keep on updating this list as soon as I stumble upon new material. I shall constantly update this list. If you have any other document related to ns2 which u need to share (please do not hide any document if you have downloaded it from the internet) please post it in the comments.

Expand this list as much as possible and lets help each other !!.

Disclaimer: All these files are not mine and i have just collected them from the internet. If you have any issues regarding this post or any material that has been uploaded just throw a comment and i shall remove that link.

Understanding BSD Linked List used in AODV routing protocol in ns2.34

Hello Folks, It’s been a long time since i posted. i had been studying the AODV routing protocol and am still trying to make it energy aware. Most of the people who are reading this post must already know about BSD linked list. This list is under the directory /ns-2.34/lib/bsd-list.h. It contains few macros for defining a doubly linked list that is used in AODV for maintaining routing tables, precursor lists, neighbor caches and Broadcast ID cache.

I searched a lot trying to understand the aodv code but the usage of bsd-list was a major hindrance in understanding it. Even after a lot of searching i could not find good material to read as it involved complex use of pointers. In the end I studied the bsd-list.h and few help from the internet I was able to relate how things are actually working. In this post I would explain the working of BSD list and how it actually works. I would not go into the inner details as the macros defined do most of the functionality themselves therefore studying them in huge detail becomes irrelevant. And yes this post would assume that you first go and read about pointers and try implementing a singly linked list and a doubly linked list on your own in C++. (Believe me that would really help).

The source files needed for this program can be downloaded from here:

Step 1) bsd-list.h contains the following macros

#define LIST_HEAD(name, type) \
struct name { \
type *lh_first; /* first element */ \
}

#define LIST_ENTRY(type) \
struct { \
type *le_next; /* next element */ \
type **le_prev; /* address of previous next element */ \
}

#define LIST_INIT(head) { \
(head)->lh_first = NULL; \
}

#define LIST_INSERT_AFTER(listelm, elm, field) { \
if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \
(listelm)->field.le_next->field.le_prev = \
&(elm)->field.le_next; \
(listelm)->field.le_next = (elm); \
(elm)->field.le_prev = &(listelm)->field.le_next; \
}

#define LIST_INSERT_BEFORE(listelm, elm, field) { \
(elm)->field.le_prev = (listelm)->field.le_prev; \
(elm)->field.le_next = (listelm); \
*(listelm)->field.le_prev = (elm); \
(listelm)->field.le_prev = &(elm)->field.le_next; \
}

#define LIST_INSERT_HEAD(head, elm, field) { \
if (((elm)->field.le_next = (head)->lh_first) != NULL) \
(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
(head)->lh_first = (elm); \
(elm)->field.le_prev = &(head)->lh_first; \
}

#define LIST_REMOVE(elm, field) { \
if ((elm)->field.le_next != NULL) \
(elm)->field.le_next->field.le_prev = \
(elm)->field.le_prev; \
*(elm)->field.le_prev = (elm)->field.le_next; \
}

Now i will give a certain example to understand the working of the above bsd-list.

Step 2) First of all create a .cpp file with the name workingbsdlist.cpp and inside the same directory copy the file bsd-list.h from /ns-2.34/lib/bsd-list.h directory.

The code for workingbsdlist.cpp is as follows (u can always copy paste)

#include
#include
#include"bsd-list.h"

using namespace std;

struct foo {
int a;
LIST_ENTRY(foo) pointers; // pointers is the object of the structure generated by List Entry
}*temp, *var, *ptr;

LIST_HEAD(foo_list, foo);

int main(void)
{
LIST_HEAD(foo_list, foo) head;
LIST_INIT(&head);

struct foo *item1 = new foo;
struct foo *item2 = new foo;
struct foo *item3 = new foo;
item1->a = 60;
item2->a = 120;
item3->a = 240;
LIST_INSERT_HEAD(&head, item1, pointers);
LIST_INSERT_AFTER(item1, item2, pointers);
LIST_INSERT_BEFORE(item2, item3, pointers);
//Displaying inner details of list
{
cout<<"HEAD's Address : "<<head.lh_first<<endl;
cout<<"Item 1 next value : "<pointers.le_next<<endl;
cout<<"Item 1 prev value : "<pointers.le_prev<<endl;
cout<<"HEAD's Address : "<<head.lh_first<<endl;
cout<<"Item 2 next value : "<pointers.le_next<<endl;
cout<<"Item 2 prev value : "<pointers.le_prev<<endl;
cout<<"HEAD's Address : "<<head.lh_first<<endl;
cout<<"Item 3 next value : "<pointers.le_next<<endl;
cout<<"Item 3 prev value : "<pointers.le_prev<pointers.le_next)
{
cout<a<<endl;
}
return (0);
}

Although the above example may be quite vague and non-coherent but it is good for an intermediate C++ programmer to learn.

Step 3) Now i shall explain each and every line of this program and how it uses the bsd-list.h header file to create a doubly linked list. Once u understand this it becomes very easy to understand code in aodv.cc

Firstly we create a structure named as foo and within it we declare a variable a.
Within the structure we call the macro using

LIST_ENTRY(foo) pointers;

Seeing the macro in bsd-list.h. This expands to the following (keep watching closely)

struct foo {
int a;
struct { // This is a nameless structure within a structure
struct foo *le_next; // pointer to structure foo
struct foo **le_prev; // pointer to a pointer that points to structure foo
} pointers; // structure variable of nameless structure
}*temp, *var, *ptr; // pointers to structure foo

Then we call the another macro in bsd-list.h as:

LIST_HEAD(foo_list, foo);

This expands to the following code:

struct foo_list // A new structure with the name foo_list that holds pointer to struct foo
{
foo *lh_first; //pointer to struct foo
}

Now in the main() function we call the same macro LIST_HEAD but this time an variable is also created for the structure foo_list. See below.

LIST_HEAD(foo_list, foo) head;

expands to

struct foo_list // A new structure with the name foo_list that holds pointer to struct foo
{
foo *lh_first; //pointer to struct foo
}head;

In the next statement another macro is called

LIST_INIT(&head);

This macro call expands to
(head)->lh_first = NULL;

This is same as head->lh_first = NULL, and it puts the value of the pointer lh_first to NULL. But see one thing the *lh_first is declared inside struct foo_list so it can only be accessed by variables of foo_list. Thus we can access it using head. Thus we write head->lh_first = NULL. This also means that the head element currently will point to NULL.

Next we declare 3 generate 3 new nodes item1, item2, item3 which are actually pointers to struct foo. We enter info in their variable a using item1->a = 60; etc.

Now we shall use the three macros that actually define the insertion operations. U do not need to study the internal details of these three macros. They shall do as they say. For example

The first macro we use is to insert at the head of the list.
LIST_INSERT_HEAD(&head, item1, pointers);

seeing this macro in bsd-list.h we have
#define LIST_INSERT_HEAD(head, elm, field)
This macro takes three arguments
1. address of head (remember that head initially points to nothing because we set its value to NULL initially).
2. node that you want to insert (item1, item2, item3 etc).
3. field which is structure variable of the nameless structure that resulted on macro expansion

The other two items are after and before that are defined in bsd-list.h as
#define LIST_INSERT_AFTER(listelm, elm, field) {....}
#define LIST_INSERT_BEFORE(listelm, elm, field) {....}

They take three arguments.
1. First argument is the listelm after or before which u want to insert.
2. Node which u want to insert such as item1, item2 etc.
3. field which is a structure variable of nameless structure defined above (pointers in our ex)

Similarly the remove macro. It becomes very easy to use and understand if above two are clear.

Then we display some inner details of the list and variables. Usually to see how addresses are used and nodes are referenced. What values are stored in next and prev. What are their addresses. Have we achieved success.

In the end we print all the elements of the list. This is a tricky for loop to understand and is quite different from the conventional method. Remember this for loop can be written in two ways. I shall explain both of them so that u do not face any difficulty when u see them in AODV code in ns-2.34.

1st One)

ptr = head.lh_first;
for(;;ptr = ptr->pointers.le_next)
{
cout<a<<endl;
}

First ptr is a pointer to struct foo. We want it to point to head of the list. And head is pointed to by lh_first. So we make it point using ptr = head.lh_first. (u should understand why we used head.lh_first).
This for loop will check for ptr is not equal to NULL and it will be incremented every time by
ptr = ptr->pointers.le_next.
Remember ptr is pointer variable of struct foo. And by definition we will have to use -> sign to access le_next. But le_next is inside a nameless structure whose variable is pointers.
Thus we write ptr = ptr->pointers.le_next.

2nd One) It is similar to earlier one except
for(;ptr;ptr = ptr->pointers.le_next)
This is one more method to access or traverse the list. This will check till ptr has a valid value or not.

Hope u understand this. And if any queries arise please feel free to ask.

Note:- These are my own views and I am not a professional C++ programmer. Some things may have totally different interpretations when seen by different experienced programmers. If i am wrong somewhere please correct it and accept my apologies.

[AWK Script] An Awk Script to Print Network Statistics

Image

Hi Folks,

In this post I, shall give u an awk file I wrote that prints several network statistics of interest (these are of course the basic ones cuz i ain’t that good at statistics). Being fed up with lots of awk files floating on the net and most of them don’t work or work on old trace formats of ns-2.34. So I planned to write my own awk script for my simulations.

[ AWK FILE SCRIPT DOWNLOAD]

This awk script i wrote is for 50 nodes and by minor modifications it can be changed to any no. I have used it for 150 nodes. The statistics u can calculate with this file are:

  • Total Packets Sent
  • Total Packets Received
  • Total Packets Dropped
  • Total Packets Forwarded
  • Packet Delivery Ratio %
  • The total hop counts are
  • Average Hop Count
  • Routing Overhead
  • Normalized Routing Load
  • Througphut of the network (KBps)
  • Average End to End Delay
  • Total Energy Consumed
  • Protocol Energy Consumption

Some of these metrics I have calculated using the above shown image. However energy consumption metrics have been calculated by me. When u run this awk script using the command :

awk -f statistics.awk xyz.tr   (xyz.tr is your trace file name)

statistics.awk creates 5 files (which contain info related with each node) in your directory they are:

  • energyleft.txt
  • pktdrop.txt
  • pktfwd.txt
  • pktrecvd.txt
  • pktsent.txt

Note:- This statistics.awk file was made for 50 nodes. However in the awk file i have put comments so as to where u need to make changes in order to run it for any number of nodes.

My view:- I wrote it according to my own logic and understanding however some logic may be wrong or may not be optimal or may be very time consuming. If any suggestions are there for improving this code. Please suggest. Thanks

Let’s support the research community by sharing our code and not hiding it.