## 3 Proposed Methodology
### Mud-Ring Algorithm for Switch Selection
'\(FT\)' represents the flow table usage factor, which asseses the switch flow table utilization rate. After evaluating the fitness function, it updates the new position to select an optimal switch; otherwise, it goes to check other switches in the network for '\(i=i+1\)' times. **Step 4:** Assess the software entities fitness function with respect to proximity to the selected switch and overall network conditions. Select the best switch for routing based on factors such as proximity, flow table usage, and network metrics to maximize flow table efficiency. **Step 5:** The procedure concludes upon selecting an optimal switch for routing. Figure 2 shows the flow chart of the Mud-Ring algorithm. The proposed research work uses a blockchain-based approach and searchable encryption algorithms to secure data flow rules and prevent security threats in an SDN environment. Searchable encryption ensures confidentiality and tamper-proof flow rules, allowing secure query processing without decryption, which is explained in Algorithm 2. Figure 2: Flow chart of mud-ring algorithm. ```
Input: a protection metric '\(\theta\)'. Output: Document identifiers '\(ID(Doc)\)'. 1. while generating random keys \(M_{key}\), \(S_{key}\), \(\left(Pub_{key},Pry_{key}\right)\leftarrow\left\{0,1\right\}^{\theta}\), send \(Pub_{key}\) to the membership server do /* Cryptographic keys */
2. if certification is achieved by center verification, then
3. get Signature '(Sign)' / \"\"Sign\" symbol indicates digital signature */
4. else
5. Exit
6. end if
7. for \(\mathbf{1}\leq\mathbf{g}\leq|\mathbf{a}|\), \(\mathbf{1}\leq\mathbf{v}\leq|Doc|\), \(\mathbf{b}\gets J_{key}(A_{g})\mod\mathbf{Q}\), Compute '\(Encrp(ID(Doc_{\mathbf{a}}))\), store it in \(B[\mathbf{1}][\mathbf{g}]\), get index table '\(T\)' and encrypted set of documents do /* \(T\)' denotes Index table */
8. if the client's identity is confirmed via _Sign_
9. then the query function is updated with the '\(T\)'. 10. else if the client proposes a transaction, then
11. start practical byzantine fault tolerance, the most recent transaction is verified and added to the blockchain ledger. 12. else if a trapdoor \((\mathbf{D}_{T})\) transmitted by the client, '\(\mathbf{p}==\mathbf{J}_{key}\left(\mathbf{e}.\mathbf{b}^{-1}mod\mathbf{Q}\right)^{\prime}\) then
13. \(\mathbf{L}[\ ]\leftarrow Encrp_{key}(ID(Doc_{i}))\), /* Encrypted document identifiers '\(Encrp_{key}(ID(Doc_{i}))\)'. */
14. else
15. get \(Decr_{key}(\mathbf{L}(\mathbf{o}))\), \(ID(Doc)\) /* Decrypted document identifiers */
16. end if
17. end for
18. end while
```  
**Algorithm 2**Searchable encrypted data query algorithm  
Where '\(M_{key}\)' is master key, '\(S_{key}\)' is session key, '\(Pub_{key}\), \(Pr^{\prime}_{key}\) are public and private keys respectively. '\(|a|\)' is total quantity of different keywords recognized, '\(J_{key}\)' hash function '\(J\)' uses the client's master key, '\(g\)' is a threshold set. '\(Q\)' is prime number used in modular arithmetic. '\(B\)' is array storing encrypted document identifiers. Algorithms 2 and 3 show the encryption and decryption steps of the proposed algorithm. '\(L\)' a set of encrypted document IDs, '\(e^{\prime}\) is encrypted value, '\(p\)' is a decrypted value being checked against a condition. '\(O\)' is an index within the set '\(L\)'. ```
Input: Master key '\(M^{\prime}_{key}\) and a set '\(L\)' of encrypted document '\(ID\)'. Output: Document identifiers '\(ID(Doc)\)'. 1. while you start start decryption, do. 2. for \(\mathbf{1}\leq\mathbf{o}\leq\mathbf{size\ of\ L}\) do /* \"\(L\)\" denotes set of encrypted IDs*/
3. \(Decr_{key}(\mathbf{L}(\mathbf{o}))\) /* Decryption key for set of document IDs*/
4. end for
5. end while
```  
**Algorithm 3**Decryption algorithm  
Blockchain is a distributed ledger that records flow rule changes and access requests, ensuring transparency and immutability. It is crucial for traffic management and network security. The decentralized nature reduces the risk of a single point of failure.