network LargeNetwork
{
    parameters:
        
        @signal[flood](type="long");
        @statistic[flood](title="number_of_messages"; source="flood"; record= vector,last);
        
        @signal[packet_size](type="long");
        @statistic[throughput](title="total_number_of_packets"; source="packet_size"; record=vector,last);
        
        @signal[hop_count](type="long");
        @statistic[latency](title="latency"; source="hop_count"; record= vector,last);  
        
        @signal[number_replies](type="long");
        @statistic[successRate](title="total_number_of_replies"; source="number_replies"; record=vector,last);  
    @display("bgb=583,467");
//    parameters:
	int cse_in; //
    int ae_in; //
    int ae_adn; //
    int cse_asn; //
    int ae_asn;
    int mn_cse;
//    int mnt_cse;
    int adn;
    int mn_ae;
//    
    int ae_in_count = cse_in * ae_in;
    int ae_adn_count = cse_in * ae_adn;
    int cse_asn_count = cse_asn * cse_in;
    int ae_asn_count = cse_asn_count * ae_asn;
    int mn_cse_count = cse_in * mn_cse;
    int mn_ae_count = mn_cse_count * mn_ae;
    int adn_count = mn_cse_count * adn;
    
    types:
        channel Channel extends ned.DelayChannel
        {
            delay = 100ms;
        }
    submodules:
        CSE_in[cse_in]: CSE;
        AE_in[ae_in_count]: AE;
        AE_adn[ae_adn_count]: AE; 
        CSE_asn[cse_asn_count]: CSE;  
        AE_asn[ae_asn_count]: AE; 
        AE_ad[adn_count]: AE;
        CSE_mn[mn_cse_count]: CSE;
        AE_mn[mn_ae_count]: AE;    
	
        
    connections allowunconnected:
        // Top level connections
        for i=0..(int(cse_in/2)-1), for j=int(cse_in/2)..(cse_in-1) {
            CSE_in[i].sibling++ <--> Channel <--> CSE_in[j].sibling++;
		}
		
		// AE-IN
		for i=0..(cse_in-1), for j = 0..(ae_in-1) {
			CSE_in[i].ae++ <--> Channel <--> AE_in[ae_in*i + j].cse++; 
		}
		//AE-ADN to CSE-IN
		for i=0..(cse_in-1), for j = 0..(ae_adn-1) {
			CSE_in[i].ae++ <--> Channel <--> AE_adn[ae_adn*i + j].cse++;
		}
		// CSE-ASN to CSE_IN
		for i=0..(cse_in-1), for j = 0..(cse_asn-1) {
			CSE_in[i].customer++ <--> Channel <--> CSE_asn[cse_asn*i + j].provider++;
		}
		//AE-ASN to CSE-ASN
		for i=0..(cse_asn_count-1), for j = 0..(ae_asn-1) {
			CSE_asn[i].ae++ <--> Channel <--> AE_asn[ae_asn*i + j].cse++;
		}
		
		//CSE-MN to CSE-IN
		for i=0..(cse_in-1), for j = 0..(mn_cse-1) {
			CSE_in[i].customer++ <--> Channel <--> CSE_mn[mn_cse*i + j].provider++;
		}
		
		//CSE-MN to ADN
		for i=0..(mn_cse_count-1), for j = 0..(adn-1) {
			CSE_mn[i].ae++ <--> Channel <--> AE_ad[adn*i + j].cse++;
		}
		
		//CSE-MN to AE-MN
		for i=0..(mn_cse_count-1), for j = 0..(mn_ae-1) {
			CSE_mn[i].ae++ <--> Channel <--> AE_mn[mn_ae*i + j].cse++;
		}
		
				


        
}
