A Simulation Based Proactive Approach for Smart Capacity Estimation in the Context of Dynamic Positions and Events

A R T I C L E I N F O A B S T R A C T Article history: Received: 30 August, 2020 Accepted: 31 October, 2020 Online: 20 November, 2020 Technologies are growing with the passage of time and providing solutions for the existing problems. One of such problems is to manage the crowd according to available capacity. Especially when the crowd density is dynamic because of dynamic position of the persons (Pilgrims). Not only dynamic position of the pilgrims makes crowd capacity dynamic but also special events increase and decrease in number of pilgrims that affect the capacity in a specific place. Therefore, it is not an easy job to estimate the available capacity according to the dynamic position and event. To overcome such problems of dynamic position and event-based crowd management different techniques and approaches are adopted. To solve the above-mentioned problem, this paper proposes a proactive approach to estimate the space occupy by the pilgrims in different positions in a zone or level. Maximum capacity in each zone and level is define on the basis of each position. On the basis of maximum and occupy capacities, available (remaining) capacity has been estimated in a zone and level according to the events such as Pilgrimage, Ramadan, Jummah etc. The occupied and available capacities in a zone, level or in the whole building can be estimated with the help of technologies such as Wireless Sensor Network (WSN), cloud computing, Internet of Things (IoT) and sensor topologies according to position and event. Simulation shows different scenarios according to the zones and different levels of building to prove the proactive approach. According to the results, it is concluded that zones, levels and point of entrances should be allocated to the pilgrims to avoid the congestion problems. Further for massive crowd and large area multi sink solution is better than single sink solution to estimate available capacity.


Introduction
Capacity estimation plays a vibrant role to maintain equilibrium among the maximum, occupied, and remaining capacities so that number of the persons can be allowed to enter in a zone, level or in a building [1]. Number of the persons permitted to enter an area directly dependent on the remaining capacity [2]. Although image-based method does not depend on the crowd to carry any type of device and counting can be performed without handling of device by the crowd. But the crowd counting done on the basis of images, does not provide result in case of dark or fade environment [3]. To provide the population awareness globally, crowd analysis can be done on the basis of video imagery to calculate and estimate the density of the crowd. It is considered an important tool of analysis for crowd density estimation at public places. Other methods also involve counting by performing the detection method or by using the clustering method for crowd estimation. Due to the more crowded environment one of the recent ways is regression. It has the capability to handle large crowded area [4]. The proposed proactive approach for capacity estimation is to calculate the number of the persons entering and exiting from the certain area. It is estimated according to the maximum capacity on the occasion of different positions and events. The sensor devices have the capability to sense and collect data at a given zone, level, building or an area [5]. In a specific scenario, data may include person ID (pilgrim ID), device ID, zone and level number, date and time for entry and exit etc. The sensed data then can be forwarded to the cluster head, then to a sink or ASTESJ ISSN: 2415-6698 server at each level and finally to central cloud storage location in order to calculate the remaining capacity of the areas. For different statistics, cloud computing can play a vibrant role to use the stored data. With the help of IoT data can be forwarded to different stakeholder for timely information to manage the crowd according to the position and events.
To overwhelm the problem of estimation of the capacity in different position and event, proposed proactive approach is one of the efficient solutions to provide advantages including: • Counting number of pilgrims without human intervention • Set the maximum capacity for different positions (Prayer, Walking, Sitting, Standing) • Capacity estimation for different zone, Mataf area and on each level • Capacity estimation according to Extreme crowded events such as, Jummah prayer, Ramadan, Eidain, Pilgrimage • To restrict the pilgrims if they already performed Umrah so that remaining pilgrims can get opportunity • Lost pilgrims can be traced within the coverage area One of the central pillars of Islam is also Pilgrimage. Approximately 3.5 million pilgrims assemble to perform pilgrimage in the holy city of Makkah [6]. In the month of Ramadan millions of people gather to perform Umrah and other prayers [7]. Pilgrims perform different supplications at different places and time to achieve the Pilgrimage or Umrah requirements. To perform the Umrah during Ramadan people persist around the Masjid Al-Haram. The estimation of available capacity inside the Masjid Al-Haram, may be calculated by number of pilgrims in a specific zone, or level minus maximum threshold of the capacity. It has been observed that it is problematic to estimate capacity for a massive dynamic crowd, the number of pilgrims entered in Masjid Al-Haram and what is the remaining capacity inside? When it exceeds to maximum capacity? In this paper, we try to solve the above-mentioned problem by exploiting WSN. We proposed a proactive approach to process the data for different zones and levels to estimate available capacity. As I myself perform the Jummah Prayer many times, The Holy Masjid Al-Haram was so much overcrowded that it became difficult to perform Sajood and Tashahud. It is because of wrong capacity estimation of zone or level.
This paper is an extension of our previous work accepted in The International Arab Conference on Information Technology ACIT'2019 [1]. The extension includes capacity estimation of dynamic position, event, study of sensor topologies and proactive approaches.

Paper Layout
In section 2, we briefly discussed the technologies used in our proposed proactive approach that includes the technologies such as cloud computing, IoT, clustering and WSN. In Section 3, there are briefly given the approaches or strategies at present used for capacity estimation. Section 4 depicts the proposed proactive approaches according to zone, level and for the whole building. Section 5 elaborates the use case, section 6 offers comparison between existing and proposed capacity estimation, section 7 defines the algorithms, section 8 simulation and results, section 9 gives discussion and section 10 conclusion and future directions.

Cloud Computing
Cloud computing is one of the most important technologies for proposed proactive approach. In cloud computing, cloud resources are located at different physical places. But via internet cloud computing makes efficient cloud services available globally to a large number of consumers located on many geographical locations [8], [9]. In a cloud computing environment, wearable devices are suggested for supportive communication between wearables and cloud server. Wearable device can be accessed remotely via the Internet [10]. Moreover, its everything-as-servicemodel (XaaS) impacts its clients and creators with many benefits [11]- [13]. Cloud computing is cost effective for the customers and uses the strategy "pay as you go" [14] [15]. To process and access information in a more accurate way, cloud based software architecture has been proposed [16], [17]. Sensors, actuators and many other embedded devices are considered as a data generation source that provide help to enable IoT edge computing to process data [18]. Cloud can store the data according to the position, event and zones for future planning to control the massive crowd.

Internet of Things (IoT)
IoT lets people/anybody and things/devices connect anyone, anything, anytime, anywhere, for any service. Although it is flexible, complex and dynamic network infrastructure as given in [19]. In many fields such as healthcare, smart homes, smart cities, retail, traffic, security, and agriculture, IoT offers multiple solutions [20]. With the help of an IoT we can monitor the elements such as wind, crops, soil, atmosphere, lights and water over a big area [21]. For the growth of the IoT, there is a need of plentiful resources for the development of the intelligent devices and the WSNs. The core building blocks are the same for network communication in between devices to build an Internet of the Things setup [22]. With up to date development and advancement in the field of information and communication technologies, it also brought positive changes in the advancement and development of IoT. Through low-cost electronic devices and communication IoT paradigm improves human collaboration in the physical world [23], [24]. In the same way, it is also increasing the importance of WSNs to integrate and make connections with the Internet to develop different commercial and industrial applications [25]. In order to achieve different objectives, updated information is required efficiently during pilgrimage and Umrah. To achieve the above goal, IoT can play a vital role to get updated information as needed at a particular zone or level. Information received from IoT may be used by the management such as security management, and resource management (water, chairs, Quranic scripts etc…). So that necessary actions can be performed according to updated information on time in proactive way.

Clustering and WSN
There are some limitations in WSN such as energy limitation, coverage area, network lifetime, and bandwidth. These limitations can be overcome with the help of some clustering schemes to get efficient solution [26]. Amongst the other factors, clustering is one of the most important factors. Clustering can also play an important role to control the performance of a network [27]. Wearable devices provide help to sense and disseminate information, such as physical activities, blood pressure, blood sugar level, heart rate) [28]. To monitor diverse environmental situations such as humidity, temperature, sunlight, and pressure, a smart sensing platform based on NodeMCU-ESP8266 microcontroller board has developed and given in [29]. With the implantation of WSN data can be sensed, stored, disseminated and processed to estimate the capacity [30], [31]. As an industrial IoT is an important infrastructure, WSNs play a crucial role in it. In IoT applications, efficiency balanced verification scheme for WSNs becomes a big contest, due to the resource limitation feature of sensor [32].
A proactive approach and framework can play an important role to enable reliable and an efficient management for WSN. One of the examples is Web Services based on clouds and lightweight crosslayer design [25].

Sensor Topologies
The topologies can differ in complication from a single node connected to a collector node to fully meshed network covering a large area. Flat or hierarchical architecture are used to design sensor topologies. In flat (peer-to-peer) architecture, each node either can be a sink or sensor node that has the same communication and computational abilities in the network. In hierarchical architecture, the nodes link with their particular cluster head in close proximity. Normally, cluster heads own more storage capacity and processing power as compared to any ordinary sensor node. Commonly line, star or bus topologies are used by the sensor networks that are physically wired together [33].
In Figure 1, point-to-point, Bus and linear topologies are given. A hardwired connection between two points is called a permanent point-to-point topology. A switched connection is a type of pointto-point connection in which control can be transferred between end nodes. In Bus topology, nodes are associated with a communication bus for communication. The advantages of the Bus topology are that it is simple and easy to install. But disadvantage is that the failure of central bus is the failure of the whole network, which is called a single point of failure. In Linear Topology, there is a twoway connection between the nodes. Only two terminating nodes has a single connection to their neighboring nodes at the end of the network, but all other nodes have link or connection to left and right nodes. In case of failure of a node, there is a disconnection from the network of any node connected to that node.
In Figure 2, ring, star and tree topologies are given. Network set up in a circular fashion is called ring topology. Each node in this configuration is connected to precisely two other nodes. Direction of flow of data is from the source to each node in clockwise or anticlockwise until it reaches to the intended recipient. In order to overcome this issue, a second communication ring is added by many networks that can transfer data in the opposite direction. In star topology, each node or device is connected to a single central device called hub or switch. Star topology has advantages such as easy to plan, implement, and add or remove the nodes. An intelligent node is needed as all data traffic flows through the central node. Entire network fails as a result of the failure of this node. In Tree topology, single "root node" is at the top of the hierarchy and other nodes are connected to the lower level in hierarchy in a tree manner structure. Many levels of nodes can be contained by a tree topology. This topology is extendable, and identification of the fault is easy and can be fixed easily because of simple structure. With the growth of the tree networks, it becomes more difficult to manage it. In Figure 3, partially and fully mesh topologies are given. There are two arrangements of mesh topology: partially mesh and fully mesh. In partially mesh, some nodes are connected to more than one other node is called a partially connected mesh, while in fully mesh, every node is connected to every other node. Cluster Tree topology consists of a single cluster or a multicluster network. Only one cluster-head (CH) is contained by a single cluster network. When all the nodes are connected to the cluster-head with single hop, the network topology becomes a star topology. More than one cluster-heads are contained by a multicluster network. An upper level sub-network is formed by all the cluster-heads. Nodes in different clusters communicate among themselves via their cluster heads but cannot directly talk to each other. Figure 4 illustrates the cluster tree topology, which has hierarchy architecture with the cluster-head network at the upper level and the clusters nodes at the bottom level [34]. The sink behaves as an entrance to the sensor nodes, gathering and updating the information. The sink plays a role as an interface among WSN, the external network and Internet, where the data are disseminated and processed. Sink can be single or multi sink depending upon the requirement of the application. The goal of the single sink formation is to minimize the forwarding time and route information in the direction of a unique sink. Multi sinks are utilized for applications where tasks are distributed to different sinks. Multi sinks are used where there are high density crowd, large coverage area, redundancy, high latency, and possible high energy consumption [35]. In our scenario cluster tree or hierarchical cluster structure is suitable to collect the data from zones and levels during different positions and events. During the events of Pilgrimage, Ramadan and Umrah the Holy city of Makkah (KSA) is crowded. Especially, to perform Umrah during the Ramadan all activities are around the Masjid Al-Haram, therefore it is need of the hour to organize, control and manage the crowded area smartly. The above objective can be achieved by proactive approach in smart way with the support of WSN, IoT, cloud computing and the management phases.

Present Capacity-Estimation Approaches
At present, capacity estimation is being done by management by taking view from the cameras or by the observation inside the Masjid Al-Haram. By cameras they discover the empty zone or level and update to the security officers to transfer the crowd to the empty or less crowded zone or level. They use the wireless system to give instructions to the security officers. By observation, the security officers check the capacity is available or not in an area where they are assigned. But they do not have auto capacity estimation approach so that they can measure how many pilgrims can be allowed in an empty space. They have just rough estimation of the available capacity. If the Zone or a level is reached to maximum capacity, the remaining crowd is diverted to the less crowded zone or level. If the Masjid Al-Haram is full then gates are covered with barrier and security officers do not permit pilgrims to get in, but they can make exit. No entry sign is turned on outside the gates. After that zones outside the Masjid Al-Haram are occupied. Sometimes zones and levels are overcrowded, and pilgrims face problem to perform the prayers or Tawaf. But currently, they do not have the smart estimation of the available capacity in a zone, level or in the whole Masjid Al-Haram. If there is smart capacity estimation with proactive approach, then pilgrims can be allowed according to the capacity available. Otherwise security stops the pilgrims at the gate and move to specified waiting area so that they do not overcrowd Masjid Al-Haram and do not cause any casualty.

Proposed Smart Capacity Estimation Framework and Proactive Approach
The Figure 5 represents the proposed smart capacity estimation proactive approach and framework. It provides help to estimate the capacity for zone and level to accurate the management. In order to ensure the smart capacity estimation in specific zone or level, the architecture uses WSN so that available capacity can be estimated for management automatically. The architecture provide help to understand the flow of data that is required to estimate the available capacity. It provides help to pilgrims to find out a specific zone or level where capacity is available. Figure 5 shows the overall picture of proposed framework and proactive approach for smart capacity estimation with the help of WSN, cloud storage and interaction among users by IoT for dynamic crowd management. It includes different phases: First phase involves smart capacity estimation according to time and preferable activity by pilgrims in a zone. Second phase involves smart capacity estimation according to time and their preferable activity by pilgrims at a level. Third phase involves smart capacity estimation according to time and their preferable activity by pilgrims at different levels, in order to calculate overall capacity occupied and available capacity in all zones or levels. Figure 5: Proposed smart capacity estimation framework and proactive approach [1] In the first phase, the calculation for the maximum capacity, capacity occupied by pilgrims and available capacity in the zone is done. In the second phase, head nodes or access point nodes fixed on the different zones at different levels will collect the data and forwarded to the server of different levels as update. In the third phase, data from each level from servers will be forwarded to the local cloud storage for further processing and management tasks. Detail of each proactive approach is given in subsection 4.1.

Proactive Approaches at Zone and Different Levels
Proactive approaches use to estimate the maximum, occupied and available (remaining) capacity with respect to zone, level and in a building.
The proactive approach for smart capacity estimation of zone is given as: 1-The Figure 6 depicts the steps to estimate the capacity based on a zone.
• Sensor nodes are fixed on each entry and exit point for each zone that can collect data about number of the pilgrims getting in and out of the zone.
• This information is updated to the zone access point or head node and from zone access point, it is forwarded to the level's server.
• The capacity occupied by pilgrims inside the zone can be calculated by number of pilgrims has entered minus number of the pilgrims exit. • The available capacity of the zone can be calculated by the maximum capacity of the zone minus total number of pilgrims inside.
The remaining capacity = maximum capacity of zone -(total number of pilgrims inside the zone).
() 2-Proactive approach to estimate capacity at Ground Level is depicted in Figure 5. • On each zone, sensor nodes will collect the data for pilgrims getting in or out. Afterward, it adds up or subtracts the number of the pilgrims got in and out from the head node or access point. • The number of pilgrims getting in or out from all zones will be added up or subtracted by head nodes and then updated by the ground level server.

•
If a pilgrim moves to the first level from ground level, then it will be subtracted from the ground level server but added into the first level server and vice versa. L-IN=Entered to the level L-OUT= Exit from the level From head node data can be forwarded to server to estimate the available capacity for ground level. If the ground level reaches to maximum capacity, then the ground level mentions no entry. Because ground level is full, it will be disturbance for the pilgrims if the pilgrims from outside entered into ground level and move to the first level. Therefore, security officers move the crowd to the first level from outside gate without entering into ground level and vice versa.
3-Proactive approach to estimate capacity at First or at different levels is depicted in Figure 5: • If the pilgrims move directly into the first level from outside gates, then there will be an addition to the ground level server and vice versa. • If the pilgrims move into the First level via ground level, then it will be subtracted from the ground level but added into the first level and vice versa. • From head node or access point data can be updated to the server to estimate the available capacity for first level. If the first level reaches to the maximum capacity, then at first level no entry appear at entrance. A message of maximum capacity is generated to the security officers by using IoT. The security officers move the crowd to second level from outside gate without entering into ground level or first level and vice versa. • To avoid disturbance, pilgrims are allowed first to fill up top level then second and first level respectively. In this way first and second level pilgrims will not be disturbed. • The data from each level forwarded to the local cloud storage to calculate the available capacity for the overall building. The data can be analyzed for different positions and events such as Ramadan, Pilgrimage, Jummah etc. At present, most of prevailing wireless sensor devices are restricted because of memory, processing speed, efficiency and capabilities of communication. The above reasons are because of technology and economic limitations [36]. Low-power, low-cost, a multifunctional sensor device has been developed and designed by various industries for different applications, with high attention. Amongst the sensor devices one of the big issues in WSN is to classify and produce an organizational structure [37]. On behalf of clustering topologies, the processing of sensor devices can be improved which in turn improve the processing time. As a result, performance of capacity estimation will increase [38]. The collection of data will provide help to update information at zone, level, building and at crowded areas during Pilgrimage, Ramadan and Umrah for management.
The cloud storage, IoT and telecommunication play an important role in order to collect, assignment and process data locally and globally for smart capacity estimation [39]. To get results for different applications and different analysis, enormous amount of data can be sensed, stored and processed by the deployment of large number of sensor devices, cloud storage and IoT connections [40]. Detail of sensor topologies is given in section (2.4).

Use-Case for Smart Capacity Estimation
Data related to the pilgrims have been collected long time before by management and companies (travel agents) for pilgrimage, Umrah and visit. On the completion of e-visa process, management and companies receive information about pilgrim's residence in different sector or region. The information includes route of travel, reservation (city, hotel) and number of days to stay in different places. Pilgrims can be allocated the zones and levels according to their point of entrance according from their sector or region. As in Masjid Al-Haram, pilgrims have different positions therefore; capacities vary according to the different positions such as standing, sitting, walking and prayer positions. Capacity also depends on the events. Hence, it is important to measure the capacities according to each position and event.

Positions and Capacity
Capacity of the area is also depending on the position of the pilgrims such as standing, sitting, walking (performing Tawaf and Saee) and prayer position as given in Figure 7 and 8.In case of standing position space required for a pilgrim is less than as compared to the other position therefore, in standing position the available capacity will be maximum but in case of sitting, the pilgrim require more space than the pilgrim standing, therefore, in sitting position maximum available capacity will be reduced. In case of walking, the pilgrim required more space than sitting and standing position therefore, the maximum available capacity will be reduced as compared to sitting and standing maximum capacities.
In case of prayer position, the pilgrim needs more space than the standing, sitting, and walking position as the prayer position are dynamic such as standing (Qeyyam), sitting (Tashahud) and Sajood. Roughly, if we consider the standing position as the standard measurement then space ratio between standing and sitting position is measured as [5:9]. In case of walking position, the space ratio in between standing, and walking position is measured as [10:13]. In case of prayer position, the space ratio in between standing, and prayer position is as [1:3]. By calculating the capacities according to the crowd position, the crowd maximum capacity can be set according to standing, sitting, walking and performing prayer. At the time of prayer, the capacity will be minimum as compared to standing, sitting and walking position but in case of standing the capacity will be maximum as compared to sitting, walking and prayer position.
We can divide the sector for standing, sitting, walking and prayer. If crowd has different positions such as standing, sitting, walking and prayer within one sector or zone then we can calculate the average capacity. In case of The Holy Masjid Al-Haram, pilgrims want to see Baitullah (Kaaba), they can be managed on first, second and on top level near the balcony wall so that they can see the Kaaba in standing position. Sitting position is required when pilgrims want to recite the Holy Quran or Dhikr of Allah (Mention of Allah). They can be managed behind the Mataf area. Walking position is required in the Mataf or circular area on first, second and at top level. Prayer position can be at any sector but before prayer we need to calculate the capacity available for prayer and crowd inside the Masjid Al-Haram.

Stop and Wait
Calculate the average number of pilgrims entered in an area (Zone or sector) in unit time for example in one minute or in an hour. Average will provide help to calculate after how much time it is expected that the sector or zone will reach to its maximum limit. In this way we can control the crowd before it exceeds to its maximum limit. Usually it is observed that some time crowd exceeds the maximum limit and at prayer or Tawaf time pilgrims face a big problem which can lead to a stampede.

Move and Enter in the Zone
Rate of in and out to manage after maximum capacity, when zone and level reaches to its maximum capacity. Many pilgrims stay outside waiting for space availability. The space available for waiting pilgrims can be calculated by maximum capacity minus number of the pilgrims making the exit (going out). The space availability can be in a sector or zone or in whole area. Initial capacity estimation is roughly calculated on the basis of previous experience and best guesses.
Initial capacity estimation will be calculated on the basis of data collected from central storage system. ii.
Each zone capacity is calculated by the security officers or by computerized camera's system.
For each zone, automatically real time zone capacity will be estimated by zone sensors and sensor head. iii.
Capacity available in a zone is controlled manually not automatically by security officers with the help of wireless system.
Capacity available in a zone will be calculated and automatically displayed. Zone security officer will manage the zone according to the available capacity. iv.
There is no assurance about the exact maximum capacity estimation. Wrong estimation of maximum pilgrims' capacity can overcrowd the zone or level.
Maximum capacity for ach zone or level is already set therefore; maximum capacity alert will be generated automatically for no entry without any delay. v.
According to dynamic positions and events there is no proper capacity records for zone and level.
Security officers can get records from local cloud storage system for future planning for each zone and level according to positions and events. vi.
Real time capacity available cannot be calculated therefore capacity available can only be roughly estimated.
Real time capacity available will provide help to allow exact number of pilgrims to enter into a specific zone or level. vii.
Difficult to estimate capacity available during different positions, events during prayer time and Tawaf time as each activity has different capacities that is number of pilgrims.
Capacity available during different positions, events during prayer time and Tawaf time is automatically estimated because prayer time and Tawaf time maximum capacity threshold can be set automatically according to activity. viii.
There is no automatic way to trace out the lost pilgrim because existing system only support to manual capacity estimation and for security purpose.
Pilgrim lost can be traced out on the bases of the sensor device location with help of IoT.
ix. CCTV cameras implementation provide help to observe and control the act of misconduct but there is no automatic way to identify the pilgrim (mis-conductor).
If the act of misconduct is done, then pilgrim (mis-conductor) will be identified on the bases of information stored on sensor device and on the cloud storage with the help of IoT. x.
There is no such application to provide schedule, when the capacity is available for a specific building, sector and region.
Application can be developed on the basis of IoT to provide the schedule for visit to Masjid Al-Haram according to building, sector and region.

Evacuation or Exit from the Zone
In any case if the capacity exceeds to maximum limit in a zone or level, it can be managed in another zone or level. In worst case the pilgrims have to evacuate to the waiting place and put into high priority to get in when space will be available.

Comparison between Existing and Proposed Capacity Estimation
In the section 3, capacity estimation about existing system is described. It consists of manual capacity estimation, wireless system and computerized camera's systems. The proposed capacity estimation is discussed in the section 4. The comparison and preliminary analysis between existing and proposed smart capacity estimation systems are given in Table 1.

Algorithm for Proposed Capacity Estimation
We have taken the simple scenario to design the algorithms at different zones, different levels and in the whole building.

Algorithm for Zone Capacity Estimation
In zone capacity estimation, we simply check the available capacity in zone. If maximum zone capacity is greater than the number of pilgrims has entered in a zone minus number of pilgrims have exited from the zone. If the condition is true, then display the GREEN sign and also display the available capacity for pilgrims in waiting position. Otherwise display RED sign that zone is full and there is no entry. Algorithm 1: Zone capacity estimation

Algorithm for different Level Capacity Estimation
In different levels capacity estimation, we simply check the available capacity in a level. If maximum level capacity is greater than the number of pilgrims has entered in a level minus number of pilgrims have exited from a level. If the condition is true, then display the GREEN sign for available capacity. Also display the zone number and level number where capacity is available for pilgrims in waiting position. Otherwise display RED sign that level is full and there is no entry. Algorithm 2: Different level capacity estimation Cluster verification algorithm [31], represents the scenario of verification of cluster members (CMs) in cluster form. It discusses the number of verified and unverified CMs in a cluster. But in capacity estimation algorithm, it verifies and count the number of the pilgrims getting in or out from zone, level or in a building. All CMs remain within the cluster head transmission range for verification. But in capacity estimation algorithm, the pilgrims in the range of entry and exit sensors are verify when they make entry or exit from zone or level. CMs can enter to different clusters but in capacity estimation, it is not allowed to enter other than allocated zone or level. Zone and level are allocated so that pilgrims enter from the gate that is near to their zone and level. In this way crowd will be distributed in different zones, as a result a single path and zone will not be crowded. In the cluster verification, the number of the CM verify are listed out but in capacity estimation, it tells the available capacity for a zone and as well level and building. Cluster verification represents the number of CMs supported by a cluster head but in capacity estimation, the number of the pilgrims can be managed according to the available space in a zone or level or building. In cluster verification more than one CM can be verified. But in capacity estimation, the verification and counting of the pilgrims is done at entrance and exit one by one. In cluster verification, cluster head generate the signals for verification and in response CMs generate signals for their identification. But in capacity estimation, pilgrims (sensor devices) generate signals (that is an event driven approach) for verification and in response zone sensors verify and count the number of pilgrims getting in or out from zone.

Simulation and Results
Contiki OS is a lightweight open source operating system for sensor network. It was designed by Adam Dunkels, at the Swedish Institute of Computer Sciences. C programming language is used in both Contiki OS and its programs. Contiki is flexibly portable OS and it has been ported to different platforms. Texas Instruments MSP-430 in addition to Atmel AT mega series of microcontrollers are the most often used platforms. Contiki employs event-driven programming model to deal with concurrence. It is Contiki's main advantage that all processes share one stack, allowing savings of memory. In order to utilize this model Proto threads. Unconditional blocking wait is provided by Proto threads to save the state when it blocks. It jumps back to the next instruction on resumption of Proto thread. It also employs Rime stack that is a stack for sensor networks for lightweight communication. The main purpose of Rime stack is to support code reusing and simplify the implementation of sensor networks. Contiki is used in several systems, such as electric meters, alarm generating systems, remote control of house, radiation detection and streetlights control. Cooja is Java based Contiki network simulator with a graphical user interface (GUI). It is a trial system given by Contiki, and additionally empowers with original instrumentation before running it on the real target hardware. It integrates to simulate with the external tools to provide additional features to the large and small networks. Motes can be emulated, which is faster and allows simulation of larger networks, or at the hardware level. Two emulator software packages are contained by this tool: Avrora and MSPSim. Cooja can emulate multiple platforms like: TelosB/SkyMote, MicaZ mote, Zolertia Z1 mote, ESB, Wismote [41].
The Figure 9 shows full screen view of Contiki/Cooja simulator. Network simulator "Contiki/Cooja" is separated into small windows such as: Network Window, Notes Window, Simulation Control Window and Mote Output Window.
Network Window is employed to draw the WSN in random manner, linear, ellipse or manual positions. Notes Window is employed to write down the information or detail about the simulations and detail of its results. In order to start, stop, pause or reload the simulations, simulation control Window is used. The results for data packets have transmitted and received is provided by Mote Output Window. For our scenario, we use the Tmote Sky platform. Tmote Sky is one of the high data rate platforms work with low power consumption. It works well for many months to years without replacing the battery. Therefore, it is one of the most demanding wireless sensors. It is notable that options are best used in a selection manner, as the window can become disordered with too many selected options. The number for each mote is displayed by Mote IDs. Mote Output window can be used for analyzing and filtering results. On the simulated motes, LEDs are beneficial in order to observe the LED lights.  We took the simple scenario to make understanding of the flow and function of each node as given in Figures 4 and 8. Head node function is to keep the record and status of CMs and forward record to the server for update. The status of the CM can be waiting to enter, enter and exit. Since the log file generated by the Contiki/Cooja simulation tool, we extracted the data for single and double zone in a level. For each zone we calculated the number of the pilgrims entered, exited, zone capacity occupied and available capacity for pilgrims. From this datum we can calculate the capacity for different positions and events. We also draw the table and graph for better understanding.

Single Zone Scenario
In single zone scenario, we consider one entry point and one exit point. We also set the maximum value for zone then we allow the specific number of the CMs to enter the zone and some of them allowed to exit from the zone. The simulation is shown in the Figures 10 to 18 and data is given in the Table 2. To make clarity of the figures, we consider the complete figure and then divided into its small parts (network, mote output and simulation control windows).
The simulation for maximum capacity 50 pilgrims is shown in the Figures from 10 to 14 and data is given in the Table 2. Figure 12: Network window from Figure 11 The Figures 10 and 11 represent the single zone having maximum capacity of 50 pilgrims. Figure 10 shows the capacity without coverage area while Figure 11 shows the capacity with coverage area in circular form.
The Figure 12 represents the network distribution of sensor nodes, entry point and exit point nodes in single zone having maximum capacity of 50 pilgrims. It also shows the number of nodes in waiting, occupy and exit position to calculate the available capacity.     Figures from 10 to 14 considered that the maximum capacity for zone is 50 Pilgrims. Graph in Figure 14 shows that 45 of them have entered and 5 are in waiting position. 11 pilgrims have made the exit, occupied capacity in the zone is 34 and available capacity is 16.
The simulation for maximum capacity 40 is shown in the Figures from 15 to 18 and data is given in the Table 2. To make clarity of the figures, we consider the complete figure and then divided into its small parts (network, mote output and simulation control windows).

Different Levels and Double Zone Scenarios
In different levels and double zone scenarios, we consider one entry point and one exit point in each zone and also consider that each level has double zone. We also set the maximum value for each zone and each level. We allowed the specific number of the nodes to enter in each zone and some of them allow to exit from each zone. The simulation is shown in the Figures 19-32 and data are given in the Table 2.    In Figures 19 to 23, it is considered that the maximum capacity for zone-1 and zone-2 is 25. Zone-1 and zone-2 made the level-G and total capacity is 50 Pilgrims. In zone-1, 22 have entered and 3 are in waiting position. 4 pilgrims have made the exit, occupied capacity in the zone is 18 and available capacity is 7. In zone-2, 21 have entered and 4 are in waiting position. 3 pilgrims have made the exit, occupied capacity in the zone is 18 and available capacity is 7. From the log file or zone-1 and zone-2, we calculated the capacities for Level-G. Level-G has maximum capacity 50 pilgrims. 43 have entered and 7 are in waiting position. 7 pilgrims have made the exit, occupied capacity in the zone is 36 and available capacity is 14. In Figures 24 to 28, it is considered that the maximum capacity for zone-1 and zone-2 is 20 pilgrims. Zone-1 and zone-2 made the level-1 and total capacity in level-1 is 50 Pilgrims. In zone-1, 18 have entered and 2 are in waiting position. 3 pilgrims have made the exit, occupied capacity in the zone is 15 and available capacity is 5. In zone-2, 10 have entered and 10 are in waiting position. 2 pilgrims have made the exit, occupied capacity in the zone is 8 and available capacity is 12. From the log file or zone-1 and zone-2, we calculated the capacities for Level-1. Level-1 has maximum capacity 40 pilgrims. 28 have entered and 12 are in waiting position. 5 pilgrims have made the exit, occupied capacity in the zone is 23 and available capacity is 17.  In Figures 29 to 32, it is considered that the maximum capacity for zone-1 and zone-2 is 10 pilgrims. Zone-1 and zone-2 made the level-2 and total capacity in level-2 is 20 Pilgrims. In zone-1, 9 have entered and 1is in waiting position. 2 pilgrims have made the exit, occupied capacity in the zone is 7 and available capacity is 3. In zone-2, 8 have entered and 2 are in waiting position. 3 pilgrims have made the exit, occupied capacity in the zone is 5 and available capacity is 5. From the log file or zone-1 and zone-2, we calculated the capacities for Level-2. Level-2 has maximum capacity 20 pilgrims. 17 have entered and 3 are in waiting position. 5 pilgrims have made the exit, occupied capacity in the zone is 12 and available capacity is 8.   Level-2 20 17 5 12 8 Figure 33: Capacity detail for double zones having maximum capacity 10 in each but Level-2 has maximum capacity 20

Discussion
The present analysis deals with capacity estimation for pilgrims at crowded place. The prime focus is on the allotment of zone and level number. This is performed according to moving status and events, single or multi sink, entry and exit point.
The concern of discussion is the allotment of zone and level number to pilgrims. According to discussion allotment of zone and level number to pilgrims should be specific (fixed) or flexible for dynamic position and events accordingly. Specific zone and level number according to dynamic positions and events is preferred because it is noticed if allotment is flexible then some zone and level number are more crowded than available capacity while others remain empty or less occupied. Furthermore, prayer position requires more area than standing and sitting position comparatively as given in section (5.1). As compared to routine days, pilgrimage, Ramadan and Jummah needs more area. The above mention reasons lead to non-uniform distribution of crowd. What is more, pilgrims having flexible zone and level move in different directions. It can result in congestions (bottleneck) that can lead to stampede. But in particular case, pilgrims are allotted the specific tracks to approach their zone and level number, that is why, chances of bottleneck and stampede are lessened or minimized. In flexible case, pilgrims are unable to move flexibly from overcrowded to less crowded zone or level (where capacity is available). This is because they have right to enter any zone and level number. But in particular case, pilgrims are allotted by the zone and level number. They can only move into allotted zone and level number. As allotment is performed considering maximum capacity of zone or level (a proactive approach), the zone or level does not get overcrowded. Place can be occupied within the zone on the basis of first come and first serve.
Entry point and exit point is the second point of discussion. In case of flexible, the pilgrims can enter and exit from any one of the points. Again, some entry points become more crowded than the other and cause bottleneck and there are chances of stampede. Moreover, pilgrims' attempt of entry and making exit from same location also causes bottleneck and stampede. But in specific case, each zone and level have particular point of entry and exit. In this way, chances of problem of bottleneck and stampeded can be overcome. Furthermore, pilgrims can conveniently access the transport of their residential area.
Third point of discussion is that there should be a single or multiple sink for WSN system. Massive crowd, scalability, latency, reliability, and network lifetime are the numerous challenges that may be created by the design of WSNs. The question whether sink should be single or multi sink is dependent upon its application. In the case of single sink and massive crowd, single sink has to control all traffic. The streaming of data traffic will be in one direction which causes congestion. There are probabilities that single sink is ineffective to control massive amount of data which causes the drop of data. This drop of data will cause the high latency rate. However, there are separate solutions to control the massive crowd and data in case the multi sinks are used. In the case of multi sink, data flow will be in multiple directions rather in one direction. Probability of congestion can be minimized in this way. In order to avoid the congestion and to distribute the task among sinks different type of data traffic or task can be allotted to different sinks. If the data is dropped on one path, it can be received on the alternative path. In this way latency rate can be minimized. When data is received from different paths and sinks, it will provide the data redundancy. Single sink solution is not appropriate in case of long-distance communication because transferring data to long distance with the support of sensor nodes means consumption of energy to a lot degree. This consumption of energy will lead the sensor node die early and hence it will shorten the network life span. But in case of multi sink, the sensor nodes will get the shortest path as multi sink will divide the path and will consume less energy by increasing the network life span. Increasing of lifetime of network and receiving of data from multiple courses increase the reliability of the network. In our case, as data is massive, crowd is large, dynamic, and on large area therefore WSN required the multi sinks solution.

Conclusion and Future Directions
This paper provides an overview of a dynamic positions and events, proactive approach with framework and its implications towards smart capacity estimation using WSN and cloud computing in the IoT paradigm.
We discussed the framework and proactive approach in the context of dynamic position and events for smart capacity estimation. We examined how smart capacity estimation automate and minimizes time to manage available capacity in a zone or level by using framework and proactive. Explanation is done by usecase of masjid Al-Haram for smart capacity estimation for crowd management. We also compared the existing capacity estimation and smart capacity estimation systems. We also defined the algorithms with respect to Zone and Level. We also ran different simulation scenarios and also discussed the results. In future we will calculate the capacity according to the different position. The dynamic capacity can be calculated on the basis of time frame and capacity can be maximized and minimized according to time frame. In future algorithms can be defined how to maintain social distancing, how to calculate the capacity with social distancing and find the empty space with direction? Algorithms devised how to define the exit plan to move out without facing the congested path. Smart capacity estimation with Sensor and without sensor. Without sensor, capacity of pilgrims can be counted by putting the manual counter. If proposed proactive approach and framework for smart capacity estimation is commercially applied, it can provide help in different application developments, such as: 1. Capacity available in a zone or at a level can be calculated precisely. 2. To estimate the occupied and remaining capacity in a building or in an area. 3. Alert generation before the zone or level reached to its maximum threshold. 4. Positions and Events based capacity estimation. 5. Capacity estimation on the basis of social distancing. 6. Calculation of the social distance. 7. Drinking water estimation to supply the water in different zones and levels. 8. On the basis of wheelchairs' requests, wheelchairs supply plan according to demand in different zones and levels. 9. Estimation of the Holy Quran scripts according to different languages. 10. If water, chairs or the Holy Quran scripts are not enough in a zone or level then generate the alert to workers for supply. 11. Sharing of zone capacity data with different zone security officers to manage the crowd capacity. 12. In case of emergency, provide path for evacuation from affected zone or level to outside.