## 4 Proposed Architecture
### Implementation Phase
```
1:Input:[struct l2 vpn_pw *pw; struct fcc fcc; struct notify_msg nm; struct fcc_node *fn; struct fcc_nh *fnh; struct l2 vpn_pw *pw; struct tnbr *tnbr; static struct ctl_pw pvctl; ]
2:Call struct l2 vpn_pw *PwNew ();
3:Call struct l2 vpn_pw *PwFind (pw, InterfaceName);
4:Call struct l2 vpn_pw *PwFindActive (pw);
5:Call struct l2 vpn_pw *PwFindinActive(pw)
6:Call Void PwUpdateInfo (pw);
7:Call Void PwInit (pw, fcc)
8:Call PwExit(pw) { comment: lde_kernel_remove and lde_kernel_update}
9:Call Int PwOk (pw, fcc)
10:iffnh\(->\)remote_label \(==\) NO_LABEL then
11:return (0); { comment: /* check for a remote label */}
12:endif
13:ifpw\(->\)l2 vpn\(->\)mtu!= pw\(->\)remote_mtu then
14:return (0); { comment: /* MTUs must match */}
15:endif
16:if (pw\(->\)flags & F_PW_STATUSTLV) && pw\(->\)remote_status!= PW_FORWARDING then
17:return (0); { comment: /* check pw status if applicable */}
18:endif
19:Call Int PwNegotiate (nbr, fcc);
20:if pw\(==\)NULL then
21:return (0);{ comment: pw not configured, return and record- the mapping later}
22:endif
23:{ comment: /* RFC4447--pseudowire status negotiation */}
24:Call Void SendPwStatus (nbr, nm)
25:Call Void RecvpWStatus (nbr, nm)
26:Call Void RecvpWildCard (nbr, nm, fcc) {/*RFC4447 PwID group wildcard*/}
27:Call Int PvStatusUpdate (l2 vpn, fcc)
28:Call Void PwCtl (pwctl)
29:Call Void BindingCtl (fn, fcc, pwctl)
30:Call Void ldpe_l2 vpn_init (l2 vpn, pw)
31:Call Void ldpe_l2 vpn_exit (pw)
32:Call Void ldpe_l2 vpn_pw_exit (pw, tnbr)
```  
**Algorithm 2**l2 vpn_PW ()  
In the ldpd()_Configuration file, if there is a change in l2 vpn configuration, a new configuration will be made by inserting or deleting the variations. Here, in line 4 of Algorithm 3, by calling _MergelInterface()_, the changes in the interface of an l2 vpn file are checked so that if it is wasted, it will be removed from the database and released, and if it is not found, it will be registered in the database. In the _MergeActivePw()_ function, if the active PW is wasted, it will be removed from the database and released. And in _UpdateExistingActivePw()_, if the LDP address is changed in a PW, it is sufficient that the target passengers are reinstalled, but under any of the following session conditions it must be changed. If PW flags and configuration TLV status have changed, all neighbors must be reset. However, if PW type has changed most of the transfer unit, PW or LSR ID, the PW FEC must be reinstalled. Finally, calling _MergeInActivePw()_ is like the description of active PW, except that the operation is performed on passive PW. Finally, after applying the above algorithms, our control plane will be ready to provide the proposed service. ```
1:Input:[struct12 vpnpw*pw;unionldpadddr addr;structnbr*nbr;structldpd_conf*xconf;struct12 vpn*12 vpn]
2:previous_pw_type=l2 vpn->pw_type;
3:previous_mtu=l2 vpn->mtu;
4:Call static void MergelInterface (xconf, l2 vpn);
5:CallMergeActivePw(pw);
6:{comment:/* find deleted active pseudowires and also find new active pseudowires */}
7:Call UpdateExistingActivePw(pw, addr); /*changes that require a session restart*/}
8:CallMergeInActivePw(pw);
```  
**Algorithm 3** Ldpd ()  
**Data Plane (VPP)** In this section, we explain the algorithms implemented in VPP [23] as our fast data plane to create VPLS based on Python APIs. The logical process for VPLS code in the Data Plane Development Kit (DPDK) is as follows:  
* Creation of l2 tunnel using the VppMPLSTunnelInterface algorithm;
* Addressing routes using VppMplsRoute;
* Bridge-domain using structured set_l2_bridge;
* Obtain the packages and address them;
* Packet encapsulation methods;
* Learning and forwarding part;
* The stream section of the packages in each direction;
* Disable Bridge domain after finishing work. In the following, the above items are described along with the structure in the corresponding platform. In (a) process: The VppMPLSTunnelInterface algorithm is called from the main algorithm VPP_Interface. The goal of this algorithm is to establish L2 on MPLS.