Hello everybody,
I'm developing a 802.11 frame generator, but I'm having some difficulties.
That generator must creates frames like Traffic Generator class, but without
pass to Routing Layer and transmissions are only single hop, like DumbAgent
class.
I've created a class FrameGenerator that inherits from Connector. I also
consider a timer (TimerHandler), to schedule events:
FrameGenerator :: FrameGenerator() : Connector(), timer_(this)
In tcl, I create two FrameGenerator atributes and attach them to the nodes.
One node will send frames and another node will receive frames. Later,
FrameGenerator atributes are connected:
# Creating FrameGenerator atribute to send frames
set fg [new Mac/FrameGenerator]
$ns_ attach-agent $node_($src) $fg
# Creating FrameGenerator atribute to receive frames
set null [new Mac/FrameGenerator]
$ns_ attach-agent $node_($dst) $null
# Connecting atributes
$ns_ connect $fg $null
# Idle time transmission
$fg setIdleTime $idle_time_
# Start time transmission
$fg setStart $start_time
# Stop time transmission
$fg setStop $stop_time
To send frames, class FrameGenerator calls send() method. That method
allocates memory to one packet and calls method schedule() passing the
parameters, NSObject target_ (a Connector's class attribute), the packet and
the delay time:
void FrameGenerator :: send(double time)
{
Packet *p = this->allocpkt();
Scheduler::instance().schedule(target_, p, time);
this->send_frames_++;
}
However, just a few packets arrive in recv() method and routing protocol
tries to create a route between src and dst nodes.
To allocate packets, method send() calls method allocpkt():
Packet* FrameGenerator :: allocpkt()
{
Packet *p = Packet::alloc();
struct hdr_cmn *ch = HDR_CMN(p);
struct hdr_mac802_11* mac_h = HDR_MAC802_11(p);
hdr_ip* iphdr = hdr_ip::access(p);
iphdr->dst_.addr_ = (u_int32_t)(this->dst_);
iphdr->src_.addr_ = (u_int32_t)(this->src_);
ch->direction() = hdr_cmn::DOWN;
// ch->addr_type() = NS_AF_ILINK;
ch->addr_type() = NS_AF_INET;
ch->next_hop_ = this->dst_;
ch->last_hop_ = this->dst_;
ch->num_forwards() = 0;
ch->size() = 1000;
STORE4BYTE(&this->dst_, (mac_h->dh_ra));
STORE4BYTE(&this->src_, (mac_h->dh_ta));
return p;
}
I don't know if this way is correct. My idea is to create a class that
communicates directly with Link Layer without pass to Routing Layer.
Thanks.
Urlan