[Ns-developers] Spectrum Framework: generating waveforms after reading a packet
Giuseppe Piro
g.piro at poliba.it
Sat Jan 7 09:41:51 PST 2012
Hi Lalith,
thanks a lot for the feedback
2012/1/7 Lalith Suresh <suresh.lalith at gmail.com>
> On Sat, Jan 7, 2012 at 5:10 PM, Giuseppe Piro <g.piro at poliba.it> wrote:
> > Hi all,I'm writing a new module in which the PHY layer, based on the
> > spectrum framework, is able to generate a waveform for each bit that
> should
> > be transmitted.
> > In details, once the PHY layer has received the packet from upper layers,
> > it reads the packet "bit-per-bit", thus creating, for each of them, a
> > proper SpectrumSignalParameters object that will be sent to the channel.
> >
> > Unfortunately, I don't know how reading, bit-per-bit, the packet.
> >
>
> You can convert the packet to a byte array (if I recall correctly, it
> was something like Packet::CopyData()), then iterate over the byte
> array, and for each iteration (each byte, basically), use a bitmask to
> extract an individual bit and generate a waveform for it.
>
Supposing that the waveform is created by the GeneratePulse function it the
bit is equal to 1, the code should be similar to the following, right ?
bool
ClassName::StartTx (Ptr<Packet> p)
{
uint8_t *buffer;
p->CopyData (buffer, p->GetSize ());
Time time = Seconds (0.);
for (uint32_t i = 0; i < p->GetSize (); i++)
{
Time time = Seconds (0.);
uint8_t byte = buffer[i];
for (uint8_t bit = 0; bit < 8; bit++)
{
if (((byte >> bit) & 1) == 1)
Simulator::Schedule (time, &ClassName::GeneratePulse,
this);
time += m_pulseInterval;
}
}
return true;
}
bool
>
> > Then, when a PHY entity will receives a sequence of waveforms, it have to
> > re-build the packet. How ?
> >
>
> At the receiver end, you'll need to do the reverse of the above. Get a
> group of 8 bits, turn it into a byte, and keep repeating till you have
> the whole set of bytes that make up the packet. When done, use
> Create<Packet>(byte_array, len) to create a packet out of those bytes.
>
> > Please, can anyone help me to address this task ?
> >
> > Thanks a lot
> >
> >
> > --
> >
> > Giuseppe Piro
>
>
>
> --
> Lalith Suresh
> www.lalith.in
>
--
Giuseppe Piro
More information about the Ns-developers
mailing list