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 !

Advertisements

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