Just another WordPress.com site

Posts Tagged ‘mac in ns2

making simulation speedy and mac layer understanding

leave a comment »

from http://www.cs.binghamton.edu/~kliu/research/ns2code/index.html#Eclipse

Understanding the implementation of IEEE MAC 802.11 standard in NS2

Download the document http://www.cs.binghamton.edu/~kliu/research/ns2code/note.pdf

  • How to scale your simulation to more nodes (500 nodes) and speed  it up ?

    The implementation of the Packet data structure of NS2 does not match the realities. The packet in ns2 simulation keeps all packet headers for any protocols implemented in NS2. For example, a DSR routing packet may keep DSDV, AODV, or even a PING application header. For this reason, till today, a packet used in ns2 simulation, would have a header size around 40~64KB. And NO packet would be deleted to release the memory it holds until the end of the simulation.
    So for a typical simulation with 100 nodes in ns2 around 1M packets exchanged (of course, you may reuse the packets already being freed throughPacket::free(Packet*). To learn the implementation of it, please check file common/packet{.h,.cc} ), you may hold 10% of it, 100K packets, and you may use a memory at least 100K*64KB -> 6.4GB, which definitely would crash your computer (even it is a super server).
    So How you can do it? And how you can run a simulation like 500 nodes there? You have 2 ways to do:

    • Suggested by ns2 manual, putting the below codes in your tcl script
      	add-packet-header DSR ARP LL MAC CBR IP

      to simulation a CBR application on UDP with DSR as routing protocol in a wireless ad hoc network (OOPS!, UDP is not a header. This method is effective, but it requires you to understand most packets header you need.

    • Another way is my way, changing the tcl library for the packet headers. You may find the tcl library file for packet headers in ns2/tcl/lib/ns-packet.tcl, you may find a procedure starting as foreach prot {. You can comment out all the headers you don’t recognize, like all the Routing protocols you dont know, all Routers, all Multicast, all Transport Protocols except you need, all application layer protocols, some of the Wireless, some of theMobility, Ad-Hoc Networks, Sensor Nets and all the Other. Finally, you may just have all the below left
      foreach prot { # Common: Common Flags IP # Transport Protocols TCP # Wireless ARP LL Mac # Mobility AODV } { add-packet-header $prot }

      If you are creating your own packet header, put them here.
      Typically, after this way, you may just have a packet size as 256B. So even you have 500 nodes, and 10M packets need to be exchanged during the simulation. You just need 256MB (if 10% packets held) for it, which is lower than any common configuration of current PCs.

Written by umairahmedshah

July 8, 2011 at 12:03 PM