[uClinux-dev] Multicast/Broadcast on Coldfire 5272

hotzenplotz hotzenplotz at gmail.com
Wed Aug 3 16:40:50 EDT 2005


Okay (o;

But did you try adding a mcast route on your uclinux box then?

rick

On 7/3/05, Manuel Kron <mkr at kron-systems.de> wrote:
> No. I had a problem with my mailer. Sorry!
> 
> ----- Original Message -----
> From: "hotzenplotz" <hotzenplotz at gmail.com>
> To: "uClinux development list" <uclinux-dev at uclinux.org>
> Sent: Saturday, July 02, 2005 7:14 PM
> Subject: Re: [uClinux-dev] Multicast/Broadcast on Coldfire 5272
> 
> 
> Ehhmm...
> 
> 
> Did you read my reply or do you just post same question
> over and over again???
> 
> rick
> 
> 
> On 7/2/05, Manuel Kron <mkr at kron-systems.de> wrote:
> >
> > Hi all,
> >
> > I try to send some multicast or broadcast messages into my network
> > (192.168.1.0). I have
> > a COBRA5272 Board and using µClinux 2.4 kernel. I have written a small
> > demo with multicast, but it seams muticast doesn't run on µClinux. I have
> > also
> > enabled IP: multicasting on my kernel config. I can see that the RUNNING
> > MULTICAST
> > is on.
> > What I want is sending broadcast or multicast messages into my network, in
> > order
> > to discover other µClinux client. Do you have any ideas how can I do this!
> >
> > I have attach a multicast server/client for testing. It works find on my
> > linux host PC but not on
> >
> > µClinux. Do you have any ideas?
> >
> > Regards,
> > Manuel
> >
> > >ifconfig
> > eth0      Link encap:Ethernet  HWaddr F0:71:4C:40:37:77
> >
> > inet addr:192.168.1.80  Bcast:192.168.1.255  Mask:255.255.255.0
> > UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
> > RX packets:3934 errors:0 dropped:0 overruns:0 frame:0
> > TX packets:1265 errors:0 dropped:0 overruns:0 carrier:0
> > collisions:2 txqueuelen:1000
> >
> > RX bytes:896814 (875.7 kiB)  TX bytes:145871 (142.4 kiB)
> > Base address:0x840
> >
> >
> > /> route
> >
> > Kernel IP routing table
> >
> > Destination     Gateway         Genmask         Flags Metric Ref    Use
> > Iface
> > eth0 192.168.1.0     *               255.255.255.0   U     0      0
> 0
> > eth0 127.0.0.0       *               255.255.255.0   U     0      0
> 0
> > lo
> >
> > ---------------------------mserver.c--------------------------------------
> ---------
> > // A multicast server to send multicast datagrams
> > //----- Include files
> > -------------------------------------------------------
> > #include <stdio.h>          // Needed for printf()
> > #include <stdlib.h>         // Needed for memcpy() and itoa()
> > #include <sys/types.h>    // Needed for system defined identifiers.
> > #include <netinet/in.h>   // Needed for internet address structure.
> > #include <sys/socket.h>   // Needed for socket(), bind(), etc...
> > #include <arpa/inet.h>    // Needed for inet_ntoa()
> > #include <fcntl.h>
> > #include <netdb.h>
> >
> > //----- Defines
> > -------------------------------------------------------------
> > #define PORT_NUM         4444             // Port number used
> > //#define GROUP_ADDR "225.1.1.1"            // Address of the multicast
> > group
> > #define GROUP_ADDR "224.0.0.2"            // Address of the multicast
> group
> >
> > //===== Main program
> > ========================================================
> > int main(void) {
> >   unsigned int         server_s;                // Server socket
> descriptor
> >   unsigned int         multi_server_sock;       // Multicast socket
> > descriptor
> >   struct sockaddr_in   addr_dest;               // Multicast group address
> >   struct ip_mreq       mreq;                    // Multicast group
> > descriptor
> >   unsigned char        TTL;                     // TTL for multicast
> packets
> >   struct in_addr       recv_ip_addr;            // Receive IP address
> >   unsigned int         addr_len;                // Internet address length
> >   unsigned char        buffer[256];             // Datagram buffer
> >   int                  count;                   // Loop counter
> >   int                  retcode;                 // Return code
> >
> >   // Create a multicast socket
> >   multi_server_sock=socket(AF_INET, SOCK_DGRAM,0);
> >
> >   // Create multicast group address information
> >   addr_dest.sin_family = AF_INET;
> >   addr_dest.sin_addr.s_addr = inet_addr(GROUP_ADDR);
> >   addr_dest.sin_port = htons(PORT_NUM);
> >
> >   // Set the TTL for the sends using a setsockopt()
> >   TTL = 1;
> >   retcode = setsockopt(multi_server_sock, IPPROTO_IP, IP_MULTICAST_TTL,
> >                        (char *)&TTL, sizeof(TTL));
> >   if (retcode < 0)
> >   {
> >     printf("*** ERROR - setsockopt() failed with retcode = %d \n",
> retcode);
> >     return;
> >   }
> >
> >   // Set addr_len
> >   addr_len = sizeof(addr_dest);
> >
> >   // Multicast the message forever with a period of 1 second
> >   count = 0;
> >   printf("*** Sending multicast datagrams to '%s' (port = %d) \n",
> >     GROUP_ADDR, PORT_NUM);
> >  while(1) {
> >     // Increment loop count
> >     count++;
> >
> >     // Build the message in the buffer
> >     sprintf(buffer,"Hello Multicast Group - this is message #%d", count);
> >
> >     // Send buffer as a datagram to the multicast group
> >     sendto(multi_server_sock, buffer, sizeof(buffer), 0,
> >            (struct sockaddr*)&addr_dest, addr_len);
> >   sleep(1);
> >  }
> >   close(multi_server_sock);
> >  return 0;
> > }
> >
> >
> > ---------------------------------mclient.c--------------------------------
> > //A multicast client to receive multicast datagrams
> > #include <stdio.h>
> > #include <stdlib.h>
> > #include <sys/types.h>
> > #include <netinet/in.h>
> > #include <sys/socket.h>   // Needed for socket(), bind(), etc...
> > #include <arpa/inet.h>    // Needed for inet_ntoa()
> > #include <fcntl.h>
> > #include <netdb.h>
> >
> > //----- Defines
> > -------------------------------------------------------------
> > #define PORT_NUM         4444             // Port number used
> > //#define GROUP_ADDR "225.1.1.1"            // Address of the multicast
> > group
> > #define GROUP_ADDR "224.0.0.2"            // Address of the multicast
> group
> >
> > //===== Main program
> > ========================================================
> > int main(void) {
> >
> >   unsigned int         multi_server_sock; // Multicast socket descriptor
> >   struct ip_mreq       mreq;              // Multicast group structure
> >   struct sockaddr_in   client_addr;       // Client Internet address
> >   unsigned int         addr_len;          // Internet address length
> >   unsigned char        buffer[256];       // Datagram buffer
> >   int                  retcode;           // Return code
> >
> >   // Create a multicast socket and fill-in multicast address information
> >   multi_server_sock=socket(AF_INET, SOCK_DGRAM,0);
> >   mreq.imr_multiaddr.s_addr = inet_addr(GROUP_ADDR);
> >   mreq.imr_interface.s_addr = INADDR_ANY;
> >
> >   // Create client address information and bind the multicast socket
> >   client_addr.sin_family = AF_INET;
> >   client_addr.sin_addr.s_addr = INADDR_ANY;
> >   client_addr.sin_port = htons(PORT_NUM);
> >   retcode = bind(multi_server_sock,(struct sockaddr *)&client_addr,
> > sizeof(struct sockaddr));
> >   if (retcode < 0) {
> >     printf("*** ERROR - bind() failed with retcode = %d \n", retcode);
> >     return;
> >   }
> >
> >   // Have the multicast socket join the multicast group
> >   retcode = setsockopt(multi_server_sock, IPPROTO_IP,
> > IP_ADD_MEMBERSHIP,(char*)&mreq, sizeof(mreq));
> >   if (retcode < 0) {
> >     printf("*** ERROR - setsockopt() failed with retcode = %d \n",
> retcode);
> >     return;
> >   }
> >
> >   // Set addr_len
> >   addr_len = sizeof(client_addr);
> >
> >  while(1) {
> >     // Receive a datagram from the multicast server
> >     if( (retcode = recvfrom(multi_server_sock, buffer, sizeof(buffer), 0,
> >       (struct sockaddr *)&client_addr, &addr_len)) < 0){
> >         printf("*** ERROR - recvfrom() failed \n");
> >         exit(1);
> >       }
> >
> >     // Output the received buffer to the screen as a string
> >     printf("%s\n",buffer);
> >  }
> >   close(multi_server_sock);
> >  return 0;
> > }
> >
> >
> >
> > _______________________________________________
> > uClinux-dev mailing list
> > uClinux-dev at uclinux.org
> > http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> > This message was resent by uclinux-dev at uclinux.org
> >
> >
> >
> 
> 
> --
> http://www.uclinux.net/forum/
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org
> 
> 
> _______________________________________________
> uClinux-dev mailing list
> uClinux-dev at uclinux.org
> http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
> This message was resent by uclinux-dev at uclinux.org
> 


-- 
http://www.uclinux.net/forum/



More information about the uClinux-dev mailing list