We are attempting to stream audio packets via a local WiFi network. We are broadcasting UDP packets - one 200 byte packet every 10ms. At times the iphone4 will receive acceptable packets with a few lost packets and audio quality is more than adequate for our purposes but when there is WiFi noise above 10% as noted with iStumbler, packet loss is unacceptable.
Most Android devices receive packets fine with very low packet loss under the same conditions.
We discovered that most WiFi routers queue up UDP packets when experiencing noisy RF conditions and then broadcast them in bursts when appropriate, the iPhone seems to have a serious problem with these bursts of broadcasted UDP traffic whereas most Android devices handle these just fine.
iPads handle these conditions much better than the iPhone but still below par as compared with most Android devices we have tested.
The question is:
Is there a lower level CFNetworking or other function that we might incorporate in our code to handle this very likely-to-happen bursty UDP traffic.
We have an adequate jitter buffer in-place but the problem is that we are not receiving the bursty packets at all from CFNetworkStream using Berkley sockets or other CFNetwork methods.
Here is a simple Sockets sample we were using to note packet loss within a 100 packet sample but have noticed the same thing using CFNetworking frameworks calls:
Since the server side is sending one packet per 10ms without fail 100 packets should take approx. 1000ms but we are seeing in the neighborhood of 1500-1700ms when wifi noise is present.
The typical Android device sees maybe 1050ms per 100 packets at most..
*//launch method from application didFinishLaunchingWithOptions
We are attempting to stream audio packets via a local WiFi network. We are broadcasting UDP packets - one 200 byte packet every 10ms. At times the iphone4 will receive acceptable packets with few lost packets and audio quality is more than adequate for our purposes but when there is WiFi noise above 10% as noted with iStumbler, packet loss is unacceptable.
Most Android devices receive packets fine with very low packet loss under the same conditions.
We discovered that most WiFi routers queue up packets when experiencing noisy RF conditions and then broadcast them in bursts when appropriate, the iPhone seems to have a serious problem with these bursts of broadcasted UDP traffic whereas most Android devices handle these just fine.
iPads handle these conditions much better than the iPhone but still below par as compared with most Android devices we have tested.
The question is:
Is there a lower level CFNetworking or other function that we might incorporate in our code to handle this very likely-to-happen bursty UDP traffic.
We have an adequate jitter buffer in-place but the problem is that we are not receiving the bursty packets at all from CFNetworkStream using Berkley sockets or other CFNetwork methods.
Here is a simple Sockets sample we were using to note packet loss within a 100 packet sample but have noticed the same thing using CFNetworking frameworks calls:
Since the server side is sending one packet per 10ms without fail 100 packets should take approx. 1000ms but we are seeing in the neighborhood of 1500-1700ms when wifi noise is present.
The typical Android device sees maybe 1050ms per 100 packets at most..
*//launch method from application didFinishLaunchingWithOptions
Code:
* [NSThread detachNewThreadSelector:@selector(startServer) toTarget:self withObject:nil];
- (void)startServer {
* * NSAutoreleasePool *pool;
* * pool = [[NSAutoreleasePool alloc] init];
* * int sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
* * struct sockaddr_in sa;
* * char buffer[524];
* * size_t recsize;
* * socklen_t fromlen;
* * packetCounter = 0;
* * memset(&sa, 0, sizeof(sa));
* * sa.sin_family = AF_INET;
* * sa.sin_addr.s_addr = INADDR_ANY;
* * sa.sin_port = htons([udpPort intValue]);
* * // bind the socket to our address
* * if (-1 == bind(sock,(struct sockaddr *)&sa, sizeof(struct sockaddr)))
* * * * {
* * * * * * perror("error bind failed");
* * * * * * close(sock);
* * * * * * exit(EXIT_FAILURE);
* * * * * * }*
* * for (;;)
* * * * {
* * * * * * recsize = recvfrom(sock, (void *)buffer, 524, 0, (struct sockaddr *)&sa, &fromlen);
* * * * * * //packetCounter++;
* * * * * * if (recsize < 0)
* * * * * * * * NSLog(@"Packet size less than 0");
* * * * * * else packetCounter++;//Metric for counting num of AA packets, raw input
* * * * * * if(packetCounter >= 100) {
* * * * * * * * uint64_t stop = mach_absolute_time();
* * * * * * * * uint64_t oneHundredPacketTime = stop-startBaseTime;
* * * * * * * * oneHundredPacketTime *= timebaseInfo.numer;
* * * * * * * * oneHundredPacketTime /= timebaseInfo.denom;
* * * * * * * * packetCounter = 0;
* * * * * * * * startBaseTime =* mach_absolute_time();
* * * * * * * * //NSLog(@"oneHundredPacket Time = %f ms",oneHundredPacketTime*0.000001);
* * * * * * * * [_mainViewController performSelectorOnMainThread:@selector(addText:)
** * * * * * * * * * * * * * * * * * * * withObject:[NSString stringWithFormat:@"100 Packet Time = %1.0f ms",oneHundredPacketTime*0.000001]
* * * * * * * * * * * * * * * * * * * waitUntilDone:NO];
* * * * * * }
* * * * }
* * [pool release];
}