sockets - UDP is not reliable at all? -
i have designed scheme in used udp send broadcast messages clients connected same access point. using access point connect server , other clients. problem broadcasting. when broadcast message of 800 bytes clients, reception totally random. clients able messages , not. tried broadcast multiple times at-least 1 go through , reach clients. not working times. why packets getting dropped? problem size of packets ? how should go create reliable ? factors may lead this? have 40-50 clients connected ap. access point exclusively used application , there no net connection it.
udp inherently unreliable in sense that:
udp packets may lost, and the udp protocol provides no mechanism tell if packets have been lost, or resend them.why packets getting dropped?
in general, there number of possible reasons:
packets may misrouted, packets may "eaten" firewall, packets may dropped due congestion in gateway, packets may dropped due congestion @ end-point, or packets may lost due network-level problem; e.g. collision or transmission error.any problem size of packets?
yes. if udp packet large, may need fragmented (at ip packet level). if of fragments gets lost, receiver cannot reassemble packet, , entire udp packet lost. (there no mechanism retransmitting lost fragments.)
reference: http://pcvr.nl/tcpip/udp_user.htm#11.
hence, probability of big udp packet getting lost greater.
note fragmentation occurs when ip packet size exceeds mtu of link. ethernet link, mtu typically ~1500 octets or more. ipv4 spec allows mtu low 576 octets. if subtract size of ip , udp headers, gives minimum udp packet payload size of 534 octets before fragmentation possible.
how should go create reliable ?
these things may help:
pick maximum udp packet size won't lead fragmentation. implement software read packets possible ... avoid packets beingness dropped receiving os. avoid sending udp packets through (potentially) congested network link. avoid sending many packets in short time.but nil create udp reliable in sense above. protocol inherently unreliable. if want reliability, either utilize tcp or implement own reliability mechanisms @ application protocol level. former improve approach.
sockets networking network-programming udp broadcast
No comments:
Post a Comment