# CARP details



## c0re (Nov 8, 2010)

Hey all!

In carp(4) or ifconfig(8) no information when in seconds BACKUP will be MASTER.
I mean, 'man ifconfig' from openbsd says:



> Taken together, the advbase and advskew indicate how frequently, in
> seconds, the host will advertise the fact that it considers itself master
> of the virtual host.  The formula is advbase + (advskew / 256).  If the
> master does not advertise within three times this interval, this host
> will begin advertising as master.



so if advbase=1 and advskew=100, formula 3*(1+100/256)= ~4 seconds.

But when I make [cmd=]ifconfig carp0 down[/cmd] on primary server with advskew=0 I see that second (backup) server becomes MASTER immediately, no 4 seconds timeout.

So how truly CARP works on FreeBSD?
My backup server is too frequently becomes MASTER (about 5-10 times per day) and I can't understand why.


----------



## pbd (Nov 8, 2010)

The reason why your backup becomes master immediately is because when you shut down carp interface manually (ifconfig carp0 down) it sends it's advertisement with priority 255, so it explicitly notifies other nodes that it is going down.

3 * (advbase + (advskew / 256)) is correct.


----------



## phoenix (Nov 8, 2010)

Instead of downing the interface, pull the plug out of the NIC, and time how long the fail-over takes.


----------



## c0re (Nov 9, 2010)

pbd said:
			
		

> The reason why your backup becomes master immediately is because when you shut down carp interface manually (ifconfig carp0 down) it sends it's advertisement with priority 255, so it explicitly notifies other nodes that it is going down.
> 
> 3 * (advbase + (advskew / 256)) is correct.



ah there it is! thanks.




			
				phoenix said:
			
		

> Instead of downing the interface, pull the plug out of the NIC, and time how long the fail-over takes.



got it 


Okay, that means that 4,1 seconds backup server can not hear master server announces to become master. It's 4 lost announces.
Any ideas how it can be if both server has no heavy load and they are plugged in one switch?

I used simple script with ICMP pings and echoing each date of ping loss to log file.
There are ping losses, but no sequent loss. I mean no more than one ping lost during 10 minutes.

To become master from backup I need 4 sequent lost advertisements... But ping does not show so many losses.. Any ideas?


----------



## pbd (Nov 9, 2010)

You can save dump of the carp advertisement packets on both machines:

[CMD="master#"]tcpdump -n -s 0 -w carp-master.dump -i _INTERFACE_ vrrp[/CMD]
[CMD="backup#"]tcpdump -n -s 0 -w carp-backup.dump -i _INTERFACE_ vrrp[/CMD]

(replace _INTERFACE_ with your network interface name) and then use net/wireshark to analyze the dump file. You should see whether master stops sending it's advertisement or if backup doesn't receive it.


----------



## c0re (Nov 12, 2010)

I found it.
When scheduled tasks in crontab take 50% cpu load packets been lost, but looks like they lost somewhere in  vmware esxi...
Packet sent, but not received by another carp-server.

Thanks for answers!

Will try to find out what's up with esxi.


----------

