Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ridcully

sending raw IP packages

This topic is 6915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Yes, you can use the sendto() and recvfrom() to create and receive the handshake packets.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!