Threading for distance vector which does not drop packets.

I am doing my assignment in Network architecture 1, where I have to implement a distance vector routing at each node. At each node, I have a thread which listens for incoming `DatagramPacket`s containing routing information from neighboring nodes only on a specific port. When a datagram arrives, the thread processes that datagram, and if there are updates in its internal routing tables, then it sends its routing information to all of its neighbors. I am trying to do it in Java. The problem I am facing is that when a datagram arrives, I need to process it. If during that time any other datagram arrives, it is dropped, as the thread is currently processing information. That means I have a loss of information. Can any one help me with this? I am using the usual way of reading from a socket in java. DatagramSocket socket = new DatagramSocket(4445, InetAddress.getByName("127.0.0.1")); while (true) { try { byte[] buf = new byte[2000]; // receive request DatagramPacket recvRequest = new DatagramPacket(buf, buf.length); socket.receive(recvRequest); //Some process of data in datagram } catch (IOException e) { e.printStackTrace(); } }

以上就是Threading for distance vector which does not drop packets.的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏