public void calculateDuplication() {

		Map<MonitoredAS, SingleASspikes> allUpdates = updates.getUpdateMap();

		// for every monitor
		for (MonitoredAS monitoredAS : allUpdates.keySet()) {
			// get all spikes
			Map<Long, Spike> spikes = allUpdates.get(monitoredAS)
					.getAllSpikes();

			// for every spike
			for (Long time : spikes.keySet()) {
				Spike spike = spikes.get(time);

				// get number of unique duplicated (only with DUPLICATED spikes from other
				// monitors) prefixes in this spike
				Set<InetAddress> uniqueDuplicatedPrefixes = this.updates
						.getDuplicatedPrefixesInSpikeIfSpikeIsDuplicated(spike,
								time, timeBuffer, monitoredAS,
								duplicationPercentage);
				
				
				
				// get number of unique duplicated (only with spikes from other
				// monitors) prefixes in this spike
				Set<InetAddress> allUniqueDuplicatedPrefixes = this.updates
						.getAllDuplicatedPrefixesInSpike(spike,
								time, timeBuffer, monitoredAS,
								duplicationPercentage);
				
				// find number of duplicated prefixes
				int allDuplicatedPrefixes = 0;
				for (Destination destination : spike.copyPrefixSet()) {
					if (allUniqueDuplicatedPrefixes.contains(destination
							.getPrefix())) {
						allDuplicatedPrefixes++;
					}
				}

					
					
				// if spike was classified as duplicated, the number of unique
				// duplicated will be > 0.
				if (uniqueDuplicatedPrefixes.size() == 0) {
					// spike is single
					this.stats.addSingle(spike.getSpikeSize(),allDuplicatedPrefixes);
				} else {
					// spike is duplicated

					// find number of duplicated prefixes
					int duplicatedPrefixes = 0;
					for (Destination destination : spike.copyPrefixSet()) {
						if (uniqueDuplicatedPrefixes.contains(destination
								.getPrefix())) {
							duplicatedPrefixes++;
						}
					}

					// update stats
					this.stats.addDuplicated(spike.getSpikeSize(),
							duplicatedPrefixes, allDuplicatedPrefixes);
				}
			}
		}

	}