//init void Start() { IP = "0.0.0.0"; //setup mac address for (int i = 0; i < 6; i++) { if (i != 5) { MAC += Random.Range(0, 99).ToString() + ":"; } else { MAC += Random.Range(0, 99).ToString(); } } engine = GameObject.FindGameObjectWithTag("Engine"); //setup ports for (int i = 0; i < numPorts; i++) { Vector3 position = new Vector3(0, 0.5f, 0); //instantiate port and set parent as this transform ports.Add(Instantiate(engine.GetComponent <Engine>().PortPrefab, transform.position, Quaternion.identity)); ports[i].transform.parent = transform; ports[i].transform.localPosition = position; //set up type ports[i].Init("fe0/" + i); } //other applications ping = gameObject.GetComponent <Ping>(); subnet = gameObject.GetComponent <Subnet>(); arp = gameObject.GetComponent <ArpUpdate>(); }
// Use this for initialization void Start() { arp = GetComponent <ArpUpdate>(); int numPorts = numFEPorts + numGPorts; for (int i = 0; i < 6; i++) { if (i != 5) { MAC += Random.Range(0, 99).ToString() + ":"; } else { MAC += Random.Range(0, 99).ToString(); } } engine = GameObject.FindGameObjectWithTag("Engine"); //set up ports for (int i = 0; i < numPorts; i++) { Vector3 position = new Vector3(-21, -15 + (2 * i), 0); ports.Add(Instantiate(engine.GetComponent <Engine>().PortPrefab, transform.Find("PivotPoint").position, Quaternion.identity)); ports[i].transform.parent = transform; ports[i].transform.localPosition = position; if (i >= numFEPorts) { ports[i].Init("g0/" + (i - numFEPorts)); ports[i].gameObject.AddComponent <Subnet>(); ports[i].GetComponent <Subnet>().CreateRouteConfiguration("192.168." + ((i - numFEPorts) + 1) + ".0", "255.255.255.0", "192.168." + ((i - numFEPorts) + 1) + ".1"); gameObject.AddComponent <DHCPServer>(); } else { ports[i].Init("fe0/" + i); ports[i].gameObject.AddComponent <Subnet>(); } } servers = GetComponents <DHCPServer>(); int serverNum = 0; for (int i = 0; i < numPorts; i++) { if (ports[i].getType().Contains("g")) { servers[serverNum].Setup(ports[i].GetComponent <Subnet>()); RoutingTable.Add(ports[i].GetComponent <Subnet>().network, ports[i]); serverNum++; } } }