Date: Mon, 5 Sep 2016 21:47:57 -0700 From: Adrian Chadd <adrian@freebsd.org> To: =?UTF-8?B?T3RhY8OtbGlv?= <otacilio.neto@bsd.com.br> Cc: "freebsd-arm@freebsd.org" <freebsd-arm@freebsd.org>, "freebsd-wireless@freebsd.org" <freebsd-wireless@freebsd.org> Subject: Re: Small example program shut down urtwn Message-ID: <CAJ-Vmokotf8cf2HEDhwc6WYzMNLGoj-ZeV4UAxJFDjD6=yu76w@mail.gmail.com> In-Reply-To: <fea1f0b8-d17c-5fc1-9593-6d8a6e2032db@bsd.com.br> References: <fea1f0b8-d17c-5fc1-9593-6d8a6e2032db@bsd.com.br>
next in thread | previous in thread | raw e-mail | index | archive | help
hm, interesting! I wonder if urtwn and/or usb is missing some bus barriers for ARM or something? -a On 4 September 2016 at 14:18, Otac=C3=ADlio <otacilio.neto@bsd.com.br> wrot= e: > Dears > > I wrote these two small programs to help debug a problem that I think I h= ave > found when using urtwn driver in a baglebone black. The problem is 100% > reproducible. > > In a server machine I run: > > serverUDP 2508 > > In beaglebone black I run: > > ./clientUDP servername 2508 9216 0 > > All the times, after some packages be sent the urtwn interface do not > respond from ping and stops send others packages. Some times this error > message appears: > > % urtwn0: device timeout > > I have tested with RTL8192CU and RTL8188CUS > > The problem do no occurs in my notebook. > > Following the server and client > > #include <stdlib.h> > #include <string.h> > #include <arpa/inet.h> > #include <netinet/in.h> > #include <stdio.h> > #include <sys/types.h> > #include <sys/socket.h> > #include <unistd.h> > > #define BUFFER_LEN 1024*1024 > > void diep(char *s) > { > perror(s); > exit(1); > } > > int main(int argc, char **argv) > { > int lidos; > struct sockaddr_in si_me, si_other; > int s, i, slen=3Dsizeof(si_other); > char buf[BUFFER_LEN]; > int aux; > > if(argc !=3D 2){ > fprintf(stderr, "Voce deve usar %s <porta>\n", argv[0]); > exit(1); > } > > if ((s=3Dsocket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))=3D=3D-1) > diep("socket"); > > memset((char *) &si_me, 0, sizeof(si_me)); > si_me.sin_family =3D AF_INET; > si_me.sin_port =3D htons(strtol(argv[1], (char **)NULL, 10)); > si_me.sin_addr.s_addr =3D htonl(INADDR_ANY); > if (bind(s, (struct sockaddr *)&si_me, sizeof(si_me))=3D=3D-1) > diep("bind"); > > i =3D 1; > do { > if ((lidos =3D recvfrom(s, buf, BUFFER_LEN, 0, (struct sockaddr > *)&si_other, (socklen_t *)&slen))=3D=3D-1) > diep("recvfrom()"); > aux =3D ntohl(*(int*)&buf[0]); > printf("Perdidos %d pacotes (%0.2f%%)\n", aux - i, 100*((float)(a= ux > - i))/((float)aux)); > printf("Sequencia %0000d Recebidos %d bytes\n", aux, lidos); > i++; > }while(lidos>0); > > close(s); > return 0; > } > > #include <stdlib.h> > #include <string.h> > #include <arpa/inet.h> > #include <netinet/in.h> > #include <stdio.h> > #include <sys/types.h> > #include <sys/socket.h> > #include <unistd.h> > #include <netinet/in.h> > #include <netdb.h> > #include <arpa/inet.h> > #include <sys/select.h> > > #define SOCKET_ERROR -1 > #define INVALID_SOCKET -1 > > #define SRV_IP "127.0.0.1" > > void diep(char *s) > { > perror(s); > exit(1); > } > > > int main(int argc, char **argv) > { > struct sockaddr_in si_other; > int s, i, slen=3Dsizeof(si_other); > char *buf; > int tamanho; > int npack; > struct addrinfo *result =3D NULL, > *ptr =3D NULL, > hints; > int iResult, aux; > fd_set fdset; > > if(argc !=3D 5){ > fprintf(stderr,"Voce deve usar %s <host> <porta> <tamanho> <numer= o > de pacotes>\n", argv[0]); > exit(1); > } > > tamanho =3D (int)strtol(argv[3], (char **)NULL, 10); > npack =3D (int)strtol(argv[4], (char **)NULL, 10); > > buf =3D malloc(tamanho); > > bzero(&hints, sizeof(hints)); > hints.ai_family =3D AF_UNSPEC; > hints.ai_socktype =3D SOCK_DGRAM; > hints.ai_protocol =3D IPPROTO_UDP; > > iResult =3D getaddrinfo(argv[1], argv[2], &hints, &result); > if ( iResult !=3D 0 ) { > printf("getaddrinfo failed with error: %d\n", iResult); > return 1; > } > > // Attempt to connect to an address until one succeeds > for(ptr=3Dresult; ptr !=3D NULL ;ptr=3Dptr->ai_next) { > > // Create a SOCKET for connecting to server > s =3D socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); > if (s < 0){ > perror("socket"); > return 1; > } > > // Connect to server. > iResult =3D connect(s, ptr->ai_addr, (int)ptr->ai_addrlen); > if (iResult =3D=3D SOCKET_ERROR) { > close(s); > s =3D INVALID_SOCKET; > continue; > } > > break; > } > > freeaddrinfo(result); > FD_ZERO(&fdset); > FD_SET(s, &fdset); > for (i=3D1; i<=3Dnpack || npack=3D=3D0; i++) { > aux =3D htonl(i); > memcpy(&buf[0], &aux, sizeof(aux)); > aux =3D htonl(npack); > memcpy(&buf[0+sizeof(i)], &aux, sizeof(aux)); > do{ > if(select(s+1, NULL, &fdset, NULL, NULL )<0) > diep("select()"); > }while(!FD_ISSET(s, &fdset)); > if (send(s, buf, tamanho, 0)=3D=3D-1) > diep("sendto()"); > } > printf("Enviados %d pacotes de %d bytes\n", npack, tamanho); > > close(s); > return 0; > } > _______________________________________________ > freebsd-wireless@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-wireless > To unsubscribe, send any mail to "freebsd-wireless-unsubscribe@freebsd.or= g"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAJ-Vmokotf8cf2HEDhwc6WYzMNLGoj-ZeV4UAxJFDjD6=yu76w>