OMNET++ ZIGBEE SIMULATION

OMNET++ ZIGBEE SIMULATION for set of high-level communications protocols based on the IEEE 802.15.4 standard. OMNET++ ZIGBEE SIMULATION utilizes low-data-rate wireless personal area network (WPAN) comprising devices of low complexity and long battery life.

Advantages of ZigBee technology:

  • No central control point.
  • Setting up zigbee wireless home management system is relatively inexpensive.
  • Eliminates dependence on infrared devices.
  • Ability to manage home appliance network remotely all zigbee compliant appliances compatibly operates in the same network.
  • Low cost of the modules and the zigbee protocol is patent fee free.
Architecture of Zigbee
Architecture of Zigbee

Sample code for OMNET++ ZIGBEE SIMULATION:

double Zigbee::calculateReceivedPower(double pSend, double carrierFrequency, const Coord& senderPos, double senderAngle, const Coord& receiverPos, double receiverAngle) const {
    if (getShape().size() < 2) return pSend;
    std::multiset<double> intersectAt;
    bool doesIntersect = false;
    const Zigbee::Coords& shape = getShape();
    Zigbee::Coords::const_iterator i = shape.begin();
    Zigbee::Coords::const_iterator j = (shape.rbegin()+1).base();
    for (; i != shape.end(); j = i++) {
        Coord c1 = *i;
        Coord c2 = *j;

        double i = segmentsIntersectAt(senderPos, receiverPos, c1, c2);
        if (i != -1) {
            doesIntersect = true;
            intersectAt.insert(i);
        }   }
    bool senderInside = isPointInZigbee(senderPos, *this);
    bool receiverInside = isPointInZigbee(receiverPos, *this);
    if (!doesIntersect && !senderInside && !receiverInside) return pSend;
    if (senderInside) intersectAt.insert(0);
    if (receiverInside) intersectAt.insert(1);
    if ((intersectAt.size() % 2) != 0)
    {   
        std::vector<CoordFrac> intersectVector;
        const Zigbee::Coords& shape = getShape();
        Zigbee::Coords::const_iterator i = shape.begin();
        Zigbee::Coords::const_iterator j = (shape.rbegin()+1).base();
        for (; i != shape.end(); j = i++) {
            Coord c1 = *i;
            Coord c2 = *j;
            Coord IntersectPoint;
            double val = segmentsIntersectAt(senderPos, receiverPos, c1, c2,IntersectPoint);
            if (val != -1) {
                bool inside = false;
                for (unsigned int index = 0 ; index < intersectVector.size(); index++)            {
                    if (intersectVector[index].first.distance(IntersectPoint) < 0.01)
                    {                inside = true;
                        if (intersectVector[index].second < val)
                        {
                            intersectVector[index].first = IntersectPoint;
                            intersectVector[index].second = val;
                        }
                        break;
                    }
                }
                if (!inside)
                    intersectVector.push_back(std::make_pair(IntersectPoint,val));
            }

        }
        intersectAt.clear();
        for (unsigned int index = 0 ; index < intersectVector.size(); index++)
        {
            intersectAt.insert(intersectVector[index].second);
        }
        if (senderInside) intersectAt.insert(0);
        if (receiverInside) intersectAt.insert(1);
    }
    ASSERT((intersectAt.size() % 2) == 0);

    // sum up distances in matter.
    double fractionInZigbee = 0;
    for (std::multiset<double>::const_iterator i = intersectAt.begin(); i != intersectAt.end(); ) {
        double p1 = *(i++);
        double p2 = *(i++);
        fractionInZigbee += (p2 - p1);
    }

    // calculate attenuation
    double numWalls = intersectAt.size();
    double totalDistance = senderPos.distance(receiverPos);
    double attenuation = (attenuationPerWall * numWalls) + (attenuationPerMeter * fractionInZigbee * totalDistance);
    return pSend * pow(10.0, -attenuation/10.0);
}