What is PAMPA?

PAMPA (Power-Aware Message Propagation Algorithm) is a broadcast algorithm for mobile ad hoc networks (MANETS). Like broadcast algorithms described in [Tseng:02], [Haas:02] or [Huang:06], PAMPA tries to save resources of participants in MANETs by reducing the number of nodes that are required to retransmit a message so that it gets delivered to every node. The novelty of PAMPA is that the selection of the nodes that retransmit is based on the signal strength of the delivery while most of the remaining peek some nodes at random.

PAMPA was first presented in [Miranda:06]. A more complete survey on broadcast algorithms, a full description of PAMPA and extensive simulation results can be found in [Miranda:07].

PAMPA for ns-2


A prototype of PAMPA was developed for the ns-2 network simulator. The same code can also be used for testing other algorithms (see below the list of current algorithms). Here we describe the instructions for including PAMPA in ns-2. This procedure was experimented with a ns-2 allinone distribution v. 2.32. Previously I've followed the same exact set of procedures for setting it up on ns-2 v. 2.28. The instructions assume that you have some basic knowledge of C++, TCL and of the ns-2 so that you are able to determine the most adequate location of the patches. If necessary, send me an e-mail and I'll try to give some support.

  1. PAMPA uses the NO Ad Hoc routing agent so you must begin by setting up NOAH in ns-2.
  2. On ~ns-2, create a directory named pampa with files hdr_pampa.h, pampaagent.cc and pampaagent.h
  3. To create PAMPA's header type:
    • Add PT_PAMPA to the enum packet_t after the line with: // insert new packet types here
    • Add name_[PT_PAMPA]="pampa"; to the p_info() constructor
    Add PAMPA to the long list that follows foreach prot {
    Add pampa/pampaagent.o to OBJ_CC
  4. For setting up adequate output in the trace files (just for the CMU trace format)
    Add void format_pampa(Packet *p,int offset); to the declaration of class CMUTrace : public Trace
    • Add #include <pampa/hdr_pampa.h> to the list of included files
    • Append the following function:
      void CMUTrace::format_pampa(Packet* pkt,int offset) {
      hdr_pampa *pampahdr=hdr_pampa::access(pkt);
      sprintf(pt_->buffer() + offset,"-P pampa -Ps %d -Pi %d -Ps %d -Pt %g -Ph %d", pampahdr->source_,pampahdr->uid_,pampahdr->size_, pampahdr->timesent_,pampahdr->nHops_);
  5. run ./configure on ns-2 home
  6. run make

How to use it

Ideally, it should be possible to use the code for:

  1. testing the broadcast algorithms (or variants)
  2. broadcasting messages produced by other protocols

For now, the code is only ready for testing broadcast algorithms. I plan to extend it to address 2. in the near future. I'll raise the priority of this task on demand.

To test broadcast algorithms

Use test.tcl as an example. It is based on the tcl files used in the ns-2 distribution. In brief, the differences are:

The PAMPA agent accepts the following commands:

bcast <size>
Broadcast message of <size> bytes. You may find traffgen.c useful: it prints on stdout broadcast commands following some configurable pattern. Compile with -lpopt. Run with --help to see the arguments.
log-target <target>
Sets the target of the log information produced by the agent
dump-stats <target>
Dumps the stats locally collected by the agent to the log target <target>
The following determine the policy to be followed by the agent when deciding to forward messages
policy-nodelay <max jitter> <nodelay retransmit prob>
Probabilistic, in the line of [Haas:02] paper. Delay is dictated exclusively by a random value for jitter. Requires a jitter and a probability of forwarding
policy-pwr <max_rnd_delay> <pwr_retransmit_maxpwr>
Distance-based [Tseng:02a] scheme. Requires a max-delay and a power threshold.
policy-nmsgs <max_rnd_delay> <nmsgs_retransm_maxcnt>
Counter-based [Tseng:02a] scheme. Requires a max-delay and a number of messages threshold.
policy-delpwr <pwr_mul_factor> <delpwr_retransm_maxcnt>
Power-aware delay (i.e. PAMPA), Requires pwr multiplication factor and a number of messages threshold.
policy-bdelpwr <pwr_mul_factor> <delpwr_retransm_maxcnt> <max_delay> <max_jitter>
Power-aware with bounded delay (i.e. PAMPA). Requires pwr multiplication factor, number of messages threshold, upper maximum delay and maximum jitter (for maximum delay).
policy-hcab <max_rnd_delay>
HCAB [Huang:06] algorithm, which observes the TTL of the retransmissions. Requires a max-delay.

As is, test.tcl reads the policy and its arguments from the command line (-optpampa <policy> -optargs "<args>"). Note that arguments are passed as one unique argument so you must enclose them between "" either in the command line or in the test.tcl code. An example of a full command line for starting a simulation is: ns test.tcl -traf traffile -mov movfile -optpampa policy-delpwr -optargs "3e6 2". Arguments -traf and -mov accept two filenames with TCL code. The goal is to import "traffic" (e.g. as produced by traffgen) and "movement" (e.g. produced by setdest or BonnMotion) files but they can be used for any other purposes or even be empty files if there is nothing to set.

PAMPA for tinyOS

The source code of PAMPA for tinyOS is available here. It is released with GPL License 3.0. You may want to check the README file first.


Zygmunt J. Haas, Joseph Y. Halpern, and Li Li. 2002. Gossip-based ad hoc routing. Pages 1707-1716 of: Proceedings of the 21st annual joint conference of the IEEE computer and communications societies (INFOCOM 2002), vol. 3. IEEE.
Qing Huang, Yong Bai, and Lan Chen. 2006. Efficient lightweight broadcasting protocols for multi-hop ad hoc networks. In: Proceedings of the 17th annual IEEE international symposium on personal, indoor and mobile radio communications (PIMRC 06). Helsinki, Finland: IEEE, for University of Oulu.
Hugo Miranda, Simone Leggio, Luís Rodrigues and Kimmo Raatikainen. A Power-Aware Broadcasting Algorithm. In: Proceedings of the 17th annual IEEE international symposium on personal, indoor and mobile radio communications (PIMRC 06). Helsinki, Finland: IEEE, for University of Oulu.
Gossip-Based Data Distribution in Mobile Ad Hoc Networks. Hugo Miranda. November 2007. PhD Thesis. Technical Report DI/FCUL TR-07-33
Yu-Chee Tseng, Sze-Yao Ni, Yuh-Shyan Chen, and Jang-Ping Sheu. 2002. The broadcast storm problem in a mobile ad hoc network. Wireless networks, 8(2/3), 153-167.

Contact Info

This page is maintained by Hugo Miranda, University of Lisbon. E-mail:

Last updated Jan 18, 2012.