Thursday, August 9, 2007

C# IP utilities : Decimal to binary notation

public string IPdec2binary(string ip)

string ret = "";
string[] theIP = ip.Split('.');

long na = Convert.ToInt64(theIP[0]);

long nb = Convert.ToInt64(theIP[1]);

long nc = Convert.ToInt64(theIP[2]);

long nd = Convert.ToInt64(theIP[3]);

string sa = Convert.ToString(na, 2);

string sb = Convert.ToString(nb, 2);

string sc = Convert.ToString(nc, 2);

string sd = Convert.ToString(nd, 2);

long a = Convert.ToInt64(sa);

long b = Convert.ToInt64(sb);

long c = Convert.ToInt64(sc);

long d = Convert.ToInt64(sd);

ret = Convert.ToString("" + a).PadLeft(8, '0') + ".";

ret += Convert.ToString("" + b).PadLeft(8, '0') + ".";

ret += Convert.ToString("" + c).PadLeft(8, '0') + ".";

ret += Convert.ToString("" + d).PadLeft(8, '0');
return "";

return ret;

Tuesday, August 7, 2007

C# IP utilities : Integer to dotted notation

public string IPint2dotted(long ip)
     string ret = "";
       string hex = ip.ToString("X");

       if (hex.Length>=8)
         hex = hex.Substring(hex.Length-8);
         hex = hex.PadLeft(8,'0');

       for (int i=hex.Length;i>0;i-=2)
         ret += long.Parse(Convert.ToString(hex[i-2].ToString() + hex[i-1].ToString()), System.Globalization.NumberStyles.HexNumber).ToString()+".";

       if (ret.Length>0)
return ret.Substring(0,ret.Length-1);
return "";
catch (Exception exc)
return "";


Cisco ACE redundancy issues

Once you've configured redundancy on the ACEs, there's an active one, and a stand-by one. Ok, this is simple. However, there are some times configuration synch fails, and here's what I observed.

Once redundancy is configured this way :


ft group 1
peer 1
priority 200
peer priority 101
associate-context CONTEXT1


ft group 1
peer 1
priority 101
peer priority 200
associate-context CONTEXT1

As usual, the active one has the highest priority. Now I want this redundancy to be HOT, i.e. sessions remain up during a switchover as they are mantained in sync by the peers.
Typing a show ft group det on the master ACE you could (as I did) see two types of redundancy :




Cold standby state means that sessions during the switchover will be dropped, and that, for some reason, configuration sync failed, so configurations are not even equal between the two peers, and further changes on the master will not be sent to the slave.

Typical reasons for configurations' sync to fail are :
  • A scripted probe needs its script file on the ACE's disk0:, the standby ACE may not have this file on his disk0:
  • Interfaces are not configured the same way (missing some interface vlan?)
  • Svcl groups on the Catalysts hosting the ACE may not pass the same vlans to the two peers.
However, if you made one of these mistakes, as I did, you have your standby ACE in COLD standby state, what to do now ?
Even copying manually the configuration on the second ACE, it will never switch by itself in HOT standby state.

The solution is quite easy :
  1. Solve all the issues that caused the configuration sync to fail (see above).
  2. On the standby ACE, switch off and then on (rapidly) the ft group of the context :

ACE-02/Admin#conf t
ACE-02/Admin(config)#ft group 1
ACE-02/Admin(config-ft-group)#no inservice

Now you will see the standby ACE erase all of its configuration and then start back to copy it from the master ACE. At the end, you should see on the master :

FT Group : 1
Configured Status : in-service
Maintenance mode : MAINT_MODE_OFF
My Config Priority : 200
My Net Priority : 200
My Preempt : Enabled
Peer Config Priority : 101
Peer Net Priority : 101
Peer Preempt : Enabled
Peer Id : 1
Last State Change time : Fri Aug 3 06:22:17 2007

Running cfg sync enabled : Enabled
Running cfg sync status : Running configuration sync has completed
Startup cfg sync enabled : Enabled
Startup cfg sync status : Startup configuration sync has completed
No. of Contexts : 1

Context Name : CONTEXT1
Context Id : 2

Note : During this process configuration is inhibited even on the master ACE.

PS : Thanks to Francesco for helping me in troubleshooting and summarizing the events of that night.