Rewrite the code in a way that it calculates the  the packet drop probabil-ty of those data packets that are forwarded to the Cloud for any reason.

import random
import simpy
import matplotlib.pyplot as plt

# Parameters
SIM_TIME_VALUES = [1000,2500, 5000,7500 , 10000, 12500, 15000, 17500, 20000, 22500,
                   25000,27500,30000,32500,35000,37500,40000,42500,45000,47500,50000,
                   52500,55000,57500,60000,62500,65000,67500,70000,72500,75000,77500,
                   80000,82500,85000,87500,90000,92500,95000,97500,100000,102500,105000,
                   107500,110000 ]  # Different simulation times to test
NUM_SERVERS_MICRO = 1
NUM_SERVERS_CLOUD = 1
BUFFER_CAPACITY_MICRO = 10
BUFFER_CAPACITY_CLOUD = 10

ARRIVAL_RATE = 10
SERVICE_RATE_EDGE = 5
SERVICE_RATE_CLOUD = 2
PROPAGATION_DELAY = 1
FRACTION_TYPE_B = 0.5

class Packet:
    def __init__(self, id, arrival_time, packet_type):
        self.id = id
        self.arrival_time = arrival_time
        self.packet_type = packet_type

def packet_generator(env, arrival_rate):
    id = 0
    while True:
        inter_arrival_time = random.expovariate(arrival_rate)
        packet_type = 'B' if random.random() < FRACTION_TYPE_B else 'A'
        yield env.timeout(inter_arrival_time)
        arrival_time = env.now
        packet = Packet(id, arrival_time, packet_type)
        id += 1
        env.process(packet_handler(env, packet))

def packet_handler(env, packet):
    global packet_dropped
    with micro_data_center.request() as req:
        enter_buffer_time = env.now
        yield (req | env.timeout(BUFFER_CAPACITY_MICRO))

        if req.triggered:
            service_time = random.expovariate(SERVICE_RATE_EDGE)
            yield env.timeout(service_time)

            if packet.packet_type == 'B':
                with cloud_data_center.request() as cloud_req:
                    cloud_enter_buffer_time = env.now + PROPAGATION_DELAY
                    yield (cloud_req | env.timeout(BUFFER_CAPACITY_CLOUD))

                    if cloud_req.triggered:
                        cloud_service_time = random.expovariate(SERVICE_RATE_CLOUD)
                        yield env.timeout(cloud_service_time + PROPAGATION_DELAY)
                    else:
                        packet_dropped += 1
            else:
                pass  # Packet of type A completed
        else:
            packet_dropped += 1

results = []  # Store the results for different simulation times

for SIM_TIME in SIM_TIME_VALUES:
    packet_dropped = 0
    env = simpy.Environment()
    micro_data_center = simpy.Resource(env, capacity=NUM_SERVERS_MICRO)
    cloud_data_center = simpy.Resource(env, capacity=NUM_SERVERS_CLOUD)
    env.process(packet_generator(env, ARRIVAL_RATE))
    env.run(until=SIM_TIME)
    fraction_dropped = packet_dropped / SIM_TIME
    results.append((SIM_TIME, fraction_dropped))

# Print the results
for sim_time, fraction_dropped in results:
    print(f"Simulation Time: {sim_time}")
    print(f"Fraction of packets dropped: {fraction_dropped}")
    print()

# Plot the results
sim_times = [result[0] for result in results]
fractions_dropped = [result[1] for result in results]

plt.plot(sim_times, fractions_dropped, 'o-')
plt.xlabel('Simulation Time')
plt.ylabel('Fraction of Packets Dropped')
plt.title('Effect of Simulation Time on Packet Dropping')
plt.show()