Sockets, New Empty Sockets
Hi everybody, I'm trying to make a "undefined" socket.
What i mean with undefined is that it will only contain:
PACKAGE:
Destination:Mac to send to: Length:0x6
Source:Mac that is sending this package: Length:0x6
Type:I want to define it: Length:0x2
then i will add some data to send here(not necessary for now).
This is my code right now:
Code:
Private Sub SendData()
Dim rClient As Socket = New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
'Make Data to send, not package header!
Dim buffer() As Byte = MakeReq(b_mac, sOpt.mac, sOpt.ip, sOpt.mac, MakeTIp(1), n_mac)
rClient.EnableBroadcast = True
Dim _ip As EndPoint = New IPEndPoint(IPAddress.Broadcast, 4950)
rClient.SendTo(buffer, _ip)
end sub
If I monitor my network with Wireshark i will now get somthing like this:
Destination: good
Source: good
Type: bad! it is 0x0800 (IP)
then i get a section that is called IPv4 with some data
Then i get a section of data that is called User Datagram Protocol(UDP)
then i get my DATA
I want the IP and UDP section removed and I want to change the Type value
Please help, I have tried to Google it but failed! I have tried everything I can, Please help me.:confused::confused::confused:
Re: Sockets, New Empty Sockets
First of all I can't imagion why you would want to remove that stuff and second I don't see how it could work without it.
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
DataMiser
First of all I can't imagion why you would want to remove that stuff and second I don't see how it could work without it.
It need to work!
If you look at the ARP package for example you will see:
Destination:MAC
Source:MAC
TYPE:0x0806(ARP)
then some data
That is it. But how?
Re: Sockets, New Empty Sockets
Can you explain a bit more about the purpose for this? From your description, it sounds like you want to send something without that packet having any information about what it is. I'd be amazed if that was possible, as I would expect that routers would find it difficult to know what to do with such a packet, nor can I see any value to doing that. Therefore, if you explain why you want to do that, perhaps we could suggest a better approach to solving the ultimate problem.
Re: Sockets, New Empty Sockets
Ah, I was writing as you were posting that. So you want to get rid of the UDP part and just have the IP part?
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
Shaggy Hiker
Can you explain a bit more about the purpose for this? From your description, it sounds like you want to send something without that packet having any information ...
There is no good purpose of this I only do this because I want to learn how this stuff works in the base.
What i will do with it later on is to broadcast to all on my network(you can see it in my code) and they will listen for my protocol and not any other.
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
Shaggy Hiker
Ah, I was writing as you were posting that. So you want to get rid of the UDP part and just have the IP part?
I was writing too...
No the IP will be removed to not IPv4 or IPv6 only a clean package
Re: Sockets, New Empty Sockets
You might want to look into the IP stack in general. I have a book that discusses all the different layers that go into making up any packet. It's fairly involved.
However, I'm not sure that you will be able to work with any modern switch and not have at least the IP layer in there, since I think the switches are using that, even if you have some custom layer above that. On the other hand, it has been years since I have looked at that, so I'm probably at least out of date if not flat out wrong.
Re: Sockets, New Empty Sockets
Have you experimented with different socket types? Protocol types?
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
DataMiser
Have you experimented with different socket types? Protocol types?
I'm working on it right now, I'm making a brute force that will look if it is possible with that combination of Addressfamily + SocketType + ProtocolType
Re: Sockets, New Empty Sockets
It sounds like you want to send/receive raw ethernet packets. I've not done it myself, but try using the SocketType.Raw for the protocol type.
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
SJWhiteley
It sounds like you want to send/receive raw ethernet packets. I've not done it myself, but try using the SocketType.Raw for the protocol type.
I think that too but, what does the other values need to be?
Re: Sockets, New Empty Sockets
Quote:
Originally Posted by
DataMiser
Have you experimented with different socket types? Protocol types?
I've only really been a particular fan of UDP, though I have also used TCP.
Re: Sockets, New Empty Sockets
I used a little UDP back in VB3 when I was first learning the winsock. Now I use TCP in pretty much everything.
Re: Sockets, New Empty Sockets
Well, from the start of your post it seems you want to simply send ethernet packets (MAC to MAC). by setting datagram and UDP, you are sending UDP packets over IP - neither of which you want.
Your following code indicates an IPEndPoint object - well, since you don't want IP, you can't have an IP end-point. You aren't talking IP.
If this is raw ethernet packets, try SocketType.Raw and ProtocolType.Unknown. I am not sure if this will work, but give it a try.
However...
Do you really want raw IP packets? Both UDP and TCP are built on - wrappered by - IP. You can set the SocketType to Raw and ProtocolType to Raw. The documentation implies this is raw IP protocol.
Again, i cannot be sure of these as I've only used UDP and TCP for socket communication. You will possibly need to experiment with the settings, and understand what ethernet protocol you are actually dealing with.