Building Distributed System To Handle Data in Internet of Things
Building Distributed System To Handle Data in Internet of Things
Supervisor
Dr. Mohamed Khaled Chahine Dr. Wassim Al-Juneidi
Second Semester
2020-2021
Abstract
The advent of Internet of Things (IoT) has kindled the possibility of umpteen number of
challenges. One of the major challenges in the realization of IoT applications is interoperability
among various IoT entities. Thus, the need for a new architecture comprising of smart control
and a number of common systems have been identified by researchers. Our goal is in this project
design a collaborative model and an architecture to take advantage of the available computing
resources. The main challenge is to manage and maintain large number of devices and react
smartly according to the data generated by them. So, we suggest the following a system based
on IoT, with Internet Information Services (IIS) for setting up web servers, an ASP.NET model
- view - controller (MVC) for establishing a remote, monitoring and control system by using
web browser or mobile application and a Microsoft SQL Server as the database with the web
browser connected to the Internet, where the sensor devices acquire the data and a send it to the
server that performs the hard processing, the sensing data sent to the server by using the TCP/IP
protocol, the users can provide instructions immediately without being present to check the
conditions, which considerably reduces labor and time costs. This approach can be used in a
i
Arabic Abstract
ظهور إنترنت األشياء أثار إمكانية وجود عدد اليحصى من التحديات ،أحد هذه التحديات الرئيسية هو
تحقيق التوافق بين مختلف تطبيقات ومنظومات إنترنت األشياء وهذا يحتاج الى بنية جديدة تتألف من
متحكم ذكي وعدد من االنظمة المشتركة يتم تحديدها من قبل الباحثين وهدفنا في هذا المشروع هو تصميم
نموذج وبنية مشتركة لالستفادة من جميع موارد الحوسبة المتاحة ويكون الهدف الرئيسي هو إدارة
المعلومات القادمة من االجهزة العديدة ،لذالك نقترح النظام التالي الذي يعتمد على إنترنت األشياء مع
خادمات معلومات اإلنترنت لبناء مخدمات ويب ونموذج صفحات الخادم النشط من اجل أنشاء نظام تحكم
عن بعد ومراقبة باستخدام متصفح الويب أو الهاتف المحمول باضافة الى قاعدة البيانات حيث تحصل
أجهزة االستشعار على البيانات وتقوم بإرسالها الى الخادم الذي يقوم بعمليات المعالجة الصعبة ،المعلومات
المرسلة الى الخادم تستخدم بروتوكول التحكم بالنقل ،ويستطيع المستخدم التحكم بشكل مباشر دون الحاجة
للتواجد قرب النظام مما يقلل بشكل كبير من التكاليف والوقت ،يمكن استخدام هذا المنهج في مجموعة
متنوعة من التطبيقات التي تعمل في بيئات مختلفة في ظل ظروف مختلفة حيث تتوافر مجموعة من انظمة
الحوسبة.
ii
Acknowledgment
It has been a great opportunity to gain lots of experience in real time projects, followed by the
knowledge of how to actually design and analyze real projects. For that we want to thank all
the people who made it possible for students like us. Special thanks to the graduation Project
Unit for the efforts they did to provide us with all useful information and making the path clear
for the students to implement all the education periods in real-time project design and analysis.
Furthermore, we all the professors and visiting industry for the interesting lectures they
presented which had great benefit for all of us. We would like to express our deepest gratitude
to our graduation project supervisor Dr. Wassim Juneidi for his patience and guidance along the
semester. In addition, we would like to express our sincere appreciations to Our department
head and graduation project coordinator Dr. Mohamed Khaled Chahine for his guidance,
continuous encouragement and support. Moreover, it is our duty to thank all the testing
iii
List of Contents
Abstract ...................................................................................................................................... i
Arabic Abstract ........................................................................................................................ ii
Acknowledgment .....................................................................................................................iii
List of Contents ........................................................................................................................ iv
List of Figures: ......................................................................................................................... vi
List of Tables: ......................................................................................................................... vii
List of Abbreviations .............................................................................................................viii
Chapter One Theoretical Study .............................................................................................. 1
1.1 Problem Description and Formulation ......................................................................... 2
1.2 Project Summary ............................................................................................................ 3
1.3 Concept of the System and Related Technologies ........................................................ 5
1.3.1 ASP.NET MVC architecture ................................................................................... 5
1.7.4 IoT-Disadvantages.................................................................................................. 23
iv
1.7.5 IoT Networking ...................................................................................................... 24
v
List of Figures:
Figure 1.1 Architecture of remote monitoring system. [1] ................................................... 4
Figure 1.2 MVC architecture.[2]. ............................................................................................ 5
Figure 1.3 Life cycle of an MVC. [2]. ...................................................................................... 5
Figure 1.4 The NET Remoting architecture. [4]. ................................................................. 12
Figure 1.5 WCF Contracts architecture. [6]. ....................................................................... 18
Figure 1.6 WCF Service Runtime architecture. [6]. ............................................................ 19
Figure 1.7 WCF Messaging architecture. [6]. ...................................................................... 20
Figure 1.8 WCF Activation and Hosting architecture. [6]. ................................................ 21
Figure 2.1 System Block Diagrams ....................................................................................... 28
Figure 2.2 ESP8266 Node MCU Module .............................................................................. 30
Figure 2.3 Temperature – Humidity (DHT11) Module ...................................................... 32
Figure 2.4 Port Diagram for IoT System............................................................................. 32
Figure 2.5 Light System ......................................................................................................... 35
Figure 2.6 Raspberry Pi Configuration Tool ....................................................................... 35
Figure 2.7 CCTV system ........................................................................................................ 36
Figure 2.8 Create new project ............................................................................................... 37
Figure 2.9 Create MVC project............................................................................................. 38
Figure 2.10 Simple MVC project .......................................................................................... 38
Figure 2.11 Add new controller ............................................................................................. 40
Figure 2.12 Server Start Screen ............................................................................................ 44
Figure 2.13 Server Screen ...................................................................................................... 45
Figure 2.14 Add View ............................................................................................................. 46
Figure 2.15 Dashboard Page .................................................................................................. 46
Figure 2.16 Add Website Page .............................................................................................. 49
Figure 2.17 WCFdemo Website ............................................................................................ 50
Figure 2.18 Publish WCF Service Page ................................................................................ 50
Figure 2.19 Service Reference ............................................................................................... 51
Figure 2.20 Database Diagram .............................................................................................. 52
Figure 2.21 Database Connection string .............................................................................. 53
Figure 2.22 Database Tables .................................................................................................. 54
Figure 2.23 The Database ...................................................................................................... 54
Figure 2.24 Login Page View ................................................................................................. 55
Figure 3.1 Various technologies to secure ASP.NET .......................................................... 57
Figure 3.2 Shows how each channel can be secured by using a combination of SSL, IPsec
and RPC encryption. [13]. ..................................................................................................... 60
Figure 3.3 Enabling SSL ........................................................................................................ 61
Figure 3.4 Project Url ............................................................................................................. 62
Figure 3.5 Project Home page ............................................................................................... 62
Figure 3.6 SQL Server Management Studio ........................................................................ 64
Figure 3.7 Enable windows Authentication ......................................................................... 65
Figure 4.1 Json.NET Performance. [15]. .............................................................................. 71
vi
List of Tables:
Table 1.1 Advantages and disadvantages of centralized versus distributed systems. [3]. . 7
vii
List of Abbreviations
viii
Chapter One
Theoretical Study
1.1 Problem Description and Formulation
Recent applications have been developed around the aforementioned concepts where sensing
and processing capabilities of the devices play an important role. These devices are usually
embedded systems and/or mobile devices such as smart phones, wearables, laptops, tablet PCs,
powerful driver for increased edge computing capabilities. Real-world use cases of artificial
intelligence combining with the Internet of Things. This evolution promotes a digital
transformation of the society by providing the citizens and professionals with advanced
applications for sensing and analyzing data on the ground. Due to the recent successes and the
anticipated breakthroughs in different fields, it has now become one of the most promising
research areas. Indeed, this fact is largely accelerated by new smartphones and communication
Handling simultaneous data flows, data processing and/or complex mathematical function
execution could overflow the computing capabilities of the embedded systems and mobile
devices. One approach to overcome this drawback consists in designing a distributed system
where the sensor devices are the distributed part to acquire the data and a centralized
infrastructure that performs the hard processing. The classical client/server architecture has
been designed for that purpose. Currently, this centralized infrastructure is usually deployed in
the Cloud. However, this shift introduces several new risks, and some bottlenecks and delays
may result from the communications among the devices and the centralized system. In
particular, the latter drawback is strongest for multimedia data, for example, in applications that
use video and image acquisition devices. For that reason, it is difficult to implement a
centralized multimedia analysis system in the cloud. To overcome these bottlenecks and delays,
this work extends our recent proposal of a distributed architecture to perform collaborative work
for IoT-based environments and sharing the application workload among the available devices.
This improved architecture takes into account the different network layers and their computing
2
platforms involved, from the remote Cloud servers to connected smart sensors and “things” The
approach aims at optimizing the use of computational resources of an IoT environment while
providing a framework able to obtain data from sensors, perform complex computational tasks
With the rapid development of the Internet in recent years, Internet-based applications such as
remote monitoring systems are becoming increasingly popular in industry. Through the
boundless Internet, a remote monitoring system allows the user to have remote real-time control
of the situation in a factory by using a smartphone or computer. In the future, factories will have
different types of devices, which will need to be integrated in an intelligent manner. Wireless
sensor networks (WSNs) are the base technology of the Internet of Things (IoT). A WSN is a
network that uses intelligent sensors to transmit and receive data. The applications of WSN
include health, environment, industrial, and traffic monitoring. WSNs have not only contributed
to the development of IoT but also led to the development of devices and technologies that
support the growth of the Internet, such as QR codes, intelligent phones, social networks, and
cloud computing. The open database connectivity (OBDC) method can be used for connecting
and transferring the data, for example through Microsoft SQL Server. The web server must be
established in order to provide a response to the client. Microsoft Internet Information Services
(IIS) is a service for setting up the web server and delivering data to the client in Extensible
Markup Language (XML) format. In recent years, developers have replaced XML with
JavaScript Object Notation (JSON) format to transfer data because JSON is a lightweight data
interchange format that is easy for humans to read and write as well as easy for machines to
parse and generate. JSON increases the decoding speed of a browser and improves the
architectural pattern to design a website because it provides a way to divide a given application
into three interconnected parts. The MVC design pattern decouples these major components,
3
enabling efficient code reuse and parallel development. A simple application for a remote
monitoring system is a web oscilloscope. The web oscilloscope delivers acquisition data, which
is stored in the database via TCP/IP and simulates a real oscilloscope to enable the user to easily
observe the signal plot of an electrical circuit. Other applications of remote monitoring include
video surveillance, appliance testing, and ocean monitoring. Because several studies have
proposed that the graphical interfaces are more acceptable for users than using numerical tables
as the interface, all these applications are designed with a friendly human machine interface to
intelligent devices, people use browsers for browsing websites on devices such as smartphones,
4
1.3 Concept of the System and Related Technologies
This project is a web application design based on the ASP.NET framework using Visual Studio 2019.
The coding languages used to establish the bridge between the server and client in the MVC structure
were C#, SQL, JavaScript, HTML, and CSS. Some popular libraries, such as Razor and jQuery, and a
In this study, an MVC architecture was adopted to design the web application for a remote the
IoT system. As shown in figure 2, the developer must divide an application into three types of
components:
• A model stores data that is then retrieved according to commands from the controllers.
• A view presents the data from the controller based on changes in the model.
• A controller decides the data flow and sends commands to the model and view.
Programming languages such as Java, C#, and PHP have popular MVC frameworks that are
used in web application development. In this study, the ASP.NET MVC framework was applied
to a remote the IoT system. The life cycle of an MVC architecture is presented in figure 3. The
entry point for every MVC application is URL routing. After the ASP.NET platform receives
5
a request from a browser, a controller determines how it should be handled. The controller then
determines the view and presents the view through URL routing. [2].
Microsoft SQL Server was adopted as a relational database management system to execute four
basic functions of a database. Using a database to store data acquired with an analog-to-digital
converter and establishing relations among each type of data is a common approach in industrial
systems. To connect the web application to an SQL Server, Entity Framework should be used.
Entity Framework can help a developer to relate the object in their code with a table in the
database. [2].
independent computers that cooperate with one another over a communications network in
order to achieve a specific objective. This definition pinpoints a number of aspects of distributed
systems. Although the elementary unit of a distributed system is a computer that is networked
with other computers, the computer is autonomous in the way it carries out its actions.
Computers are linked to one another over a communications network that enables an exchange
cooperation between computers for the purpose of attaining a common goal. [3].
nodes of the communications network along with details about the communications network
itself. In contrast, a logical view of a distributed system highlights the applications aspects. can
6
therefore also be interpreted as a set of cooperating processes. The distribution aspect refers to
the distribution of state (data) and behavior (code) of an application. The process encapsulates
part of the state and part of the behavior of an application, and the application’s semantics are
achieved through the cooperation of several processes. The logical distribution is independent
of the physical one. For example, processes do not necessarily have to be linked over a network
Advantages
increases availability when parts of a system fail. Applications that can easily be run
solutions. Distributed systems can be extended through the addition of components, thereby
Table 1.1 Advantages and disadvantages of centralized versus distributed systems. [3].
Disadvantages
The advantages offered by distributed systems are also countered by some disadvantages. The
more components in a system, the greater the risk that the rest of the system will suffer unless
7
special measures are taken in the event that one of the components fails. Special mechanisms
are needed to avert these failures and make them transparent to the user. Moreover, the many
components that make up a distributed system are potential sources of failures. Due to the
physical and time separation, consistency (for example, with distributed databases) is more of
a problem than with centralized systems. Leslie Lampert presents a (cynical) alternative
The client/server model introduces two roles that can be assumed by processes: the role of
service (client) and the role of service provider (server). The distribution of roles implies an
asymmetry in the distributed execution of an application. The server offers a service to which
one or more clients has access. Here processes act as natural units in the distribution. In the
context of distributed systems, the communication between client and server can be based on
one of the mechanisms of Remote Procedure Call (RPC) is an example of synchronous request-
oriented communication. The sender sends a request to the receiver and is passive until the
communication is Remote Service Invocation (RSI). During this type of communication, the
sender remains active while the receiver is processing the request. Although RSI makes better
use of the parallelism offered in distributed systems, RPC is based on popular programming
paradigms and is therefore intuitive in its interpretation. The RPC introduced in the last section
offers a fundamental communication mechanism for client/server interaction. The client is the
initiator of an RPC, and the server provides the implementation of the remotely executed
procedure. The request message contains all current input parameters for the procedure call.
Conversely, the response message contains all results for the corresponding request produced
by the server. The advantage of using remote procedure call as a communication mechanism
for the client/server model is that it incorporates procedural programming paradigms and is
8
therefore easily understood. The implementation of the procedure is an integral part of the
server, and the invocation of the procedure is part of the application running in the client. [3].
Advantages
An advantage of the client/server model is the intuitive splitting of applications into a client
part and a server part. Based on conventional abstractions such as procedural programming, it
simplifies the design and the development of distributed applications. Over and above this, it
makes it easy to migrate or integrate existing applications into a distributed environment. The
client/server model also makes effective use of resources when a large number of clients are
Disadvantages
From a different point of view, all these advantages could also be considered disadvantages.
For example, the restriction to procedural programming paradigms excludes other approaches
always ensure that transparency is maintained between local and remote procedure calls since
transparency can no longer be achieved in the case of radical system failure. The concurrency
mentioned earlier as an advantage can also lead to problems because of its requirement that
9
1.5 Remoting System
1.5.1 Overview
These contexts will normally resemble either different processes or machines. In the .NET
Framework, this technology provides the foundation for distributed applications. The
framework .NET includes .NET Remoting API that support the development of distributed
infrastructure comparable to the Java Remote Method Invocation (RMI) although the latter
adopts an entirely different internal architecture. Both frameworks allow objects on a client
infrastructure that permits objects that do not reside in the same memory space (or even on the
same host) to communicate with one another in a transparent fashion. This implies that every
message sent to a remote object will have to be delivered through an alternative mechanism.
Therefore, each message from a local (client) object to a remote (server) object will be
intercepted using a (double) proxy pattern. In addition, .NET Remoting gives you a flexible and
extensible framework that allows for different transfer mechanisms (HTTP and TCP are
supported by default), encodings Simple Object Access Protocol (SOAP) and binary come with
the framework), and security settings (Internet Information Services (IIS) Security and SSL
come out of the box). With these options, and the possibility of extending all of them or
10
applications. You can choose between HTTP-based transport for the Internet or a faster TCP-
based one for LAN applications by literally changing a single line in a configuration file. [5]
Several different architectures for the development of distributed applications already exist.
You might therefore wonder why .NET introduces another, quite different way of developing
those kinds of applications. One of the major benefits of .NET Remoting is that it’s centralized
around well-known and well-defined standards like HTTP and that it is directly tied to the .NET
Ease of Implementation
With .NET this concept of absolute ease of implementation has been extended to the
have to define your interfaces in a different programming. A unique feature is that you don’t
have to decide up front on the encoding format of remoting requests; instead, you can switch
from a fast TCP transport to HTTP by changing one word in a configuration file. You can even
provide both communication channels for the same objects by adding another line to the
configuration. [4]
Extensible Architecture
.NET Remoting offers the developer and administrator a vastly greater choice of protocols and
formats than any of the former remoting mechanisms. In Figure 8, you can see a simplified
view of the .NET Remoting architecture. Whenever a client application holds a reference to a
the destination object. This proxy will allow all of the target object’s instance methods to be
11
called upon it. Whenever a method call is placed to the proxy, it will be converted into a
The message will pass a serialization layer, the formatter which converts it into a specific
transfer format such as SOAP. The serialized message later reaches a transport channel, which
transfers it to a remote process via a specific protocol like HTTP or TCP. On the server side,
the message also passes a formatting layer, which converts the serialized format back into the
original message and forwards it to the dispatcher. Finally, the dispatcher calls the target
object’s method and passes back the response values through all tiers. [4].
Interface Definitions
.NET Remoting provides several different ways of defining those interfaces, as discussed in the
following sections.
• Shared Assembly
In this case, the server-side object’s implementation exists on the client as well. Only during
instantiation is it determined whether a local object or an object on the remote server will be
created. This method allows for a semitransparent switch between invoking the local
implementation (for example, when working offline) and invoking server-side objects (for
12
example, to make calculations on better-performing servers when connected to the
network).[4].
When creating a distributed application, you define the base classes or interfaces to your remote
objects in a separated assembly. This assembly is used on both the client and the server. The
real implementation is placed only on the server and is a class that extends the base class or
implements the interface. The advantage is that you have a distinct boundary between the server
This approach seems to be the most elegant one at first glance. You develop the server in the
same way as when using the shared assemblies method. Instead of really sharing the Dynamic-
link library (DLL) or EXE, you later extract the necessary metadata, which contains the
interface information, using SoapSuds that will either need the URL to a running server or the
name of an assembly as a parameter, and will extract the necessary information (interfaces, base
classes, objects passed by value, and so on). It will put this data into a new assembly, which
can be referenced from the client application. You can then continue to work as if you’d
Marshalling Data
Marshalling is the process of converting a data field, or an entire set of related structures, into
a serialized string that can be sent in a message. To marshall a binary number, one might convert
it to hexadecimal digit string, if the message format must be text. If the message will carry
binary data, the binary number might be converted into 4 little-endian normalized binary bytes
and sent that way. Pointers are harder; one often has to convert them into an abstract reference
(e.g., a "node number") that is independent of the actual memory locations. [5].
13
• Marshal-by-value objects:
These objects are copied and passed by value out of the application domain. When
copy of this object and passes the copy to the client application domain. The copy
hence received can handle any method call in client domain. Using Marshal-by-
• Marshal-by-reference objects:
The clients that use these objects need a proxy to access the object remotely. When
client calls a method on Marshal by reference object, the remoting system create
proxy object in the caller application that contains the reference of all method and
Serialization of Data
In .NET Remoting the encoding/decoding of objects is natively supported. You just need to
mark such objects with the [Serializable] attribute or implement the interface ISerializable and
The underlying .NET runtime formatting mechanism marshals simple data types and subobjects
(which have to be serializable or exist as remote objects), and even ensures that circular
Multiserver/Multiclient
When you use remote objects (as opposed to using copies of remotely generated objects that
are passed by value), .NET automatically keeps track of where they originated. So a client can
ask one server to create an object and safely pass this as a method’s parameter to another server.
The second server will then directly execute its methods on the first server, without a round trip
through the client. Nevertheless, this also means there has to be a direct way of communication
14
from the second server to the first one—that is, there must not be a firewall in between, or at
interoperability. It is one of the latest technologies of Microsoft that is used to build service-
Hypertext Transfer Protocol (HTTP) request is represented uniformly, WCF makes it possible
mechanisms. WCF was released for the first time in 2006 as a part of the .NET framework with
Windows Vista, and then got updated several times. 4.8 (2019) is the most recent version that
• WCF service.
• Message ─ This is a communication unit that comprises of several parts apart from the
body. Message instances are sent as well as received for all types of communication
specifies the communication mechanism to describe how the messages will be sent along
15
with defining the set of messages. A structure of an endpoint comprises of the following
parts:
o Address ─ Address specifies the exact location to receive the messages and is
scheme://domain[:port]/[path]
binding elements that make the infrastructure for communication. For example, a
binding states the protocols used for transport like TCP, HTTP, etc., the format of
• Hosting ─ Hosting from the viewpoint of WCF refers to the WCF service hosting which
can be done through many available options like self-hosting, Internet Information
between a client application and a WCF service. Normally, metadata for a WCF service
is generated automatically when enabled, and this is done by inspection of service and
its endpoints.
• WCF Client ─ A client application that gets created for exposing the service operations
in the form of methods is known as a WCF client. This can be hosted by any application,
16
1.6.3 WCF Features
• Service Orientation: one consequence of using Web services (WS) standards is the
(SOA) are the reliance on WEB services to send and receive data.
interoperability.
• Multiple Message Patterns: Messages are exchanged in one of several patterns. The
most common pattern is the request/reply pattern, where one endpoint requests data
from a second endpoint such as a one-way message in which a signal endpoint sends a
• Data Contracts: Because WCF is built using .Net Framework, it also includes code-
• Security: Messages can be encrypted to protect and you can require users to
implemented using well-know standers such as Secure Sockets Layer (SSL) or WS-
Secure Conversation.
• Multiple Transports and Encoding: Messages can be sent in any of several built-in
transport protocols and encodings. The most common protocols and encoding is to send
text encoded SOAP messages using is the HTTP for use on the World Wide Web.
Alternatively, WCF allow you to send message over Transmission Control Protocol
Remoting in which both the client and the service must have .Net.
17
• WCF services offer enhanced reliability as well as security in comparison to Active
• Implementing the security model and binding change in WCF do not require a major
change in coding. Just a few configuration changes are required to meet the
constraints.
• WCF has integrated Asynchronous JavaScript (AJAX) and support for JavaScript
WCF has a layered architecture that offers ample support for developing various distributed
applications.
Contracts
The contracts layer is just next to the application layer and contains information similar to that
of a real-world contract that specifies the operation of a service and the kind of accessible
information it will make. Contracts are basically of four types discussed below in brief:
18
• Service contract: This contract provides information to the client as well as to the outer
world about the offerings of the endpoint, and the protocols to be used in the
communication process.
• Data contract: The data exchanged by a service is defined by a data contract. Both the
client and the service has to be in agreement with the data contract.
the customization of the type formatting of the SOAP message parameters. Here, it
should be mentioned that WCF employs SOAP format for the purpose of
• Policy and Binding: There are certain pre-conditions for communication with a service
and such conditions are defined by policy and binding contract. A client needs to follow
Service Runtime
The service runtime layer is just below the contracts layer. It specifies the various service
behaviors that occur during runtime. There are many types of behaviors that can undergo
• Error Behavior ─ Defines the result of any internal service error occurrence.
19
• Metadata Behavior ─ Specifies the availability of metadata to the outside world.
• Instance Behavior ─ Defines the number of instances that needs to be created to make
• Dispatch Behavior ─ Controls the way by which a message gets processed by the
infrastructure of WCF.
• Concurrency Behavior ─ Controls the functions that run parallel during a client-server
communication.
Messaging
This layer, composed of several channels, mainly deals with the message content to be
communicated between two endpoints. A set of channels form a channel stack and the
two major types of channels that comprise the channel stack are the following ones:
• Transport Channels ─ These channels are present at the bottom of a stack and are
accountable for sending and receiving messages using transport protocols like HTTP,
• Protocol Channels ─ Present at the top of a stack, these channels also known as layered
20
The last layer of WCF architecture is the place where services are actually hosted or
can be executed for easy access by the client. This is done by various mechanisms
• IIS ─ IIS stands for Internet Information Service. It offers a myriad of advantages using
the HTTP protocol by a service. Here, it is not required to have the host code for
activating the service code; instead, the service code gets activated automatically.
• Windows Activation Service ─ This is popularly known as WAS and comes with IIS
7.0. Both HTTP and non-HTTP based communication is possible here by using TCP or
application. This mechanism offers amazing flexibility in terms of choosing the desired
• Windows Service ─ Hosting a WCF service with this mechanism is advantageous, as the
services then remain activated and accessible to the client due to no runtime activation.
[6].
IoT (Internet of Things) is an advanced automation and analytics system which exploits
networking, sensing, big data, and artificial intelligence technology to deliver complete systems
for a product or service. These systems allow greater transparency, control, and performance
when applied to any industry or system. IoT systems have applications across industries through
their unique flexibility and ability to be suitable in any environment. They enhance data
21
collection, automation, operations, and much more through smart devices and powerful
The most important features of IoT include artificial intelligence, connectivity, sensors,
active engagement, and small device use. A brief review of these features is given
below:
aspect of life with the power of data collection, artificial intelligence algorithms, and
networks.
Networks
can exist on a much smaller and cheaper scale while still being practical. IoT creates
• Sensors – IoT loses its distinction without sensors. They act as defining instruments
which transform IoT from a standard passive network of devices into an active
happens through passive engagement. IoT introduces a new paradigm for active
• Small Devices – Devices, as predicted, have become smaller, cheaper, and more
powerful over time. IoT exploits purpose-built small devices to deliver its precision,
22
1.7.2 IoT-Advantages
The advantages of IoT span across every area of lifestyle and business. Here is a list of some
significant flaws in accuracy and as noted, engagement remains passive. IoT completely
transforms this to achieve richer and more effective engagement with audiences.
• Technology Optimization – The same technologies and data which improve the
customer experience also improves device use, and aid in more potent improvements to
• Reduced Waste – IoT makes areas of improvement clear. Current analytics give us
superficial insight, but IoT provides real-world information leading to more effective
management of resources.
• Enhanced Data Collection – Modern data collection suffers from its limitations and its
design for passive use. IoT breaks it out of those spaces, and places it exactly where
everything. [8].
1.7.4 IoT-Disadvantages
Though IoT delivers an impressive set of benefits, it also presents a significant set of challenges.
over networks. The system offers little control despite any security measures. These
• Privacy – The sophistication of IoT provides substantial personal data in extreme detail
23
• Complexity – Some find IoT systems complicated in terms of design, deployment, and
maintenance given their use of multiple technologies and a large set of new enabling
technologies.
• Flexibility – Many are concerned about the flexibility of an IoT system to integrate
easily with another. They worry about finding themselves with several conflicting or
locked systems.
• Compliance – IoT, like any other technology in the realm of business, must comply with
regulations. Its complexity makes the issue of compliance seem incredibly challenging
The definition of cloud is quite accurately listing characteristics, service models and
deployment models, however it does not refer to networks. Networks in IoT are not in fact a
characteristic but they are enablers. One key-contributor factor for the success widespread of
IoT technology is in fact due to the raise of modern, fast, reliable, low-latency and low-cost
networks. Specifically, for IoT the most common network types range between Bluetooth,
traditional Wireless Local Area Network (WAN), cellular and a new generation of Lower-
Power Wide Area Network (LPWAN). Few network technologies have a clear advantage
compared to other. WLAN and Bluetooth technology are without any doubt the most common
type of consumer network in the market at the moment. They both work in a license-free radio
frequency band; they both ensure a good bandwidth transfer rate and they both requires fairly
inexpensive receivers. Limitation comes however from the fact that they have evident range
limitation that precludes them to be the main choice for being used in extensive IoT
applications. Range in fact is limited to few tens of meters in WLAN and few meters for
Bluetooth connection. As IoT industrial applications are intended to work mostly with devices
distributed in a wide area, often with bad cellular coverage, and that would require a strict power
24
management to extend the battery lifetime, a new technology of Lower-Power Wide Area
LPWAN are networks that combine technologies in order to achieve long distance, robust and
low-bit rate communications with battery operated sensors geographically located in a wide
area. [9].
25
Chapter Two
Practical Implementation
26
In this chapter we will study the main part to form the Distributed Applications that we will
2.1 Introduction
Developing and deploying applications are critical aspects of providing modern organizations
with new and innovative services while helping them maintain and operate their existing
technologies, .NET has been the de facto standard for Windows since it was first released by
environments to execute in, but also require a plethora of additional services, including, but not
limited to, relational databases, queuing middleware, authentication and authorization services,
file storage, networking, caching, and a variety of operational monitoring and logging
• Libraries for common web patterns, such as Model View Controller (MVC)
• Authentication system that includes libraries, a database, and template pages for
27
2.2 System Overview
The entire system is designed following to the principle of modularity. As shown below (figure
2.1), the system is modularized into 3 parts: field data collection module (IOT System), service-
oriented communication module (Web Server), and user application module (ASP.NET MVC).
Each part communicates with others following rigorous use of well-defined data interfaces.
Both the field system and remote system provide welding monitoring function and data query
function. The detailed function for each part will be shown in later sections.
28
2.3 Internet of Things System
The Smart House is the full controlled automated system designed efficiently to fit end user
requirements. The technical progress all around the universe assigned the buildings and the
houses to be equipped by Building Management System BMS that controls and monitors the
electrical devices in various environments based on Internet of Things (IoT) approach. The
electrical devices such as Air conditions, TVs, Ventilations, House Lights, and Irrigation
systems etc., need to be controlled to guaranty security developments, the benefits of the smart
1. Energy enhancement: The house lights and the devices can be controlled and monitored
permanently such that the lights or the devices can be turned OFF depending on the
and the house can be surrounded by cameras to capture the events with respect to motion
sensors. In addition, the smart house system can contain more features like fingerprints
and key cards that maximize system security for a little bit more.
3. Accessibility: the voice commands can help the incompetent persons to control house
gadgets and simplify the life based on this system such that all appliances such as air
conditions, TVs, multimedia players, etc. are controlled anytime throughout the house
5. Life time: The efficiency and the life time are expanded due to the reasons presented
above. [10].
29
2.3.1 Smart System Components
Arduino based ESP8266 Node MCU is a new microcontroller aspect that is created in
Arduino microcontroller specifications regardless AVR processors that lead the entire module
to be compiled by Arduino IDE C++ compiler. The module is considered a complete kit due to
the specification that was added the ESP board to reduce the individual sectors that needed to
be attached to the board in order to perform specific roles. The new ESP MCU module was
configured with respect to Arduino Uno board manager and SAM core. The term 'Core' was
given to the group of software units that are needed to compile the Arduino C++ headers by
using MCU language. The creativity of ESP8266 module leads to build robust and complete
systems due to the design methodology that developed Arduino core under the domination of
ESP8266 Wi – Fi based on GitHub ESP8266 core webpage. This module is learning software
platform that combines between ESP8266 and Node MCU firmware. The MCU module that is
shown in Figure 2.2 works under the supervision of 802.11n and 802.11b networks. This means
that it can serve as an Access Point AP, Wi – Fi station or both station and AP at the same time
[10].
30
Node MCU Specifications & Features
The ESP8266 ESP-01 is a serial to WiFi breakout module with a built in ARM microprocessor
that has 1MB of memory and 2 GPIOs brought out to the header for connecting to
peripherals. It can be used as a serial to WiFi bridge to add WiFi capability to a project or it
can even be programmed directly and used as a little stand-alone processor. It has full TCP/IP
The Temperature – Humidity sensor that is known by DHT11, reads and measures the
temperature and humidity degrees in a single distinctive model. Temperature (T) and Humidity
(H) Sensor are treated in a complex way with a calibration of digital signal output. The sensor
31
guarantees extraordinary reliability and exceptional long term stability due to the private digital
signal acquirement in the sensing technology. This module contains resistive humidity
microcontroller, offering excellent quality, fast response, anti-interference ability and cost
effectiveness. DHT sensor measures both (T) and (H) which hands the readings through
ESP8266 module with respect to Net Pie website. The module is constructed of three terminals
identified by Vcc, Data, and Gnd. The sensor acts well if linked with the digital pins of a
microcontroller. As the schematic connection demonstrated in Figure 2.3, VCC pin must be
provided by 5 V from ESP8266 MCU, the data is chosen to be connected to the digital pin D5
of ESP8266, and the Gnd terminal of the sensor is connected to the Gnd pin of ESP8266
board.[10].
Port Diagram
Since the proposed system is a distributed system, and for ease of connection with the main
controller, we used the ESP-01 model, which allows to connect all sensors wirelessly
(also known as RESTful API) is an application programming interface (API or web API) that
conforms to the constraints of REST architectural style and allows for interaction with RESTful
web services, when we request the IP address assigned to each sensor, the information is sent
{"sensor":"TemperatureSensor”,"DataT":'23.100000381469727',"DataH":'68.20607'}
In the Node MCU, there is a function to read the information and put it into variables to deal
with it.
pt::read_json("example.json", loadPtreeRoot);
pt::ptree temp ;
std::string name ;
std::string DateT ;
std::string DateH ;
name = temp.get_name ("Sensor");
DataT = temp.get_time("DataT");
DataH = temp.get_time("DataH");
The Hypertext Transfer Protocol (HTTP) works as a request-response protocol between a client
and server:
• Finally, the response contains status information about the request and may also contain
HTTP GET
GET is used to request data from a specified resource. It is often used to get values from APIs.[].
33
For example, you can have:
GET /update-sensor?temperature=value1&humidity=value2
HTTP POST
POST is used to send data to a server to create/update a resource. For example, publish sensor
The data sent to the server with POST is stored in the request body of the HTTP request:
api_key=api&sensor_name=name&temperature=value1&humidity=value2
This method is requested via the following link https://esp8266.local/Data and return the data
in JSON format
void getData() {
String mydataT = JSON.stringify(Temperature);
String mydataH = JSON.stringify(Humidity);
String input =
"{\"sensor\":\"Temperature\",\"Time\":'"+GetTime()+"',\"Date\":'"+GetData()+"',\"Data\":'"
+mydataT+","+mydataH+"'}";
server.send(200, "text/json", ""+input+"");
}
In addition to fetching information from sensors, there are also functions to control the ports
Void getSettings() {
String response = "{";
if (server.arg("LED_BUILTIN")== "HIGH"){
digitalWrite(LED_BUILTIN, HIGH);
}
else if (server.arg("LED_BUILTIN")== "LOW"){
digitalWrite(LED_BUILTIN, LOW);
}
response+="}";
server.send(200, "text/json");
}
The user can control the home lighting and other applications through the dashboard page
34
Figure 2.5 Light System
In addition, there are other functions for calculating the time and date when the event occurs,
the functions of communicating with the wireless network, and the functions of building a
REST server. The entire code will be included in the appendix and explained
For the monitoring system , we use Raspberry PI 4 and the Raspberry Pi camera, first we need
to connect the ribbon to the CSI connector to the Raspberry PI board and turn the raspberry on
$ sudo raspi-config
35
Creating a Livestream
:demux=h264
This creates an RTSP stream from the Raspberry PI camera that is accessible from the local
Each camera has its own link for example camera 1 link: http://192.168.1.14:5000
To test the practical performance of this system, we also develop a Web MVC application based
on C# language. The website provides basic data query service and remote monitoring function.
To make sure that the monitoring function is real-time, the website establishes a remoting
connection with the web server-based .NET Remoting library. MVC model been explained in
the theoretical section and here will be the steps to build the web application.
36
In this project we use Visual Studio 2019 So we downloaded and installed it on the device
Total
OS Name System Type Processor Physical Local Fixed Disk
Memory
Intel(R)
Core(TM) i7-
6700HQ CPU SSD
Microsoft
@ 2.60GHz, 117.7 GB
Windows 10 x64-based PC 15.8 GB
2601 Mhz, (126,406,950,912
Pro
4 Core(s), 8 bytes)
Logical
Processor(s)
In Visual Studio, from the File menu, select New -> Project. You will be presented to the New
Project dialog, where you select the project type, name and location. For this tutorial, we'll use
37
From the New ASP.NET Web Application dialog, select MVC
After some time, Visual Studio will create a simple MVC project using the default template,
as shown below.
As we talked briefly about earlier, the Controller acts as the middleman - it will combine
your Model with a View and serve the result to the end-user. However, neither a Model nor a
View is required - the Controller can act on its own for the most basic operations, e.g. delivering
However, there are a few things we need to do before adding a new controller to our project.
38
2.4.1 Adding MVC support to a Web project
We need to add MVC support to it, to let the .NET framework and the web server know how
to process incoming requests etc. to that let’s open the Startup.cs file in Visual Studio and look
for the ConfigureServices method. It's currently empty, but let's change that by adding the
services.AddMvc();
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapDefaultControllerRoute();
});
}
39
2.4.2 Add a Controller
Add our very first Controller to the project. Just right-click the new folder and select Add -
Visual Studio will offer to apply scaffolding to your new controller, which basically means that
it can be created with a range of methods for doing various stuff. However, this tutorial is all
about doing things from scratch, so you should select the one called something like "MVC
A new Controller will be generated for you and it will look like this:
namespace HelloMVCWorld.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
}
}
This is how a default project is built. For our project, we need to modify these default codes, so
we need two controllers one for home page and other for the Login page.
For the Home Controller at first, we include the library that we need for the work
The default library and extra for the model, remoting, database, etc.
40
using System.Web.Mvc;
using System.Net;
using ADPproject.Services.Remoting;
using ADPproject.Model;
using Newtonsoft.Json;
using IotLibrary;
and in the class, there is one ActionResult method.
ActionResult is a return type of a controller method, also called an action method, and serves
as the base class for result classes. Action methods return models to views, file streams,
redirect to other controllers, or whatever is necessary for the task at hand. The controller takes
The Dashboard method that handles the view for the IOT web page.
parameters to transfer a specific type of information that the user creates within the project
specifications.
The model classes represent domain-specific data and business logic in the MVC application.
It represents the shape of the data as public properties and business logic as methods.
A controller can have one or more action methods, and each action method can return a different
view, a view is used to display data using the model class object. The Views folder contains all
For the Dashboard view the code is included in the appendix due to its length but we will
mention the sections related to the project, The code consists of interfaces written in several
languages HTML5, CSS, JavaScript. This three-language use to make front-end framework
@model mvc_test.Models.sensor_v_m
@using (Html.BeginForm("remotingtest", "test"))
{
@Html.TextBoxFor(m => m.Id)
then to the web server over the remoting function remoting.Getsensor Which fetches the
To build the remoting system we must have the following three structures
1- (.dll) shared library that contain the remote class interface and the mobile object
2- Remoting server which builds a communication channel on a specific port and determines
the basic settings, which are the server activate object (SAO) and the client activate object
(COA)
3- Client In which a channel is defined and registered, a proxy is built and used
Now let’s talk about remoting.Getsensor struct, remoting is a class we create to connect the
ASP.NET with the Web server to exchange the data, .NET Remoting was explain in the
theoretical part.
remote object name prox and the Http channel to the server
(http://localhost:443/CustomerManger.soap)
SOAP is a protocol to transport data in XML format from the client to the server and back.[11].
The second section is Getsensor that connects with the clint to fetch information from the
getDB method in the server side who connect to the database and show it to the user in the view
page
MarshalByRefObjects.
MarshalByRefObject is the base class for objects that communicate across application domain
43
And the void main to Initializing the connection, we use port 443 because the connection is
secure uses HTTPS powered by Transport Layer Security (TLS) we'll talk about it in the other
section. And the remote and we choose the SAO as a single tone that is, create a single
Console.WriteLine("{0}:{1}:{2}:{3}", DateTime.Now.Hour.ToString(),
DateTime.Now.Minute.ToString(), DateTime.Now.Second.ToString(),
DateTime.Now.Millisecond.ToString());
Console.WriteLine("Server.Main: Server is listenning to port 443");
RemotingConfiguration.RegisterWellKnownServiceType(typeof(CustomerManger),
"customerManger.soap", WellKnownObjectMode.SingleCall);
Console.WriteLine("{0}:{1}:{2}:{3}", DateTime.Now.Hour.ToString(),
DateTime.Now.Minute.ToString(), DateTime.Now.Second.ToString(),
DateTime.Now.Millisecond.ToString());
API_to_DB.InsertData();
Console.ReadKey();
}
When we the project start the next screen shows that the server is running waiting for a request
44
The clint call for request, the server create a remote object contains the data from the Database
The communication between the clint and server it is done through a library called
IoTLibrary.dll that we have added to the project, in this library we need to define the remote
class interface that we use which is used by the server as inheritance and used by the client to
activator class is containing methods to create types of objects locally or remotely, or obtain
carry data between server and clint and the getDB method from the clint server
[Serializable]
public class readjson
{
public int sensor;
public string Data;
public string Time;
public string Date;
}
Serialization is the process of converting an object into a stream of bytes to store the object or
You can create a view for an action method directly from it by right clicking inside an action
45
The following creates a view from the Dashboerd() action method of the Home controller, as
shown below.
This will open the Add View dialogue box. It's good practice to keep the view name the same
as the action method name so that you don't have to explicitly specify the view name in the
Select the scaffolding template. Template dropdown will show default templates available for
Create, Delete, Details, Edit, List, or Empty view. Select "Empty" template because we want to
It shows the house temperature and humidity, the lighting control buttons, the CCTV system
buttons, the weather forecast, and other features, including household tasks, a generate report
46
2.7 WCF Architecture
There are four major layers that provide developers with a new service-oriented programming
model. The WCF architecture consists of the four layers explained in the theoretical section
Contracts (Layer 1): The contract layer contains various types of contracts and policy and
binding used in WCF. The various types of contracts present in the contract layer are as follows:
Service Contract: Service contract includes the operations performed by the service and
namespace WcfServiceLibrary
{
[ServiceContract]
}
Data Contract: Exposes the user defined data types and classes in a WCF service. [12]
[DataContract]
public class CompositeType
{
[DataMember]
public int Id { get; set; }
[DataMember]
public double Data { get; set; }
[DataMember]
public string Data { get; set; }
[DataMember]
public string Time { get; set; }
}
}
Operation Contract: Operation contract is used to expose the operations that a service can
perform. It defines the methods of a WCF service along with the parameters and return type
[ServiceContract]
public interface IDataService
{
[OperationContract]
sensor_activity GetData(int custID);
[OperationContract]
List<sensor_activity> GetDataL();
[OperationContract]
string InsertData(sensor_activity cust);
47
[OperationContract]
void UpdateData(sensor_activity cust);
[OperationContract]
void DeleteData(int custID);
}
Service Runtime (Layer 2): The service runtime layer contains the behavior of the service that
Messaging (Layer 3): Using the channels, the messaging layer processes the message that is
Activation and Hosting (Layer 4): This layer supports the execution of services in various
environments, such as Windows Services, IIS and Windows Activation Services (WAS). A
service can either be self-hosted or hosted in the context of another application and we use the
IIS: When a WCF service is hosted in IIS the client can access the service over the internet.
When a service is hosted in IIS, it acquires the benefits of IIS such as process lifetime
48
open IIS on your system. Or you can directly open IIS by typing inetmgr in run window like
below.
This will open a popup to input new website details. Input the following details in pop-up box.
49
To verify configuration, you can simply access the site in a web browser.
Next, we must run visual studio and publish the WCF on the IIS site
After we publish the WCF service we can add our services to the web server
50
as a service reference from the project solution we choose add service reference and the
Press ok this will result in a proxy class created in the web server
SQL Server databases are some of the most common databases in use, to create a database and
start entering your information first we need to Install the SQL Server Management Studio
software than Start up SQL Server Management Studio. If you already have a server up and
running, and have the permissions necessary to connect to it, you can enter the server address
and authentication information. If you want to create a local database, set the Database Name
51
Next, we need to Locate the Database folder after the connection to the server, either local or
remote, is made, the Object Explorer window will open on the left side of the screen. At the top
of the Object Explorer tree will be the server you are connected to. if it is not expanded, click
Create a new database. Right-click on the Databases folder and select "New Database...". A
window will appear, allowing you to configure the database before creating it.
Create a table. A database can only store data if you create a structure for that data. A table
holds the information that you enter into your database, and you will need to create it before
you can proceed. Expand the new database in your Database folder, and right-click on the
Windows will open on the rest of the screen which will allow you to manipulate your new table.
The database for the project simple we need two table one for the sensors data and other for the
users, in the sensors data it is highly recommended that you create a Primary Key as the first
column on your table. This acts as an ID number, or record number, that will allow you to easily
recall these entries later. In the sensors data table there will be five field (ID, Data, Time, Date,
User ID) for each sensor, for every user has a ID and User ID to fetch the correct information
of each user, time and date to record the timestamp of an event and data field so the database
key is a column or group of columns in a relational database table that provides a link
between data in two tables So we can connect each data to their user.
The process of recalling the information from the database will be done through a method called
1- add new item to the project called ADO.NET entity we will choose EF designer from
database the after name it and press next the following tap will show
53
2- the next tap for choosing the tables from the database for the project
3- choose out the tables then press finish and the database will appear as follows
The information is called from the database using the following code:
54
2.9 Login Page
In order to have a page dedicated to each user through which he controls the different
applications, we need to have a username and password for each user to be entered through a
page to connect to his dashboard panel therefore, a special controller was created for this page
the database of users and find the name and password than compare them
55
Chapter Three
Secure ASP.NET
56
3.1 Introduction
Security is a broad topic. Research has shown that early design of authentication and
data, including credentials, passed to and from your application, and between application tiers.
There are many technologies used to build .NET Web applications. To build effective
fine-tune the various security features within each product and technology area, and how to
make them work together to provide an effective, defense-in-depth security strategy. [13].
57
3.2 Designing an Authentication and Authorization Strategy
challenging task. The good news is that proper authentication and authorization design during
the early phases of your application development helps to mitigate many top security risks. [13].
The following steps identify a process that will help you develop an authentication and
1. Identify resources
Identify Resources
Identify resources that your application needs to expose to clients. Typical resources include:
• Web Server resources such as Web pages, Web services, static resources
• Network resources such as remote file system resources and data from directory
• Role based. Access to operations (typically methods) is secured based on the role
membership of the caller. Roles are used to partition your application's user base into
sets of users that share the same security privileges within the application; for example,
• Resource based. Individual resources are secured using Windows ACLs. [13].
58
Choose the Identities Used for Resource Access
Choose the identity or identities that should be used to access resources across the layers of
your application. This includes resources accessed from Web-based applications, and
Many applications pass security sensitive data across networks to and from end users and
between intermediate application nodes. Sensitive data might include credentials used for
authentication, or data such as credit card numbers or bank transaction details. To guard against
unwanted information disclosure and to protect the data from unauthorized modification while
59
Secure communication provides the following two features:
Privacy. Privacy is concerned with ensuring that data remains private and confidential, and
cannot be viewed by eavesdroppers who may be armed with network monitoring software.
Integrity. Secure communication channels must also ensure that data is protected from
In this typical deployment model, a request passes through three distinct channels. The client-
to-Web server link may be over the Internet or corporate intranet and typically uses HTTP. The
remaining two links are between internal servers within your corporate domain. Nonetheless,
all three links represent potential security concerns. Many purely intranet-based applications
convey security sensitive data between tiers; for example, HR and payroll applications that deal
Figure 3.2 shows how each channel can be secured by using a combination of SSL, IPsec and RPC encryption. [13].
The choice of technology depends on a number of factors including the transport protocol,
To secure sensitive data sent between a browser and Web server, use SSL/TLS is used to
60
You are using Forms authentication and need to secure the clear text credentials submitted to
You are using Forms authentication and need to secure the clear text credentials submitted to
Your application passes sensitive data between the browser and Web server (and vice-versa);
2. Enable the SSL Enabled option and copy the SSL URL.
Now just right-click on the application and select the Properties option.
Select the Web tab from the left pane, and paste the SSL URL into the Project URL box.
61
Figure 3.4 Project Url
Select the HomeController.cs from the Controllers folder and add the following highlighted
code to edit:
namespace WebApplication1.Controllers
{
[RequireHttps]
public class HomeController : Controller
{
public ActionResult Dashboard()
{
return View();
}
}
Now press Ctrl+F5 to run the application and follow the instructions to trust the self-signed
certificate generated by IIS Express.
After clicking on Yes, the Security Warning wizard opens and click Yes to install the
certificate representing the localhost.
Now, when you run the application using Internet Explorer (IE), it shows the Home Page of the
application and there is no SSL warning.
The transport channel between a Web server and a remote application server should be secured
by using IPsec, SSL or RPC Encryption. The choice depends on the transport protocols,
Enterprise Services. If your remote server hosts one or more serviced components (in an
Enterprise Services server application) and you are communicating directly with them (and as
Web Services. If your remote server hosts a Web service, you can choose between IPSec and
SSL.
You should generally use SSL because the Web service already uses the HTTP transport. SSL
also allows you to only encrypt the data sent to and from the Web service (and not all traffic
sent between the two computers). IPSec results in the encryption of all traffic sent between the
two computers.
.NET Components (using .NET Remoting). If your remote server hosts one or more .NET
components and you connect to them over the TCP channel, you can use IPSec to provide a
secure communication link. If you host the .NET components within ASP.NET, you can use
For the server and clint side we have to change the code for the register channel
channel implements ISecurableChannel, and if so, enables encryption and digital signatures.
63
3.3.3 Application Server to Database Server
To secure the data sent between an application server and database server, you can use SSL. Or
Windows authentication. One of the key benefits of using Windows authentication to SQL
Server is that it means that the credentials are never passed across the network.[13].
Open SQL Server Management Studio. And connect to the SQL Server.
On the Security page under Server authentication, select SQL Server and Windows
64
Figure 3.7 Enable windows Authentication
To offer secured content, a server greets the client with a trusted certificate, issued by a known
authority. The certificate has a limited time validity and must be renewed from time to time.
we'll generate a SSL certificate and use it on ESP8266 web server. [13].
For ESP8266 compatibility, the certificate must use SHA256 and the key length must be either
512 or 1024 bits. A 512 bits RSA key will make ESP8266 respond faster, but it is considered
weak by modern browsers. For better security, use 1024 bits RSA key. The trusted CA should
give you both the certificate and the private RSA key. We intend to use OpenSSL to generate
the certificate and the private RSA key. Getting OpenSSL on Linux is easy since most
distributions already have it installed and you can find it in software repositories
65
Launch openssl on the command line, from the folder where you want certificate and key to be
generated. It is possible to generate both key and certificate using a single command:
req -x509 -newkey rsa:1024 -sha256 -keyout key.txt -out cert.txt -days 365 -nodes -subj "/C
=RO/ST=B/L=Bucharest/O=OneTransistor [RO]/OU=OneTransistor/CN=esp8266.local" -a
ddext subjectAltName=DNS:esp8266.local
the rsa:1024 specifies key length in bits, while in the second approach, last argument
of genrsa is used for this. The -days parameter specifies certificate validity starting from the
this: subjectAltName=DNS:esp8266.local,IP:192.168.1.184.
namespace BearSSL {
using ESP8266WebServerSecure =
esp8266webserver::ESP8266WebServerTemplate<WiFiServerSecure>;
-----BEGIN CERTIFICATE-----
-----END CERTIFICATE-----
66
)EOF";
)EOF";
67
Chapter Four
68
4.1 Introduction
Centralized systems may have helped build the internet, but they have important disadvantages.
and organizations. It affects almost everyone who uses the web. It’s at the core of the
development and evolution of networks, financial systems, companies, apps, web services, and
more.
While all these systems can function effectively, some are more stable and secure than others
by design. Systems can be very small, interconnecting only a few devices and a handful of
users. Or they can be immense and span countries and continents. Either way, they face the
The topic of “Distributed Systems and Internet of Things” represents a vision in which the
Internet extends into the real world embracing everyday objects. Physical items are no longer
disconnected from the virtual world, but can be remotely controlled and can act as physical
access points to Internet services. The back end of these physical access points is a
mobile and Cloud computing. This topic arises from synergically merging IoT and distributed
computing.[14].
69
4.4 Why use .NET?
A few benefits of using .NET and WCF Web API instead of other web services frameworks.
using .NET and WCF for the web services framework can ease many pains, such as having to
create the clients and authorizing the clients that can communicate.
WCF ASP.NET
Enables building services that support HTTP only. First-class programming model for
multiple transport protocols (HTTP, HTTP. More suitable for access from various
TCP, UDP, and custom transports) and browsers, mobile devices etc enabling wide
Enables building services that support Enables building Web APIs that support wide
multiple encodings (Text, MTOM, and variety of media types including XML, JSON
Supports building services with WS-* Uses basic protocol and formats such as HTTP,
standards like Reliable Messaging, WebSockets, SSL, JSON, and XML. There is
Duplex message exchange patterns. patterns can be supported through SignalR and
WebSockets integration.
WCF SOAP services can be described There is a variety of ways to describe a Web
in WSDL allowing automated tools to API ranging from auto-generated HTML help
70
generate client proxies even for services page describing snippets to structured metadata
4.5 Performance
The performance of WCF and ASP.NET is good. Neither framework causes any problems in
• CPU and RAM resources available for the programs to run; ASP.NET Web API can be
hosted in a program.
• Network bandwidth and throughput.
• Other services running in the background.
• Time required by data engines to return the data, or to load the data from the memory
or files.
The rest of the stuff is performed by the ASP.NET Web API to serialize the data to JSON format
and send the data over the network. Most of the times, serialization and deserialization of data
can also take time; Luckily, ASP.NET Web API uses the Newtonsoft.Json API to perform data
any performance factor a hard time. This is what makes ASP.NET Web API a very powerful
4.6 Conclusion
In this work, the up-to-date web technologies were utilized to render the whole home
automation system a distributed type with the processes as services. The cloud portion of the
distributed system involves the web applications integrated with data management and
operations through HTML5 based web applications and services development for intuitive GUI
web applications. Similarly, modular design concept was adopted in the embedded hardware
development for better functionality and greater reliability. A robust data communication
protocol to ensure seamless communication between the individual applications and systems
was deployed. Relatively, a high level of security by the virtue of the robust web service security
protocol deployed was realized. Overall, the system provides a cost-effective solution to home
automation as the costs of a dedicated public IP address and a high-end computer, as present
protocol, Message Queuing Telemetry Transport (MQTT), an extremely simple and lightweight
machine-to-machine, messaging protocol built on WebSocket for constrained devices and low-
72
73
Reference:
[1]-Higinio Mora, &María Teresa, &David Gil 2018, Collaborative Working Architecture for
University of Alicante,
[2]-Kuang-Chi Kao. 2018. Design and development of an IoT-based web application for an
Taiwan.
[4]-Mario Szpuszta, & Ingo Rammer. Advanced .NET Remoting, Second Edition, Retrieved
from https://vdocuments.site/advanced-net-remoting.html.
[5]-Bert Vanhooff, & Davy Preuveneers, Yolande Berbers. (2006). '.NET Remoting and Web
Services:' A Lightweight Bridge between the .NET Compact and Full Framework. Department
<https://www.tutorialspoint.com/internet_of_things.htm>.
[9]-Andrea Finardi (4 June 2018). IoT Simulations with Cisco Packet Tracer
[10]-Dlnya Abdulahad Aziz 2019, ‘Design of Smart House System based on Webserver
74
[11]-C# Corner, Ksasikumar, accessed 15 Jun 2021, < https://www.c-
sharpcorner.com/article/net-remoting/>
https://www.onetransistor.eu/2019/04/https-server-on-esp8266-nodemcu.html>
distributed-centralized/>
[15]-Hack.guides, Afzaal Ahmad Zeeshan, accessed 22 July 2021, Using ASP.NET Web API
75
جامعة اليرموك الخاصة
كلية هندسة المعلوماتية واالتصاالت
قسم هندسة المعلومات واالتصاالت
الفصل الثاني
2020-2021