Sending UDP Packets 0-40: Troubleshooting Tips

  • Thread starter Chrono
  • Start date
In summary, the code didn't seem to send anything. Somebody suggested that I try changing the port numbers, and that worked just fine.
  • #1
Chrono
425
2
All right, guys. The code below is supposed to send UDP packets over the ports 0 - 40. However, when I run it, it doesn't seem to send anything. I'm guessing it's one of two things: I'm missing some essential part of the code, or that something's wrong with the address. Anybody have any ideas?
Code:
import java.net.*;
import java.io.*;
public class datagram 
{
public static void main(String args[]) throws Exception 
{
int i;
byte[] buf = new byte[256];
DatagramSocket socket;
DatagramPacket packet;
InetAddress address = InetAddress.getByName("localhost");
for(i = 0; i <= 40; i++)
{
socket = new DatagramSocket(i);
packet = new DatagramPacket(buf, buf.length, address, i);
socket.send(packet);
}
}
}
 
Technology news on Phys.org
  • #2
Don't use port numbers in the range 1-1024, because they are reserved by the operating system for other services. Couldn't you use bigger numbers, such as 5000?
 
  • #3
Wouldn't the packets be sent back or rejected anyway?
 
  • #4
the packets won't be sent back because udp is not a reliable protcol unlike tcp, there is no guarantee that the packet will be received.
 
  • #5
Chrono said:
Wouldn't the packets be sent back or rejected anyway?

The behavior depends on the operating system, but it is guaranteed that those ports (i.e. 1-40) can't be accessed. By the way, port 0 doesn't exist.

dmail said:
the packets won't be sent back because udp is not a reliable protcol unlike tcp, there is no guarantee that the packet will be received.

UDP is a best-effort protocol, meaning that the most is done to ensure (although not guarantee) a reliable delivery. In practice it is rare that UDP fails.
 
  • #6
By the way, port 0 doesn't exist.

Well according to RFC's it is reserved, in general networking port 0 is the same as a broadcast address in IP, if you code an app to use port 0 it will try to find the first available UDP port

RFC
Explanation of port 0

becuase of this 'feature' many security experts recommend that port 0 is blocked
 
Last edited:
  • #7
I think I got it, guys. Thanks for the help. For one thing I was sending them to localhost. I don't think that would work well on sending packets. Also, I did change the port numbers (by the way, I was told to use ports 0 - 40) to 40 - 80 and it worked just fine. I still think the school's security had some problems with us sending out packets, but eventually we all got it to work. Thanks again!
 

What is a UDP packet?

A UDP (User Datagram Protocol) packet is a unit of data that is transmitted over a network using UDP. Unlike TCP (Transmission Control Protocol), UDP does not guarantee the delivery of the packet or the order in which the packets are received.

Why would someone need to send UDP packets 0-40?

Sending UDP packets 0-40 is a common troubleshooting technique used to test the connectivity and performance of a network. By sending a series of packets, it is possible to identify any potential issues or bottlenecks in the network.

What are some potential issues that could arise when sending UDP packets 0-40?

Some potential issues that could arise when sending UDP packets 0-40 include packet loss, network congestion, and hardware or software malfunctions. These issues can affect the overall performance and reliability of the network.

How can I troubleshoot issues when sending UDP packets 0-40?

To troubleshoot issues when sending UDP packets 0-40, you can try sending the packets to different destinations or using different packet sizes. You can also use network monitoring tools to analyze the traffic and identify any potential issues.

Are there any security concerns when sending UDP packets 0-40?

Sending UDP packets 0-40 can potentially expose your network to security risks, as it is a form of network probing. It is important to ensure that the packets are only sent to trusted destinations and that proper security measures are in place to protect your network.

Similar threads

  • Programming and Computer Science
2
Replies
39
Views
5K
  • Programming and Computer Science
Replies
1
Views
804
  • Computing and Technology
Replies
4
Views
1K
  • Computing and Technology
Replies
13
Views
6K
  • Programming and Computer Science
Replies
6
Views
4K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
Replies
5
Views
5K
  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
6
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top