As you know, Barrier options are extensions of vanilla options in the sense that they have a barrier level which activates or deactivates the option's pay-off upon hitting the barrier. The barrier can be hit when the option is in-the-money or out-of-money. Barrier options which are activated upon hitting the
barrier are called Knock-in barrier options or simply Ins and those that are instead deactivated are known as Knock-out barrier options or Outs.

In knock-out options, if the barrier is not hit by the underlying price from the time of issuance of the option to its maturity, then the option
holder receives an equivalent pay-off of a vanilla option.Knock-in options only provide a possibility of a positive pay-off after the barrier has been hit.

When a barrier option knocks-in, it becomes an equivalent vanilla option and thus, offers the same pay-off whereas a knock-out is equivalent to the corresponding vanilla option as long as the barrier is not hit until maturity (exercise time).

**Mathematically speaking**

Let $M_T=\max\{S_t\, ,\, 0\le t\le T\}$ and $m_T=\min\{S_t\, ,\, 0\le t\le T\}$
then the payoffs of down-and-out-call  and down-and-out put  respectively are given by
$$(S_T-K)^+ \mathbb{I}_{\{m_T>L\}}$$
$$(K-S_T)^+ \mathbb{I}_{\{M_T>L\}}$$
and the payoffs for the up-and-out call and up-and-out put are given as follows
$$(S_T-K)^+ \mathbb{I}_{\{M_T>L\}}$$
$$(K-S_T)^+ \mathbb{I}_{\{M_T>L\}}$$
Knock-in options give a payoff equivalent to that of an equivalent vanilla option at maturity only when the barrier is hit otherwise the payoff is zero.

A portfolio consisting of one knock-in call and one knock-out call is equivalent to an ordinary call option,that is,
$$\text{up-and-out call + up-and-in call}=\text{vanilla call}$$

Similarly, for the other barrier options we have the following relationships,

$$\text{down-and-out call + down-and-in call}=\text{vanilla call}$$
and
$$\text{up-and-out put + up-and-in put}=\text{vanilla put}$$
$$\text{down-and-out put + down-and-in put}=\text{vanilla put}$$
**Refference**

 - Lishang Jiang, [Mathematical modelling and methods of option pricing][1], World Scientific Publishing Co. Pte. Ltd., 2003.
 - Michael Kateregga,[Pricing and Hedging of Barrier Options,Thesis][2] · June 2011


  [1]: http://www.worldscientific.com/doi/pdf/10.1142/9789812703576_fmatter
  [2]: https://www.researchgate.net/publication/269076916_Pricing_and_Hedging_of_Barrier_Options