Re: How to send udp packets over the internet.



What requests do you expect to make of a web server using *UDP*?
I know of no web server that will respond to it.  Web servers
generally use TCP.

Thanks for the hint.

You might open up a TCP connection to port
80 (or possibly an alternate port), and send a request like:

GET /index.php HTTP/1.1\r\nHost:www.yahoo.com\r\n\r\n

In telnet, it is very easy. Telnet does the job of creating a standard
packet with the above contents for me. I need to create the packet
myself. What'd be the structure? Is it something like this?

I'd open a socket, connect() it and write() the data something like this:

write(fd, "GET /index.php HTTP/1.1\r\nHost:www.yahoo.com\r\n\r\n", 47);
(Hope I computed the length correctly. Don't send the \0 at the end of
the string.)

I could also fdopen() the socket file descriptor, then output
the data with fprintf() or fwrite(), with fflush() to force
transmission before expecting an answer.

TCP (not telnet) does all the packet creation and I don't have to
worry about it. Incidentally, I'd likely take the same approach
with UDP if I expect to have an extended conversation (e.g. more
than one request / one response) with the same server. No headers
to mess with, just write() the data for one packet in one write()
call.

If you don't have your own TCP stack, you'll need to create one.
A single TCP packet may need to be retransmitted, and it needs to
keep the TCP sequence numbers consistent with the packets used to
set up the connection.

struct RDTHeader {
struct in_addr peer_ip;
unsigned short int peer_port;
unsigned short int seq_num;
unsigned short int length;
unsigned char flags;
unsigned char code;
SHASH hash;
unsigned char data[DFLT_SEG_SIZE +1];
};

And I shall put the contents in data?

I am just stuck at this point.

I've left out IP options and TCP options here. Header file references
are from FreeBSD, but this is probably the same for other BSD UNIX
systems.

A TCP packet *as transmitted on ethernet* consists of:

ethernet header (see <net/ethernet.h>)
IP header (see <netinet/ip.h>)
TCP header (see <netinet/tcp.h>)
data

A UDP packet *as transmitted on ethernet* consists of:

ethernet header (see <net/ethernet.h>)
IP header (see <netinet/ip.h>)
UDP header (see <netinet/udp.h>)
data

.



Relevant Pages

  • RE: First TCP packet
    ... The TCP datagram travels inside an IP packet, ... to B should be the TTL on the IP Header. ... might change depending of devices on the path ...
    (Pen-Test)
  • Re: custom handlers & dumb question
    ... tcp unlike udp is a reliable transport. ... acknowledgement, so if you can trust the status of a send (no need for own ... tcp has limited retry logic, so a PUT can often fail, but your packet send ... (iis buffering may prevent the server code from seeing this condition). ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: NDIS passthru packet redirection
    ... I solved this with adjusting the TCP checksum. ... Now I must redirect the answer packet to the calling application. ... TCP header or TCP data isn't changed, the you don't need to update the TCP ...
    (microsoft.public.development.device.drivers)
  • Re: TCP packet size is much smaller than expected
    ... Both MSS values in the TCP syn packets are indeed 1460, ... so you missed a packet in your first analysys. ... TCP, UDP, ICMP) and finally the real data. ... usually in form of a header and/or a trailer. ...
    (comp.os.linux.networking)
  • Re: Strange problem drive me mad.
    ... not by the TCP layer. ... > Thanks for reply, actually, the problem is that client (may caused by ... > always flush data before I decode the each packet when buffer is full. ...
    (microsoft.public.win32.programmer.networks)