Advertisement

sending raw IP packages

Started by May 15, 2000 02:52 PM
5 comments, last by Ridcully 24 years, 6 months ago
when i was looking at the documentation of the function socket(), i found out that you can create a socket with the attribtute SOCKET_RAW and the protocole IPPROT_RAW (or something like that) so my question is if i can really use this to send my own IP packages and therefore have direct access to the header of the packages (which would probably make it possible to fake my ip, right ) is that right or are those flags used for something else? thanks ridcully
hmm, okay, but i am having some problem with the SOCKET_RAW.
how do you connect it? if i use connect() and want to send/recv i get WSAENOCONN. if SOCKET_RAW connectionless? and must both server and client specify SOCKET_RAW?
Advertisement
You have to use sendto() and recvfrom() on raw sockets. Raw sockets are connectionless; the IP protocol doesn''t define the concept of connections at the network layer. The host that you connect to doesn''t have to specify the same socket parameters as you do, if you follow the protocol that it opens the socket with exactly. That is to say if you manually encapsulate the TCP headers properly, you can sendto() a socket opened with the TCP protocol.
ah, thanks. i got it to work with an SOCKET_DGRAM as server and a SOCKET_RAW as client.
BUT: how can i receive data from a SOCKET_STREAM server? i would have to establish a connection first, right? but i can''t do this with a raw socket...
do i have to emulate the handshake with recvfrom/sendto or something else?

thanks again
ridcully
You''d have to manually create all the ACK/SYN, etc. packets for the connection. There''s really no purpose in doing so; just use the a standard TCP socket.
ah, i see...
one last question: i can use recvfrom and sendto to send the ack/syn tcp handshake packages, can i? or are those functions also bound to a protocol?

btw: this is not totally purposeless because you can modify the ip packages on the lowest level that way.
Advertisement
Yes, you can use the sendto() and recvfrom() to create and receive the handshake packets.

This topic is closed to new replies.

Advertisement