WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2008-Nov-05 09:01:00

vinkolar
Member
Registered: 2008-Aug-03
Posts: 1

Forwarding packet through ethernet

Hi,

  There is a small glitch in function warpmac_startEmacXmitGeneric() in the file warpmac.c. When we attempt to transmit a packet through EMAC, the current code does wait to see if the existing ethernet transmission is complete. This does not happen very often since the time-gap between generation of two ethernet packets (generally done in WARP when a packet is received over air) is big enough to flush the XEMAC tx buffer. However, if the time gap is small (e.g.: you are generating additional ethernet packets at receiver), the code fails to send the packet to the host computer. But startEmacXmitGeneric() still returns a success return-value. A busy wait can fix this.

Existing code is

Code:

  if (XEmacLite_mIsTxDone(BaseAddress)==TRUE) {
     // Send the packet through ethernet
  }
  return XST_SUCCESS;

I have currently changed it to

Code:

// Busy wait loop till we get hold of txbuffer
while (!(XEmacLite_mIsTxDone(BaseAddress)));

// Send the packet through ethernet
return XST_SUCCESS;

Do you see any obvious, but severe, side-effects of doing this?

-Vinay

Offline

 

#2 2008-Nov-05 09:36:51

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

Re: Forwarding packet through ethernet

Your suggested fix is a good one. We actually stumbled across the same issue for a different application that also required generating Ethernet frames locally. We wrote the new WARPMAC function warpmac_sendRawEthernetPacket(), which behaves exactly as you described- waiting for the EMAC to finish sending a frame before attempting to send another.

Offline

 

#3 2010-Aug-08 21:52:11

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Murphypo,

I really wish to create my own packet which contains the BER and PER information and use warpmac_sendRawEthernetPacket() to send my packet via Ethernet to my PC to print out the statistics. ( According to some other posts, I think using Ethernet is my best shot.) However, I can't fine this function in either WarpMac.c in XPS folder or in the above link. Could you provide this function to me?

Another question is about how to create the custom packets. After reading couple of posts, I think there are two ways to do that:
1) Use memcpy() to copy whatever data directly to the packet buffer(pktBuf_tx_DATA, for example). However, if my packet is very large(say 1470 byte Ethernet packet), can I still use memcpy() without degrading the performance?
2) The second way is to create a custom packet in the PC and first use EMAC to transmit it to FIFO and then use DMA to move the data to the Tx buffer. I'm not sure whether my understanding about this is correct. In this way, which software should I use to generate custom packet and call EMAC driver to transmit the generated packet to the FIFO?
By the way, is there a way to directly generate a custom packet in a buffer? Actually, the BRAM is divided into 32 sub-buffers. According to the most updated CSMA, buffer 0, 1, 2 are occupied for Rx, Tx and Ack. Can I directly write a packet(say I create a char string) to another buffer(buffer 4, for example) and use DMA to move it to buffer 1(tx buffer) to transmit later?

Thanks a lot,

Tan

Offline

 

#4 2010-Aug-08 21:56:51

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Murphypo,

I really wish to create my own packet which contains the BER and PER information and use warpmac_sendRawEthernetPacket() to send my packet via Ethernet to my PC to print out the statistics. ( According to some other posts, I think using Ethernet is my best shot.) However, I can't fine this function in either WarpMac.c in XPS folder or in the above link. Could you provide this function to me?

Another question is about how to create the custom packets. After reading couple of posts, I think there are two ways to do that:
1) Use memcpy() to copy whatever data directly to the packet buffer(pktBuf_tx_DATA, for example). However, if my packet is very large(say 1470 byte Ethernet packet), can I still use memcpy() without degrading the performance?
2) The second way is to create a custom packet in the PC and first use EMAC to transmit it to FIFO and then use DMA to move the data to the Tx buffer. I'm not sure whether my understanding about this is correct. In this way, which software should I use to generate custom packet and call EMAC driver to transmit the generated packet to the FIFO?
By the way, is there a way to directly generate a custom packet in a buffer? Actually, the BRAM is divided into 32 sub-buffers. According to the most updated CSMA, buffer 0, 1, 2 are occupied for Rx, Tx and Ack. Can I directly write a packet(say I create a char string) to another buffer(buffer 4, for example) and use DMA to move it to buffer 1(tx buffer) to transmit later?

Thanks a lot,

Tan

Offline

 

#5 2010-Aug-09 15:48:29

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

Re: Forwarding packet through ethernet

You can easily send arbitrary Ethernet packets from a node using these functions:

Code:

	warpmac_prepPktToNetwork((void *)pktPtr, pktLen);
	warpmac_startPktToNetwork(pktLen);

These replace warpmac_sendRawEthernetPacket() (if you look at the old source code, warpmac_sendRawEthernetPacket() was a line-for-line copy of the functions above, just using a pointer instead of a packet buffer index).

1) It depends on where in your code you do it. In the good header handler, for example, there's a "bubble" in the pipeline between the good header event and the good/bad payload event. The length of this idle time depends on the packet length, of course. But for long packets, there's plenty of time to construct and send an Ethernet frame before good/bad payload asserts.

2) You can definitely use the other packet buffers for arbitrary Ethernet stuff. We do this extensively for more complicated MAC designs and for WARPnet stuff (for constructing statistics packets before sending them to the server). Just be careful to keep track of which buffers contain what packets in software; the hardware doesn't provide any coordination of occupied/vacant buffers.

Offline

 

#6 2010-Aug-09 19:36:08

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Murphypo,

Thanks for your reply! For (2), what do you mean by arbitrary ethernet stuff? If I want to send some meaningful data like a char string, how to put it into those packet buffers?

Also, is the Ethernet header used in Warp node the same as the common Ethernet header and the PC can directly receive the custom Ethernet packet created by me(just like communications between 2 PCs with a Ethernet cable)?

Another question is about CSMA.c code. In the timer_callback() function, once the BACKOFF_Timer is out, the transmitter will immediately send the packet. I think it should first sense the channel. If there are some packets flowing in the channel, it should back off again. What do you think?

Thanks again,

Tan

Last edited by tan (2010-Aug-09 19:39:14)

Offline

 

#7 2010-Aug-10 05:17:04

Christian
Member
Registered: 2010-Feb-26
Posts: 124

Re: Forwarding packet through ethernet

If you construct an ethernet packet on the warp node on your own you have to make sure that its content complies to the respective rules (e.g. TCP, IP checksums are calculated correctly, or that you do a htons etc. where necessary).

Furthermore, you should take care of the size of the ethernet packet you're about to construct. If you send only small amount of information in the body part of the ethernet packet, then you can definitely use a simple memcpy to move the information from your code to the emac pkt buffer. But if you use really long packets (1000bytes++) you should consider using DMA to copy around the packet content. On the other hand, if you want to send a large packet but you only change a small fraction of it every time you can create a template in one of the pkt buffers, then memcpy your information to the correct location within this buffer, and then tell the EMAC to use this pkt buffer instead of the default one:

Code:

//...
warpmac_prepPktToNetwork((void *)warpphy_getBuffAddr(templateBufferID)+NUM_HEADER_BYTES, length);
//...

Offline

 

#8 2010-Aug-10 15:04:16

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Christian,

Thanks for your reply! This does help a lot.

One more question:

If I want to initialize pktBuf_tx_DATA() with some specific content for wireless transmission, what should I do?

I think if I just want to transmit a single packet over the air and measure the performance, I can use memcpy() to copy the data(say char string) into pktBuf_tx_DATA() and then call dataFromNetworkLayer_callback() to transmit the data over the air, right? What if my payload is very long(>1000bytes)? If I still want to create a custom packet in CSMA code and transfer it to tx_buffer, how to do that? I don't think I can use DMA to move my packet generated in the code to the packet buffer based on the previous posts...

Also, if I want to transmit several packets during the run-time, can I generate my data() on a PC and send it through Ethernet to WARP board via a socket just like common Ethernet communication?

Thanks,

Tan

Offline

 

#9 2010-Aug-11 04:32:46

Christian
Member
Registered: 2010-Feb-26
Posts: 124

Re: Forwarding packet through ethernet

==
Side note regarding general data packet transmission:
The WARP node takes whatever packet comes from the ethernet port, encapsulates it with a WARP MAC header, sends it over the air according to the employed MAC protocol, removes the WARP mac header, and forwards it to the other station.
==

When sending a data packet you have to distinguish between two cases:
(1) You are sending a packet to a PC: You have to make sure that the data packet complies to the TCP/UDP, IP, ETH rules (checksums, header layout, packet ids, etc.). To send a packet to a PC, it is usually easier to use (forward) a packet sent from a PC attached to the source WARP node.
(2) You want to send a packet only to the WARP node: You can send arbitrary information from one node to the other since the destination node will most likely not forward this data packet to the PC, but just uses it to collect some other implicit information (timing, channel estimates, PER, BER).

If you want to send a packet to a PC and if you want the source/destination WARP node to modify the packet content (add some measurement results), you can:
- either create a packet entirely from scratch (no need for an attached source PC), or
- in a setup phase in the very beginning, you send a series of "template packets" from the PC to the node which then stores them in different pktBuffers (later on, modify parts of it on the WARP node, and then send it), or
- send a packet directly from a source PC to the destination PC and modify it "on the fly" on the warp nodes.

In either case, you have to implement kind of a bufferID management on the WARP nodes, and you have to make sure that (1) is fulfilled.


PS: regarding DMA:
I experimented a little bit with my WARP boards with DMA (waitForDMA before and after the copy process) and memcpy:
a) Copying from a 1000B char array to another took:
- 24us with DMA
- 94us with memcpy
b) Same setup with 1500B:
- 33us with DMA
- 143us with memcpy

Whereas DMA has another advantage: your code could do other stuff while the content is copied (except directly modifying/working with the source or destination memory), while the memcpy is a blocking call. The severity of the copy-process length (timing sensitivity) depends on your code / mac protocol, meaning that one mac protocol might be able to tolerate another 140us delay while another might not.

Offline

 

#10 2010-Aug-11 16:29:58

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Christian,

Thanks for your further reply! This answers lots of my doubts. I think my situation is to send a packet and want the source/destination WARP node to modify the packet content. Also, I wish to"- send a packet directly from a source PC to the destination PC and modify it "on the fly" on the warp nodes."
Actually, what I want is pretty straightforward. I just want to generate a Ethernet packet(with 1470 byte payload). The payload content should be initialized by some of my data instead of random. Then I want to send one packet at a time from a Warp node and receive it on another Warp node. After the Rx node receives the packet, it will forward whatever data received to the PC. Then I want to compare the tx packet and rx packet(packet actually received) to calculate BER. I wrote some scripts to calculate BER and other measurements; however, I'm not sure how to create the packet and let the tx node send it and how to gather the received packet and send it to the PC on the rx part.

Could you provide more detailed information about what function I should use to achieve this(like dataFromNetwork())?

Thanks a lot,

Tan

Offline

 

#11 2010-Aug-11 23:32:14

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

Re: Forwarding packet through ethernet

We just posted OFDM Reference Design v15.0, with includes support for the WARPnet Measurement Framework I mentioned earlier. One of the examples shows how to run a real-time BER test using dummy packet mode as the data source, with the Tx and Rx nodes sending their packets via Ethernet for BER processing. We're still working on the documentation, but the code is ready to use. Getting the WARPnet server running will take a little effort (it's all Python, and has a few dependencies), but it's definitely worth it if you're looking to run real-time experiments.

p.s. I created a guest account with write permissions to the Trac wiki (user/pass = guest/warpWiki). If you give the framework a try and notice something missing from the docs, please feel free to update it directly. We've been working on this code for a while, and I'm sure we've forgotten some of the steps we followed to get it up and running.

Offline

 

#12 2010-Aug-12 00:03:04

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Hi Murphypo,

Thanks for your reply!

I have three questions.

1) For design v15.0, does it support 64QAM for video streaming? I wish to test my modification in 64QAM as well.

2) Since I'm not familiar with Python, can I send the packet received in the rx node to PC through Ethernet cable and compare the bit error rates off-line on the PC(instead of a Warp server)? For now, my initial goal is to send one packet at a time and measure both average PER and BER and plot them according to different gain of the channel...

Thanks,

Tan

Last edited by tan (2010-Aug-12 00:18:04)

Offline

 

#13 2010-Aug-12 00:21:37

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

Re: Forwarding packet through ethernet

I honestly haven't tested 64-QAM in the v15 PHY. I've tested QPSK and 16-QAM at length (v15 is actually a snapshot of the project I'm using to run experiments for a paper), and they work fine.

In our BER testing example, the Tx and Rx nodes both send their packets via Ethernet to a programming running on a PC, the ber_processor. This app compares the packets, calculates the numbers of bits received and in error, then sends this calculation to the WARPnet server for logging. The Tx node generates its own packets using WARPMAC's dummy packet mode and the PHY's random payload generator.

Offline

 

#14 2010-Aug-12 00:39:25

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Ok. I will give it a try. Let me see what i can find.

Tan

Offline

 

#15 2010-Aug-13 17:32:47

tan
Member
From: UW Madison
Registered: 2010-May-25
Posts: 81

Re: Forwarding packet through ethernet

Sorry. I wrongly copied my posts twice. Please delete them...

Tan

Offline

 

Board footer