Download Ns2.33-Antnet1.0 by Richardson Lima

Software implementations of AntNet posted by Gianni Di Caro

http://www.idsia.ch/~gianni/antnet.html

Lavina Jain made an implementation of AntNet for NS-2 (that can be also downloaded here). Starting from Jain’s code, Richardson Lima has released a revised and updated version of AntNet for NS-2.33. Since I’m not an NS-2 user, I haven’t checked these implementations, but I guess the Lima’s implementation can be used as a good starting point. If you plan to use Lima’s code, please feel free to contact me to check/improve the quality of the implementation.

Download Ns2.33-Antnet1.0 by Richardson Lima

http://www.foxylinux.com/ns2-33_AND_antnet1.0_by_RichardsonLima.tar.gz

My Twitter for support in realtime on AntNet Implementation

Hey there, Richardson Lima now is using Twitter !!!

I created my twitter ID to support real-time to the implementation of AntNet the simulator ns2.

Then visit  http://twitter.com/richardsonlima

Hope that I have helped.

Regards !

Ns-2.33 compiled with Antnet implemented

NEWS:

Currently many researchers are sending me emails reporting problems in the implementation antnet, with the support of 林木盛 Mu-Sheng Lin (user account and 500MB of space on FTP server), 林木盛 Mu-Sheng Lin is Ph.D candidate, Department of Electronic Engineering, National Taiwan University of Science and Technology, Taiwan, I am providing the link ftp://dp6.ykvs.tpc.edu.tw/pub/AntNet_On_Ns2/ns2-33_AND_antnet1.0_by_RichardsonLima.tar.gz , This package contains the Ns-2.33 compiled with Antnet implemented. To solve some problems in the implementation I am writing a second version of the manual for implementation of antnet in ns-2.33, I report some ‘tricks’. =)

Download the Antnet Algorithm

Download the Antnet Algorithm developed by Lavina Jain for the Ns-2.28 and modified for the Ns-2.33, currently I am working in this algorithm so that it works 100% identical to the proposal of Dr. Gianni Di Caro.

Click here to download.

Released the manual for implementation

Based on the manual written by Lavina Jain for the Ns-2.28, I launched the manual for implementation of AntNet altorithm for Ns-2.33.

Click here to download.

Hope that I have helped.

Regards,

antnet_rtable.h – Lavina’ s algorithm

// \file antnet_rtable.h

// \brief Definition file for routing table in AntNet

#ifndef __antnet_rtable_h__
#define __antnet_rtable_h__

#include <trace.h>
#include <map>
#include <string>
#include <vector>
#include <classifier-port.h>

#include <random.h>

#include “ant_pkt.h”
#include “antnet_common.h”

// \brief Represents an entry in routing table

// This structure represents pheromone value corresponding to a neighbor node

struct pheromone {
nsaddr_t neighbor; ///< address of neighbor node
double phvalue; ///< pheromone value
};

/// vector of pheromone values (represents entry in routing table corresponding to a destination)

typedef std::vector<struct pheromone> pheromone_matrix;
/// Routing table
typedef std::map<nsaddr_t, pheromone_matrix> rtable_t;
/// Vector of neighbors all having same and maximum pheromone value
typedef std::vector<nsaddr_t> sameph_t;

/////////////////////////////////////////////////////////////
/// \brief Class to implement routing table
/////////////////////////////////////////////////////////////

class antnet_rtable {
rtable_t rt_;   ///< routing table

RNG *rnum;      ///< random number generator
public:

/// Constructor
antnet_rtable() {
rnum = new RNG((long int)CURRENT_TIME);
}

/// Method to add an entry in routing table
// Parameters: destination node, neighbor node, pheromone value

void add_entry(nsaddr_t destination, nsaddr_t neighbor, double phvalue);
/// Method to print routing table
void print();
/// returns destination node for given source node
nsaddr_t calc_destination(nsaddr_t source);
/// returns next hop node for given source destination pair
// Parameters: source node, destination node, parent node

nsaddr_t calc_next(nsaddr_t source, nsaddr_t destination, nsaddr_t parent);
/// updates an entry in routing table
// Parameters: destination node, neighbor node

void update(nsaddr_t destination, nsaddr_t neighbor);
};

#endif

Destination – abstract !

antnet.cc:    dest = rtable_.calc_destination(addr());// generate random destination

antnet.cc:    ah->pkt_dst() = dest;            // set packet destination

antnet.cc:    ih->daddr() = next;        // set destination address in ip header

antnet.cc:        if(addr() == ah->pkt_dst()) {    // destination node

antnet.cc:        else {        // not destination node

antnet.cc:        if(addr() == ah->pkt_dst()) {    // destination node, travel complete

antnet.cc:        else {        // not destination node

antnet.cc:    ih->daddr() = next;    // set destination address in ip header

antnet.cc:/// called when forward ant reaches destination node

antnet.cc:    // swap source and destination address

antnet.cc:    ih->daddr() = ch->next_hop();    // destination address

antnet.cc:    ih->daddr() = ch->next_hop();    // destination addres

antnet.cc:        if(iterWin != window_.end()) {    // destination entry exists, add to it in window

antnet.cc:        else {    // destination entry does not exist, add new dest entry to window

antnet.cc:    // routing table is updated for all the destination nodes that are visited after the neighbor node

antnet.cc:    // update pheromone value corresponding to neighbor node and destination nodes visited thereafter

antnet.cc:        // read destination nodef rom memory

antnet.cc:        // update pheromone valu fro neighbor node and this destination node

antnet.cc:    // add destination entry for each node in topology

antnet.h:    window_t window_;    ///< window of trip times to all destinations

antnet_rtable.cc:/// – destination node

antnet_rtable.cc:    if(iterRt == rt_.end()) {    // destination entry not in rtable, add new entry

antnet_rtable.cc:    else {    // destination entry exists in rtable, add neighbor entry

antnet_rtable.cc:/// Method to return a randomly chosen destination for a source node

antnet_rtable.cc:nsaddr_t antnet_rtable::calc_destination(nsaddr_t source) {

antnet_rtable.cc:/// – destination node address

antnet_rtable.cc:    // find routing table entry for destination node

antnet_rtable.cc:        // read vector of pheromone values for the destination node

antnet_rtable.cc:/// – destination node address

antnet_rtable.cc:    // read ruoitng table entry for destination

antnet_rtable.h:/// vector of pheromone values (represents entry in routing table corresponding to a destination)

antnet_rtable.h:        // Parameters: destination node, neighbor node, pheromone value

antnet_rtable.h:        void add_entry(nsaddr_t destination, nsaddr_t neighbor, double phvalue);

antnet_rtable.h:        /// returns destination node for given source node

antnet_rtable.h:        nsaddr_t calc_destination(nsaddr_t source);

antnet_rtable.h:        /// returns next hop node for given source destination pair

antnet_rtable.h:        // Parameters: source node, destination node, parent node

antnet_rtable.h:        nsaddr_t calc_next(nsaddr_t source, nsaddr_t destination, nsaddr_t parent);

antnet_rtable.h:        // Parameters: destination node, neighbor node

antnet_rtable.h:        void update(nsaddr_t destination, nsaddr_t neighbor);

ant_pkt.h:    nsaddr_t pkt_dst_;    ///< address of destination node

Neighbors – abstract !

antnet.cc:extern int N; ///< number of neighbors of a node

antnet.cc: N = get_num_neighbors(node_addr);

antnet.cc: int num_nb = get_num_neighbors(node_addr);

antnet.cc: // read list of neighbors

antnet.cc:/// Method to print neighbors of a node

antnet.cc:Antnet::print_neighbors() {

antnet.cc:/// Method to add neighbors of a node

antnet_common.cc:/// Method to return number of neighbors of a node

antnet_common.cc:get_num_neighbors(nsaddr_t node_addr) {

antnet_common.h:/// Method to return number of neighbors of a node

antnet_common.h:int get_num_neighbors(nsaddr_t node_addr); Binary file

antnet.h: /// print neighbors of a node

antnet.h: void print_neighbors(); Binary file

antnet_rtable.cc:int N; ///< Number of neighbors of a node

antnet_rtable.cc: fprintf(stdout,”neighbors of %d:\t”,source);

antnet_rtable.h:/// Vector of neighbors all having same and maximum pheromone value scripts/

Simulation of ants looking for food

get hungry, out for food