Hot Redundancy Agent for Dynamic Switching of Servers

Environment: VC6 , NT4 SP4+, W2K

Pfwredun.exe ( Hot redundancy agent ) is the program which shows the possibility of catching IP address of master PC ( say 'A' ) , which shuts down or fails , by slave PC ( say 'B' ) and from that moment client apps on others PCs see this 'B' PC as their server and not A.

Special Thanks to Robert Hamilton for his article entitled, "CPing -- Easily ping a host from Windows 95 and Windows NT". I used his CPing class because of better results than MS PingSym or others ( I tried a few of them ). The only change I did is changing parameter in Ping constructor with parameter from host name to IP address .

This program uses IPHLPAPI.LIB and IPHLPAPI.H ( which calls iptypes.h and ipexport.h ) from Platform SDK . So you need to install Platform SDK first , before compiling and linking pfwredun.exe.

IPHLPAPI.LIB work in Windows NT 4.0 + SP 4+ , W2K and Win98 . I checked the work of the program in NT 4.0 SP 4 ,5 and W2K. I didn't check it in Win98.

This program ( pfwredun.exe - MFC dialog box application ) has to be started First time with parameter INIT h.e. in editfield of Run dialog from Start menu you have to write pfwredun INIT. After creation of pfwredun.ini file you have to fill in some data. In section [Adapters] you'll see that every line includes MAC Address and description of each adapter in square brackets. The number of lines will be by number of net adapters in the PC.

In each line you have to write after equal sign all IP's of servers which should be attached to this adapter in case of failure. So , if IP's of N servers will be written for each adapter , in the case of failure on all these servers all IP's will be attached to this adapter. IPs have to be written in standard form XXX.XXX.XXX.XXX,YYY.YYY.YYY.YYY.... In the section [Settings] you can change Network mask and time settings as you need. In time key ( by default 30 ) you define the time between calls to check/attach function if working thread created successfully( the time between finishing previous calls and start of current one ) . In the case of unsuccessful thread creation I used the timer for polling calls.

Second time pfwredun.exe has to be started without parameters . You can see existing of hot redundancy agent ( pfwredun.exe ) by icon on TaskBar tray consisting of two connected boxes ( computers ) . When IP of any server not attached yet the icon has blue color and changes color to green if agent attach first IP to one of it's adapters. Which IP is attached possible to see by "*" near IP address if press Right Button staying on Agent Icon and choosing Settings from menu. BTW I couldn't change the icon by NIM_MODIFY , so I used NIM_DELETE and NIM_ADD pair. To close the program it's possible only when not one IP is attached , so for freeing of IP need to choose which adapter ( from 1 ) and which IP ( from 1 ) you need to leave in Settings dialog box .After pressing first time IP freed from adapter. Now you can start the server and press another time to start the polling of this master. If You want to close the agent and some IPs attached , you simple need to choose each adapter,IP pair and press twice . After all IP releases the color of icon will be blue and possible to call Close the agent.

In closing the application there exists another problem, when I press Close in menu , the thread maybe in the Sleep state. So I divided Sleep time-out by 3 to minimize response time.

For clarification of data structure , I describe here some of class members ( CPfwredundlg ):

CDWordArray m_adapterindex
array of net adapter's indexes ( each net adapter have unique index ), if n net adapters exist in PC
CPtrArray m_aptr
array of pointers. Every element of m_aptr is pointer on array of IP's for each adapter ( from n ) for check for attachment . Because first adapter may have 2 IP's for attachment , next 5 IP's and so on.
CPtrArray m_adaptercontext
array of pointers . Every element of m_adaptercontext is pointer on array of Contexts for every adapter( Context is the value , which describe the context of attachment return by AddIPAddress for next use in DeleteIPAddress ) . It's parallel to m_aptr.
CMapPtrToWord m_map
two-dimension array . Every element in this array is pair of pointer to array of m_aptr and DWORD ( 0/1 ) , which describe is attachment condition. If 1 ( TRUE ) attachment was done and no need to check this IP.

Additional features of this program is attaching the IP , which has opportunity of Internet ( by firewall ) by intranet computer will allow to use it like internet computer , but only the original network mask has to be changed to allow routing for added IP.

Downloads

Download project - 50 Kb
Download zipped exe - 13 Kb


Comments

  • Hot standby redundancy on switches

    Posted by Legacy on 01/20/2004 12:00am

    Originally posted by: Shajulin Benedict

    The program has described the hot standby procedure for servers. Can you please explain me the codings for implementing it in switches.
    If one switch fails, then the next switch has to take over in hot standby manner. Since I am pursuing an M.E project relating this concept I humbly request your help.
    Thanking you
    YOurs sincerely
    Shajulin Benedict

    Reply
  • No... you guys need to install SDK from microsoft

    Posted by Legacy on 05/21/2003 12:00am

    Originally posted by: jaejiny

    No... you guys need to install SDK from microsoft

    good day..

    Reply
  • how do you delete an IP if u don't have the NTEContext

    Posted by Legacy on 03/26/2002 12:00am

    Originally posted by: dev

    hi,

    After adding an IP using AddIPAddress we use the NTEContext value returned by this function call pass it to deleteipaddress and that deletes the IP. This is fine if our application is running and we have access to the NTEContext but suppose we exit our application after adding the IP and then want to delete it later on using another application . Then HOW DO WE GET THE VALUE OF THE NTECONTEXT FOR THAT IP ADDRESS.

    One way is to use getadaptersinfo function and from that move thru the ip address list and get the ntecontext for the ip we want to delete and then pass it to deleteipaddress.
    I am able to get this working on win 2k but this doesn't seem to work on winnt 4.0 i.e the call to getadaptersinfo function.

    Is there any other way of getting the NTEContext on NT 4.0 or is there an alternative method to delete the IP???

    Any help is thanked in advance.

    regards
    dev

    Reply
  • file missed in your source

    Posted by Legacy on 01/05/2002 12:00am

    Originally posted by: Xela

    Hi there,
    I was unable to comile your project, due to iphlpapi.h missed. If you can help me with this, please e-mail me back.

    Regards,

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds