CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Raw socket help

  1. #1
    Join Date
    Apr 2007
    Posts
    6

    Raw socket help

    Hi
    This is my first post and am a newbie to network programming.
    My currrent assignment is concerned with DHCP client server programming and need some help with that.

    I need to request two IP addresses on the client side from the server. I have a single LAN card and the request is sent from client on the same LAN card. The first request contains the preffered IP address and the MAc address and is sent using sendto() function inside another function send_packet(). The second request contains a preffered IP address and a third parth MAC address(not the same address on which the client is working). In sendto() function i get a message "such a device does not exist". Not surprised by that, but i need to get this working. Ne ideas from ne one.
    I heard i can use RAW sockets instead of Datagram. Will this put the card in promiscous mode? Is this a solution?

    http://www.isc.org/index.pl?/sw/dhcp/

    This is the code im using at the client and server side to run the daemons.

    Pls help

    Thanks in advance

  2. #2
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125

    Re: Raw socket help

    Cursious as to what you are trying to accomlish from a design (not implementation) standpoint.....

    If I read your post properly, what you are trying to do sounds very unusual....
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  3. #3
    Join Date
    Apr 2007
    Posts
    6

    Re: Raw socket help

    Hi
    Yep this is a very unusual thing. Its part of my engineering project. The brief description is as follows:

    I have a client with 2 lan cards and a server both running the package i mentioned earleier.
    If one of the lan cards fail, a process ports the MAC address of the failed Lan card to the working LAn card, so that processes running on the failed Lan card can coontinue on a working card. So I needd the processes of the failed Lan card to work on a diff Lan card, hence the client on the working lan card has to request IP addresses from server for itself and also the failed Lan card(using the failed MAC address). Hence i need to send a request a packet on a lan card using a diff MAC address.

    Hope im clear...
    Pls help

  4. #4
    Join Date
    Aug 2001
    Posts
    507

    Re: Raw socket help

    im not sure if this is the way u acomplish this

    a process ports the MAC address of the failed Lan card to the working LAn card
    MAC address are unique these can't be ported.

    What will happen is you will have to implement a switchover routine.

    both the LAN Cards will get IP addresses. If they get them from DHCP server, then they can't be the same. So u will have to implement failover with different IP addresses.

    You can do this, by making your application aware that there are two IP addresses, Or u can let it stay unaware, and just forward it's communication requests internally to the failover thread. That thread can then forward the traffic to which ever of the LAN cards is active.

    Hope that helps
    If you found my reply to be useful, please dont hesitate to rate it.


    DO NOT kick the Axe if it doesnt fall on your foot.

    Salman

  5. #5
    Join Date
    Apr 2007
    Posts
    6

    Re: Raw socket help

    @slaman

    Im sorry I think ive confused you

    Our project is part of a much bigger project, we are developing this module. Wat i meant is, If two LAN cards are present on one system(or two systems having a single LAN card), they request for IP address for the running processes from the DHCP server. If one of them fails, the failed MAC address is provided to the working LAN card. And the processes of the failed card are redirected to the working LAN card. As u said, this can be left off simply and allow the IP addresses to be assigned. But in this case, the MAC address on which the failed process runs, is different from the original LAN card(hence MAC address) it was running.

    Which means the process running on a lan card with say MAC address A, now runs on a diff LAN card with MAC address B. Hence when the IP lease expires, it requests for IP address from DHCP server. Hence while requesting for IP address renewal, the process sends request from B adding Address B. If this happens, then a different IP address is received, which is NOT WAT I WANT. Hence the aim is to communicate thru card B, but add Address A, so that existing IP addresses are renewed.

    Hope im clear this time...

  6. #6
    Join Date
    Aug 2001
    Posts
    507

    Re: Raw socket help

    Yannifan

    MAC address remains the same, only IP addresses change.

    Now, If I understand correctly, If the IP acquisition on B fails, then the process running on B, should start to communicate on the address available on A.

    But in this case, the MAC address on which the failed process runs, is different from the original LAN card(hence MAC address) it was running.
    Offcourse this will happen, because your applications are aware of the IP/MAC addresses.

    What I suggested was that you include anther layer, say CommMaster.
    Ur application will only send requests to this CommMaster.

    CommMaster should be aware of the MAC / IP addresses. Lets say u write another routine Call it GetIP, which will try to get a IP address for a LAN card. If it gets an IP it will tell the CommMaster and viceversa.
    And CommMaster routine will decide which card gets the traffic.

    This way your application will be portable, and more robust.
    If you found my reply to be useful, please dont hesitate to rate it.


    DO NOT kick the Axe if it doesnt fall on your foot.

    Salman

  7. #7
    Join Date
    Apr 2007
    Posts
    6

    Re: Raw socket help

    @salman

    Thanks a lot. Ive got an idea now. Will try to implement it
    Cheers

  8. #8
    Join Date
    Aug 2001
    Posts
    507

    Re: Raw socket help

    U can ask Krishnaa or Wildfrog here ...

    They would be able to provide better response then me.
    If you found my reply to be useful, please dont hesitate to rate it.


    DO NOT kick the Axe if it doesnt fall on your foot.

    Salman

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

Featured