WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2009-Oct-13 04:55:45

hamid
Member
Registered: 2009-Oct-13
Posts: 2

Buffering ethernet packets

Hello,

I am trying to modify the NOMAC. I want to save the ethernet packets in an array. If 4 packets are saved, they should be transmitted one after each other. Here is the code I put into the emacRx_callback function:

Code:

Macframe txBuffer;
	
// copy payload to my array (dataBuffer)
memcpy( (void*) (dataBuffer + currentSize), (void *) payload, (size_t) length);
currentSize = currentSize + length;
// save the current length of the packet
frameLength[numberOfFrames] = length;
numberOfFrames++;
xil_printf("received data via ethernet ( %c )\r\n", numberOfFrames+48-1);
// BUFFERSIZE says how many packets to save in the array
if(numberOfFrames < BUFFERSIZE)
{
     return;
}
	
// we have x Frames
// the node will send one after the other
	
int i = 0;
unsigned int currentPosition = 0;
for( i=0; i<BUFFERSIZE; i++)
{
     xil_printf("sending frame %c \r\n", i+48);
     // copy from array into 
     memcpy( (void *) warpphy_getBuffAddr(1)+ NUM_HEADER_BYTES, (void *) dataBuffer + currentPosition, (size_t) frameLength[i] );
     txBuffer.header.length = frameLength[i];
     txBuffer.header.fullRate = HDR_FULLRATE_QPSK;
     txBuffer.header.codeRate = CODE_RATE_34;
     warpmac_prepPhyForXmit(&txBuffer, 1);
     warpmac_startPhyXmit(1);
     warpmac_finishPhyXmit();
     currentPosition += frameLength[i];
}
numberOfFrames = 0;
currentSize = 0;

However this doesn't work because at a certain point the warp board doesn't want to receive any ethernet packets. It just stops working. This happens as soon as the board receives a packet over phy.
My scenario is built up of two warp boards. One has the normal NOMAC on it while the other one uses this modified version. I am trying to stream/ping to the other computer. If I use my code but with BUFFERSIZE set to 1 (this means just save one packet) on both boards it works. Am I doing something wrong?
Thank you
Hamid

PS: Now I made some test. The programme gets into a never ending loop in the following loop:
while(state == INCOMPLETE)
   state = warpphy_pollRxStatus();
It doesn't leave this loop.

Last edited by hamid (2009-Oct-13 05:20:07)

Offline

 

#2 2009-Oct-13 20:45:28

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: Buffering ethernet packets

What version of the OFDM reference design are you working with? We recently posted v13.1, which includes the latest incarnation of noMac.c, along with some bug fixes in the PHY. It would be worth trying your modifications with this design.

Does your code work if you set BUFFERSIZE to 1, so its behavior mimics the unmodified noMac?

Where in memory is dataBuffer stored? There's probably not room in on-chip memory for the whole buffer, though the SRAMs should have lots of space.

Offline

 

#3 2009-Oct-23 11:48:54

hamid
Member
Registered: 2009-Oct-13
Posts: 2

Re: Buffering ethernet packets

thanks for your answer!

If I put the BUFFERSIZE to 1, everything works fine. So the problem arises as soon as I increase the BUFFERSIZE to 2 (or more).
As you already pointed out, I didn't make use of the SRAM. How could I allocate memory in SRAM? I tried it with malloc(...) however it was not possible to allocate memory. The pointer was always zero.

Any suggestions ?

Offline

 

#4 2009-Oct-25 20:32:25

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 5159

Re: Buffering ethernet packets

malloc doesn't work when there's no OS to manage memory. You can use the SRAMs in code, by accessing memory locations relative to each SRAM's base address (defined in xparameters.h, probably XPAR_SRAM0_ZBT_512KX32_MEM0_BASEADDR and XPAR_SRAM1_ZBT_512KX32_MEM0_BASEADDR). The heap/stack are probably assigned to one (check the linker script), but the other is free.

Offline

 

Board footer