Transmitting an Ethernet Frame

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Transmitting an Ethernet Frame

1,553件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Tue Mar 01 12:17:39 MST 2011
Hi,
I am trying to send an Ethernet frame to my computer using the following code
//Dest MAC = 00:22:19:F5:E3:22
//Source MAC = 06:05:04:03:02:01
unsigned char first [] = {0x00,0x22,0x19,0xF5,0xE3,0x22,    0x06,0x05,0x04,0x03,0x02,0x01,    0x05,      0x46,0x49,0x52,0x53,0x54};

    Init_EthMAC();

    RequestSend(0x05);                              //Length of the data "first"
    CopyToFrame_EthMAC(first,5);
I  am not able to get the frame in the WireShark program or a C# program  using PCapDotNet library, so I think it is safe to conclude that the  frame is not being transmitted.
Is this code not correct? What should be modified / added?
The SystemInit is induced with CMSIS.And also the hardware is fine as EasyWeb example runs properly.
Thanks in advance,
Prithvi
0 件の賞賛
返信
7 返答(返信)

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Thu Mar 03 03:15:37 MST 2011

Quote:
Hell, no :)

It can be found in the RDB1768cmsis_uIP example:
main/lpc1700/lpc17xx_emac.c
main/lpc1700/lpc17xx_emac.h    

Thanks Jharwood. I'll dig into that.
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Wed Mar 02 16:11:28 MST 2011

Quote: Prithvi

Also I could not find the function EMAC_SendPacket() in ethmac.c. Did you write it yourself?



Hell, no :)

It can be found in the RDB1768cmsis_uIP example:
main/lpc1700/lpc17xx_emac.c
main/lpc1700/lpc17xx_emac.h
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Mar 02 13:09:22 MST 2011

Quote: Prithvi
The frame transmission is still not perfect.



Working here perfect :)
 
1. Don't step, set breakpoints :mad:

2. Use a 1 sec loop and repeat one frame

3. Restart WireShark
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Wed Mar 02 12:31:31 MST 2011
Guys, I appreciate all the help that you have given me. The frame transmission is still not perfect. I am confused of what's happening. :confused:
My code is as follows:
int main(void) {
    
    unsigned char first [] = {0x00,0x21,0x70,0x7D,0x3A,0x88,0x06,0x05,0x04,0x03,0x02,0x01,
0x00,0x05,'f','i','r','s','t'};
    unsigned char second [] = {0x00,0x21,0x70,0x7D,0x3A,0x88,0x06,0x05,0x04,0x03,0x02,0x01,
0x00,0x06,'s','e','c','o','n','d'};
    unsigned char third [] = {0x00,0x21,0x70,0x7D,0x3A,0x88,0x06,0x05,0x04,0x03,0x02,0x01,
0x00,0x05,'t','h','i','r','d'};

    Init_EthMAC();

    RequestSend(19);
    CopyToFrame_EthMAC(first,19);

    RequestSend(20);
    CopyToFrame_EthMAC(second,20);

    RequestSend(19);
    CopyToFrame_EthMAC(third,19);

    while(1) {

    }
    return 0 ;
}
My observations are as follows:
1. No frame gets captured (on WireShark) when I run the code in the debug window by pressing the resume button (F8)
2. When I run the code by stepping over all the functions then three frames get transmitted.
a. The first frame starts with 00 21 70 7d 3a 88 06 05  04 01 00 followed by 00s.
b. The second frame is as expected with a 'W' at the end (after the 'd' of second)
c. The third frame is as expected.

What should I infer from this? Why is the code behaving differently when stepping over and running it normally? Why is the first frame sent incorrectly when stepping over?
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Wed Mar 02 04:47:49 MST 2011

Quote:

Is there anything else that I am doing wrong?



Yes, stop copying, start thinking :mad:

James showed you an Ethernet-Frame. So just use EasyWeb and Wireshark captures it :eek:
unsigned char test_frame [] = {0x00,0x22,0x19,0xF5,0xE3,0x22,0x06,0x05,0x04,0x03,0x02,0x01,0x00,0x05, 'h','e', 'l', 'l','o'};
Init_EthMAC();
printf("Transmit Frame\n");
RequestSend(19);
CopyToFrame_EthMAC(test_frame,19);
printf("...done\n");
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Prithvi on Tue Mar 01 21:24:27 MST 2011
Hey thanks. I've corrected the two thing that you mentioned, but to no avail. I still did not receive the frame in the computer.
Also I could not find the function EMAC_SendPacket() in ethmac.c. Did you write it yourself? Is there anything else that I am doing wrong?
0 件の賞賛
返信

1,532件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by jharwood on Tue Mar 01 15:01:31 MST 2011
The 13th and 14th bytes of an ethernet frame are the length/type field. And I suspect that you need to make the EthMac calls with the full length of the frame, not just the payload size.

    unsigned char first [] = {0x00,0x22,0x19,0xF5,0xE3,0x22,
            0x06,0x05,0x04,0x03,0x02,0x01, 0x00,0x05, 'h','e', 'l', 'l','o'};

    EMAC_SendPacket(first, 19);

0 件の賞賛
返信