Results 1 to 15 of 15

Thread: Sockets, New Empty Sockets

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    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.

  2. #2
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    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.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by DataMiser View Post
    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?

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    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.
    My usual boring signature: Nothing

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    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?
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by Shaggy Hiker View Post
    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.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by Shaggy Hiker View Post
    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

  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    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.
    My usual boring signature: Nothing

  9. #9
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    Re: Sockets, New Empty Sockets

    Have you experimented with different socket types? Protocol types?

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by DataMiser View Post
    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

  11. #11
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    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.
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Dec 2010
    Posts
    31

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by SJWhiteley View Post
    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?

  13. #13
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,102

    Re: Sockets, New Empty Sockets

    Quote Originally Posted by DataMiser View Post
    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.
    My usual boring signature: Nothing

  14. #14
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,206

    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.

  15. #15
    PowerPoster SJWhiteley's Avatar
    Join Date
    Feb 2009
    Location
    South of the Mason-Dixon Line
    Posts
    2,256

    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.
    "Ok, my response to that is pending a Google search" - Bucky Katt.
    "There are two types of people in the world: Those who can extrapolate from incomplete data sets." - Unk.
    "Before you can 'think outside the box' you need to understand where the box is."

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width