This book focuses on the integration of blockchain technology for IoT systems, exploring the methodologies behind each component of the system to bolster the data security and protect privacy. It also discusses the essential algorithms necessary for the efficient implementation of blockchain in IoT systems to provide security and privacy. With the advancement of Internet of Things (IoT), ensuring data security and privacy has become a critical concern due to the significant economic value associated with IoT data. This book presents algorithms that encompass the processes, starting with the generation of a block containing IoT data to the finalization of the consensus. These algorithms provide realistic methods for effectively integrating blockchain into IoT systems. The primary objective is to thoroughly examine the process of integrating decentralization paradigm into a conventional centralized system to address persistent problems. This book is appropriate for advanced-level students in computer science and electrical engineering, who are studying relevant subjects such as the Internet of Things, blockchain, wireless communications and artificial intelligence. Researchers and professionals working in blockchain-based IoT or equivalent fields will want to purchase this book as well. Preface Contents Acronyms 1 Introduction 1.1 Internet of Things 1.1.1 Communications in IoT 1.1.2 Architecture of IoT System 1.1.2.1 Basic Architecture 1.1.2.2 Edge Computing 1.1.3 Challenges of IoT System 1.2 Blockchain 1.2.1 Hash Function 1.2.2 Block Structure 1.2.3 Transaction 1.2.4 Blockchain Category 1.2.5 Features of Blockchain 1.3 Necessity of Blockchain-Based IoT 1.3.1 Limited Capability 1.3.2 Latency and Throughput 1.3.3 Implementation Feasibility 1.4 Aim of the Monograph References 2 Architecture of BIoT 2.1 Introduction 2.2 Related Works 2.3 Multilayer and Multi-ledger Blockchain 2.3.1 Multilayer Blockchain 2.3.2 Ledger Structure 2.3.3 Transaction and Block Design 2.3.4 Consensus Algorithm 2.3.5 Smart Contract 2.3.6 Example Procedure of the Provided BIoT System 2.4 Advantages of Blockchain-Based IoT 2.5 Summary References 3 Transaction Migration Scheme for BIoT 3.1 Introduction 3.2 Related Works 3.3 System Model 3.3.1 Transactions Migration Latency 3.3.2 Block Generation Latency 3.3.3 Block Consensus Latency 3.3.4 Objective 3.4 DDPG-Based Transaction Migration Scheme 3.4.1 MDP Model Formulation 3.4.1.1 State Set 3.4.1.2 Action Set 3.4.1.3 State Transition Function 3.4.1.4 Reward Function 3.4.2 Transaction Migration Scheme 3.4.2.1 Actor and Critic Networks 3.4.2.2 Action Refinement 3.4.2.3 Training Procedure 3.5 Performance Evaluation and Analysis 3.5.1 Simulation Setup 3.5.2 Numerical Results and Analysis 3.6 Summary References 4 Lightweight Consensus Mechanism for BIoT 4.1 Introduction 4.2 Related Works 4.3 System Model 4.3.1 Scenario Description 4.3.2 Communication Model 4.3.3 Leader Selection Model 4.3.4 Block Consensus Model 4.3.5 Objective 4.4 DQN-Based RAFT+ Algorithm 4.4.1 MDP Model Formulation 4.4.1.1 State Set 4.4.1.2 Action Set 4.4.1.3 State Transition Function 4.4.1.4 Reward Function 4.4.2 Leader Selection Scheme 4.5 Performance Evaluation and Analysis 4.5.1 Simulation Setup 4.5.2 Numerical Results and Analysis 4.5.3 Fault-Tolerant Performance Analysis 4.5.3.1 Block Inconsistency 4.5.3.2 Network Fragmentation 4.6 Summary References 5 Prototype Implementation of BIoT 5.1 Introduction 5.2 Related Works 5.2.1 Implementations of LoRa Systems 5.2.2 Blockchain-Enabled LoRa Systems 5.3 Overview of LoRa System 5.3.1 Network Reference Model 5.3.2 Basic Features and Categories of LoRa Data 5.4 Design of HyperLoRa System 5.4.1 Architecture with Multiple Ledgers 5.4.1.1 Network Ledger 5.4.1.2 Application Ledger 5.4.2 Edge Computing in LoRa Gateways 5.4.2.1 Join Procedure Handling 5.4.2.2 Application Package Processing 5.5 Security Analysis 5.5.1 DoS Attack on Application Layer 5.5.2 Single Point of Failure 5.5.3 Malicious LoRa Gateway 5.5.4 Malicious Network Server 5.6 Experimental Results and Analysis 5.6.1 Implementation with Hyperledger Fabric 5.6.2 Experimental Setup 5.6.3 Results and Analysis 5.7 Summary References 6 Conclusion and Outlook 6.1 Conclusion 6.2 Open Challenges Index