Q:

Rc switch library transmit using protocol 5

I'm trying to transmit using mode 5 with the rc switch library, but my reciever tells me that the data is using protocol 2.  I'm using the RecieveDemo_simple example as a sniffer for 433 MHz and I'm recieving data with protocol 5 from a wireless electric plug that I want to replicate. 
I am able to send the data, but it is using the wrong protocol most of the time. 
Here's some output from the reciever:
Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 5
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 2
Received 15766156 / 24bit Protocol: 5
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 2
Received 15885740 / 24bit Protocol: 5

The code:
/*
  Example for different sending methods

  https://github.com/sui77/rc-switch/

*/

#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();

void setup() {

  Serial.begin(9600);

  // Transmitter is connected to Arduino Pin #10  
  mySwitch.enableTransmit(10);

  // Optional set pulse length. 
  // mySwitch.setPulseLength(320);

  // Optional set protocol (default is 1, will work for most outlets)
  mySwitch.setProtocol(5);

  // Optional set number of transmission repetitions. 
  // mySwitch.setRepeatTransmit(15);

}

void loop() {

  /* Same switch as above, but using decimal code */
  mySwitch.send(15885740, 24);
  delay(1000);  
  mySwitch.send(15766156, 24);
  delay(1000);  

}

A:

I would expect your sending protocol 5 just fine. 
But because protocol 2 and 5 are very similar, your receiver gets confused about which protocol it sees when there's noise or other interference. 
This is the definition of the two protocols from the code:
{ 650, {  1, 10 }, {  1,  2 }, {  2,  1 }, false },    // protocol 2
{ 500, {  6, 14 }, {  1,  2 }, {  2,  1 }, false },    // protocol 5

Note the last three parts are the same, which are the pulses for 0, 1, and whether or not the high/lows are inverted.  
The first part is also very similar, which is the pulse length.  It's so similar that the difference probably falls within the margin for error the receiver software uses. 
Only the second parts differs a bit more, which is the sync bit, it's a short high pulse followed by a longer low pulse.  It's easy to mistake the one for the other though when there's noise and such.