Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - how to send packets over ethernet?: (18 Items)
   
how to send packets over ethernet?  
hi,

i looked around, read the most postings, but doesn't get my problem solved.

i just want to send (periodicaly) packets using the lan-port of my board (i.mx31). just to get it work and understand 
how ;)

could somebody please help me? i really didn't find a way for me in understanding that topic. i havn't done something 
with networks before.

maybe somebody can give some simple samplecode that helps me to understand what i have to do and how it works.

it would be great!

thanks a lot!
RE: how to send packets over ethernet?  
What kind of packets do you want to tx?  ie are
they IP or non-IP?  What is the ethertype?

--
aboyd
Re: RE: how to send packets over ethernet?  
type is normal ipv4
and it should be IP-packets
ie realize a simple ping
RE: RE: how to send packets over ethernet?  
From: Hannes Bock 

> ie realize a simple ping

The source to ping is under trunk/utils/p/ping
on the foundry.

Maybe also look at the source to ttcp?  It has
options for both tcp and udp.

You might want to look at some of these links:

http://www.google.ca/search?hl=en&q=socket+programming&meta=

--
aboyd
RE: how to send packets over ethernet?  
Hi Hannes:
	I think you have a bit of a steep learning curve ahead.  There
are two ways that are likely to be useful for you to use Ethernet.  One
is through Internet sockets. 
(see http://en.wikipedia.org/wiki/Berkeley_sockets)

The other is through our proprietary QNET protocol. 
(http://www.qnx.com/developers/docs/6.3.0SP3/neutrino/sys_arch/qnet.html
)

	Robert.


-----Original Message-----
From: Hannes Bock [mailto:community-noreply@qnx.com] 
Sent: Thursday, August 07, 2008 5:23 AM
To: general-networking
Subject: how to send packets over ethernet?

hi,

i looked around, read the most postings, but doesn't get my problem
solved.

i just want to send (periodicaly) packets using the lan-port of my board
(i.mx31). just to get it work and understand how ;)

could somebody please help me? i really didn't find a way for me in
understanding that topic. i havn't done something with networks before.

maybe somebody can give some simple samplecode that helps me to
understand what i have to do and how it works.

it would be great!

thanks a lot!

_______________________________________________
General
http://community.qnx.com/sf/go/post11514
Re: RE: how to send packets over ethernet?  
thanks for the links!

i think qnet is a little bit to powerfull for my purposes.
i'll try the udp "hello world"-example from wikipedia, this should be completely sufficiently.
is there anything to consider or to adapt for qnx?

thanks a lot for the help!
Re: RE: how to send packets over ethernet?  
hi,

i tried the "hello world"-udp example and it works fine ... but not for long :o(

after sending about 3000 packtets the bord hangs.
if I put a sleep(1) after sending the first packet i become the only packet which is send.

any idea what's the problem? maybe something with the buffers?

here ist the code:

void  myNetwork_thread ()
{
    int sock;
    struct sockaddr_in sa;
    int bytes_sent, buffer_length;
    char buffer[200];
    int pongcount=1;
    
    sprintf(buffer, "pingpong");
    buffer_length = strlen(buffer) + 1;
 
    sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(-1 == sock) /* if socket failed to initialize, exit */
    {
      printf("Error Creating Socket");
      /*return 0;*/
    }
    sa.sin_family = PF_INET;
    sa.sin_addr.s_addr = htonl(0xC0A81E86);
    sa.sin_port = htons(7654);
 
    printf("ping");
    
    while(1)
    {
       bytes_sent = sendto(sock, buffer, buffer_length, 0,(struct sockaddr*) &sa, sizeof(struct sockaddr_in) );
       if(bytes_sent < 0)
         printf("Error sending packet: %s\n", strerror(errno) );
       printf("pong %i\n", pongcount++);
      
    }
 
    close(sock); /* close the socket */
   return 0;
}
RE: RE: how to send packets over ethernet?  
From: Hannes Bock 

> after sending about 3000 packtets the bord hangs.

What network card / driver are you running?  What
is the nicinfo output?  Esp if you start the driver
with the verbose option, what is the sloginfo output?

--
Aboyd
Re: RE: RE: how to send packets over ethernet?  
> What network card / driver are you running?  What
> is the nicinfo output?  Esp if you start the driver
> with the verbose option, what is the sloginfo output?

i only used the bsp for my bord (i.mx31) and then tryed to build my application. i didn't start the driver specialy "by 
hand".

the output from nicinfo and sloginfo is attached

Attachment: Text nicinfo.txt 1 KB
RE: RE: RE: how to send packets over ethernet?  
From: Hannes Bock 

> the output from nicinfo and sloginfo is attached

That appears to be truncated - I don't see any
sloginfo output, and even the nicinfo output is
not complete.

But I do see that you are running the crys 8900
nic.  That driver has had numerous fixes over the
years, but I don't think was ever released.
  
Would you be interested in a test binary of a newer 
version?  What cpu (x86, ppcbe, etc) are you running
on?

--
aboyd
Re: RE: RE: RE: how to send packets over ethernet?  
it's an i.mx31 with an arm9 cpu

here the complete output:

nicinfo

Crystal 89xx Ethernet Controller

  Physical Node ID ........................... 00049F 00396B
  Current Physical Node ID ................... 00049F 00396B
  Current Operation Rate ..................... 10.00 Mb/s half-duplex
  Active Interface Type ...................... UTP
  Maximum Transmittable data Unit ............ 1514
  Maximum Receivable data Unit ............... 1514
  Hardware Interrupt ......................... 0xa8
  I/O Aperture ............................... 0xb4020300 - 0xb402031f
  Promiscuous Mode ........................... Off
  Multicast Support .......................... Enabled

  Packets Transmitted OK ..................... 90
  Bytes Transmitted OK ....................... 11155
  Memory Allocation Failures on Transmit ..... 0

  Packets Received OK ........................ 91
  Bytes Received OK .......................... 5752
  Memory Allocation Failures on Receive ...... 0

  Single Collisions on Transmit .............. 0
  Transmits aborted (excessnicinfo

Crystal 89xx Ethernet Controller

  Physical Node ID ........................... 00049F 00396B
  Current Physical Node ID ................... 00049F 00396B
  Current Operation Rate ..................... 10.00 Mb/s half-duplex
  Active Interface Type ...................... UTP
  Maximum Transmittable data Unit ............ 1514
  Maximum Receivable data Unit ............... 1514
  Hardware Interrupt ......................... 0xa8
  I/O Aperture ............................... 0xb4020300 - 0xb402031f
  Promiscuous Mode ........................... Off
  Multicast Support .......................... Enabled

  Packets Transmitted OK ..................... 36
  Bytes Transmitted OK ....................... 3730
  Memory Allocation Failures on Transmit ..... 0

  Packets Received OK ........................ 34
  Bytes Received OK .......................... 2149
  Memory Allocation Failures on Receive ...... 0

  Single Collisions on Transmit .............. 0
  Transmits aborted (excessive collisions) ... 0
  No Carrier on Transmit ..................... 0
  Receive Alignment errors ................... 0
  Received packets with CRC errors ........... 0
  Oversized Packets received ................. 0
  Short packets .............................. 0
  Squelch Test errors ........................ 0


# sloginfo

Time             Sev Major Minor Args
Jan 01 00:00:00    5    14     0 tcpip starting
Jan 01 00:00:00    3    14     0 Using pseudo random generator.  See "random" option
RE: RE: RE: RE: how to send packets over ethernet?  
From: Hannes Bock 

> it's an i.mx31 with an arm9 cpu

Is the driver devn-crys8900-mx31ads.so?

The output of "pidin -p io-net mem"
will tell the story ....

--
aboyd
Re: RE: RE: RE: RE: how to send packets over ethernet?  
it's rys8900-mx31ads.so

Attachment: Text pidin.txt 823 bytes
RE: RE: how to send packets over ethernet?  
Hmmm... You're probably filling the socket buffers, erroring out in the
sendto and putting yourself into a constant loop.  Add a sleep (or exit)
in to let the buffer drain (as below)


       if(bytes_sent < 0) {
         printf("Error sending packet: %s\n", strerror(errno) );
         sleep(2);
       }

  Robert.

-----Original Message-----
From: Hannes Bock [mailto:community-noreply@qnx.com] 
Sent: Thursday, August 21, 2008 6:54 AM
To: general-networking
Subject: Re: RE: how to send packets over ethernet?

hi,

i tried the "hello world"-udp example and it works fine ... but not for
long :o(

after sending about 3000 packtets the bord hangs.
if I put a sleep(1) after sending the first packet i become the only
packet which is send.

any idea what's the problem? maybe something with the buffers?

here ist the code:

void  myNetwork_thread ()
{
    int sock;
    struct sockaddr_in sa;
    int bytes_sent, buffer_length;
    char buffer[200];
    int pongcount=1;
    
    sprintf(buffer, "pingpong");
    buffer_length = strlen(buffer) + 1;
 
    sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
    if(-1 == sock) /* if socket failed to initialize, exit */
    {
      printf("Error Creating Socket");
      /*return 0;*/
    }
    sa.sin_family = PF_INET;
    sa.sin_addr.s_addr = htonl(0xC0A81E86);
    sa.sin_port = htons(7654);
 
    printf("ping");
    
    while(1)
    {
       bytes_sent = sendto(sock, buffer, buffer_length, 0,(struct
sockaddr*) &sa, sizeof(struct sockaddr_in) );
       if(bytes_sent < 0)
         printf("Error sending packet: %s\n", strerror(errno) );
       printf("pong %i\n", pongcount++);
      
    }
 
    close(sock); /* close the socket */
   return 0;
}

_______________________________________________
General
http://community.qnx.com/sf/go/post12167
Re: RE: RE: how to send packets over ethernet?  
i allready tried it with a sleep at this point.
but then only one packet is send before the system hangs.
RE: RE: RE: how to send packets over ethernet?  
I'm curious as to what you mean by "hangs".  I strongly suspect that
what you are actually seeing is your application spinning in a loop that
prevents anything else from working.  

What happens if you move the sleep(1) into the main body of the loop
(i.e. only sending one packet per second).  It's also possible that the
driver has a bug that results in it locking up if you hit it too hard...

	Robert.



-----Original Message-----
From: Hannes Bock [mailto:community-noreply@qnx.com] 
Sent: Thursday, August 21, 2008 10:43 AM
To: general-networking
Subject: Re: RE: RE: how to send packets over ethernet?

i allready tried it with a sleep at this point.
but then only one packet is send before the system hangs.

_______________________________________________
General
http://community.qnx.com/sf/go/post12199
Re: RE: RE: RE: how to send packets over ethernet?  
i tried the sleep in the loop but after one packet nothing will work anymore.
even the IDE lost the connection to the board. that's why i think the bord hangs.

maybe it's an problem with the driver as andrew suspected.
Re: how to send packets over ethernet?  
solved!!!

it was my failure!

by chaning my main one bracket slipped on a wrong position.
now it works fine!

thanks for all the help!!!

------
"the error was between the headphones!" ;o)