cloudsim-plus-master/cloudsim-plus-master/cloudsim-plus/src/main/java/org/cloudbus/cloudsim/hosts/network/NetworkHost.java
private void receivePackets() {
        for (final HostPacket hostPkt : hostPktsReceived) {
            hostPkt.getVmPacket().setReceiveTime(getSimulation().clock());

            //Checks if the destinationVm is inside this host
            final Vm destinationVm = VmList.getById(getVmList(), hostPkt.getVmPacket().getDestination().getId());
            if(destinationVm.equals(Vm.NULL)){
                Log.println(
                    Log.Level.ERROR, getClass(), getSimulation().clock(),
                    "Destination VM %d was not found inside the Host %d",
                    hostPkt.getVmPacket().getDestination().getId(), getId());
                return;
            }

            final PacketScheduler pktScheduler = getVmPacketScheduler(destinationVm);
            pktScheduler.addPacketToListOfPacketsSentFromVm(hostPkt.getVmPacket());
            Log.println(
                Log.Level.DEBUG, getClass(), getSimulation().clock(),
                "Host %d received pkt with %d bytes from Cloudlet %d in VM %d and forwarded it to Cloudlet %d in VM %d",
                getId(), hostPkt.getVmPacket().getSize(),
                hostPkt.getVmPacket().getSenderCloudlet().getId(),
                hostPkt.getVmPacket().getSource().getId(),
                hostPkt.getVmPacket().getReceiverCloudlet().getId(),
                hostPkt.getVmPacket().getDestination().getId());
        }

        hostPktsReceived.clear();
    }
/**
     * Receives packets and forwards them to targeting VMs and respective Cloudlets.
     */
Receives packets and forwards them to targeting VMs and respective Cloudlets.
Receives packets and forwards them to targeting VMs and respective Cloudlets .
private void receivePackets() {
        for (final HostPacket hostPkt : hostPktsReceived) {
            hostPkt.getVmPacket().setReceiveTime(getSimulation().clock());
            final Vm destinationVm = VmList.getById(getVmList(), hostPkt.getVmPacket().getDestination().getId());
            if(destinationVm.equals(Vm.NULL)){
                Log.println(
                    Log.Level.ERROR, getClass(), getSimulation().clock(),
                    "Destination VM %d was not found inside the Host %d",
                    hostPkt.getVmPacket().getDestination().getId(), getId());
                return;
            }
            final PacketScheduler pktScheduler = getVmPacketScheduler(destinationVm);
            pktScheduler.addPacketToListOfPacketsSentFromVm(hostPkt.getVmPacket());
            Log.println(
                Log.Level.DEBUG, getClass(), getSimulation().clock(),
                "Host %d received pkt with %d bytes from Cloudlet %d in VM %d and forwarded it to Cloudlet %d in VM %d",
                getId(), hostPkt.getVmPacket().getSize(),
                hostPkt.getVmPacket().getSenderCloudlet().getId(),
                hostPkt.getVmPacket().getSource().getId(),
                hostPkt.getVmPacket().getReceiverCloudlet().getId(),
                hostPkt.getVmPacket().getDestination().getId());
        }
        hostPktsReceived.clear();
    }
private void receivePackets ( ) { for ( final HostPacket hostPkt : hostPktsReceived ) { hostPkt . getVmPacket ( ) . setReceiveTime ( getSimulation ( ) . clock ( ) ) ; final Vm destinationVm = VmList . getById ( getVmList ( ) , hostPkt . getVmPacket ( ) . getDestination ( ) . getId ( ) ) ; if ( destinationVm . equals ( Vm . NULL ) ) { Log . println ( Log . Level . ERROR , getClass ( ) , getSimulation ( ) . clock ( ) , "Destination VM %d was not found inside the Host %d" , hostPkt . getVmPacket ( ) . getDestination ( ) . getId ( ) , getId ( ) ) ; return ; } final PacketScheduler pktScheduler = getVmPacketScheduler ( destinationVm ) ; pktScheduler . addPacketToListOfPacketsSentFromVm ( hostPkt . getVmPacket ( ) ) ; Log . println ( Log . Level . DEBUG , getClass ( ) , getSimulation ( ) . clock ( ) , "Host %d received pkt with %d bytes from Cloudlet %d in VM %d and forwarded it to Cloudlet %d in VM %d" , getId ( ) , hostPkt . getVmPacket ( ) . getSize ( ) , hostPkt . getVmPacket ( ) . getSenderCloudlet ( ) . getId ( ) , hostPkt . getVmPacket ( ) . getSource ( ) . getId ( ) , hostPkt . getVmPacket ( ) . getReceiverCloudlet ( ) . getId ( ) , hostPkt . getVmPacket ( ) . getDestination ( ) . getId ( ) ) ; } hostPktsReceived . clear ( ) ; }
Receives packets and forwards them to targeting VMs and respective Cloudlets.
Receives packets and forwards them to targeting VMs and respective Cloudlets .
//Checks if the destinationVm is inside this host