
//==================================================NETWORK==========================================================


network AsdqNetworkSub
{       
    types:
        channel Channel extends ned.DelayChannel
        {
            delay = 100ms;
        }
        
    submodules:
        IN_CSE[5]: CSE {
            parameters:
                @display("p=700,600,ring");
        }

        MN_CSE[12]: CSE;
        ASN_CSE[75]: CSE;
               
        IN_AE[10]: AE;
        ADN_AE[70]: AE;
        ASN_AE[550]: AE;
        MN_AE[60]: AE;

    connections allowunconnected:

        for i=0..3, for j=(i+1)..4 {
            IN_CSE[i].sibling++ <--> Channel <--> IN_CSE[j].sibling++; //top-level mesh IN_CSE network (Extendable)
        }

        for i=0..4, for j=0..49 {
            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*10) && j<(i*10)+10; // ADN_AE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ADN_AEs for each IN_CSE
        }

        for i=0..4, for j=0..9 {
            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*2) && j<(i*2)+2; // IN_AE which are connected to top level IN_CSEs (Extendable) and 3 here is the number of IN_AEs for each IN_CSE
        }

        for i=0..4, for j=0..49 {
            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*10) && j<(i*10)+10; // ASN_CSE which are connected to top level IN_CSEs (Extendable) and 100 here is the number of ASN_CSE for each IN_CSE
        }

        for i=0..49, for j=0..499 {
            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
        }

        for i=0..4, for j=0..9 {
            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*2) && j<(i*2)+2; // MN_CSE which are connected to top level IN_CSEs (Extendable) and 20 here is the number of MN_CSE for each IN_CSE
        }

        for i=10..11 {                                          // 10% of MN_CSEs have another level of MN_CSEs
            MN_CSE[6].customer++ <--> Channel <--> MN_CSE[i].provider++;
        }
       
//        for i=10..11 {
//            MN_CSE[i].peer++ <-->prompt Channel <--> MN_CSE[i+1].peer++;
//            MN_CSE[12].peer++ <--> Channel <--> MN_CSE[10].peer++;
//        }
//        
//        for i=13..14 {
//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
//            MN_CSE[15].peer++ <--> Channel <--> MN_CSE[13].peer++;
//        }
//        
//        for i=16..17 {
//            MN_CSE[i].peer++ <--> Channel <--> MN_CSE[i+1].peer++;
//            MN_CSE[18].peer++ <--> Channel <--> MN_CSE[16].peer++;
//        }
        

        for i=0..11, for j=0..59 {
            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*5) && j<(i*5)+5;
        }

        for i=0..4, for j=50..74 {
            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*5)+50 && j<(i*5)+55;
        }
        
        for i=0..74, for j=500..549 {
            ASN_CSE[i+50].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+500 && j<(i*2)+502;
        }
        
        for i=0..9, for j=50..69 {
            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+50 && j<(i*2)+52;
        } 
        
}
