

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


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

        MN_CSE[2400]: CSE;
        ASN_CSE[110000]: CSE;
               
        IN_AE[300]: AE;
        ADN_AE[12000]: AE;
        ASN_AE[200000]: AE;
        MN_AE[24000]: AE;

    connections allowunconnected:

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

        for i=0..99, for j=0..9999 {
            IN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*100) && j<(i*100)+100; // 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..99, for j=0..299 {
            IN_CSE[i].ae++ <--> Channel <--> IN_AE[j].cse if j>=(i*3) && j<(i*3)+3; // 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..99, for j=0..9999 {
            IN_CSE[i].customer++ <--> Channel <--> ASN_CSE[j].provider++ if j>=(i*100) && j<(i*100)+100; // 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..4999, for j=0..99999 {
            ASN_CSE[i].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*20) && j<(i*20)+20;
        }

        for i=0..99, for j=0..1999 {
            IN_CSE[i].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(i*20) && j<(i*20)+20; // 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=0..199, for j=2000..2399 {                                          // 10% of MN_CSEs have another level of MN_CSEs
            MN_CSE[i*10].customer++ <--> Channel <--> MN_CSE[j].provider++ if j>=(2*i)+2000 && j<(i*2)+2002;
        }
       
//        for i=10..11 {
//            MN_CSE[i].peer++ <--> 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..2399, for j=0..23999 {
            MN_CSE[i].ae++ <--> Channel <--> MN_AE[j].cse if j>=(i*10) && j<(i*10)+10;
        }

        for i=0..999, for j=10000..109999 {
            MN_CSE[i].provider++ <--> Channel <--> ASN_CSE[j].customer++ if j>=(i*100)+10000 && j<(i*100)+10100;
        }
        
        for i=0..99999, for j=100000..199999 {
            ASN_CSE[i+10000].ae++ <--> Channel <--> ASN_AE[j].cse if j>=(i*2)+100000 && j<(i*2)+100002;
        }
        
        for i=0..999, for j=10000..11999 {
            MN_CSE[i].ae++ <--> Channel <--> ADN_AE[j].cse if j>=(i*2)+10000 && j<(i*2)+10002;
        } 
        
}
