Cananyone help me. I wrote a c code and this code supposed to classify network traffic into two classes but I used a bayesian classifier implementation but it is generating errors like
network_traffic2.c:11: error: `main' must return `int'
This is the code below:
Code:
#include <string>
#include <iostream>
#include "includes/smile.h"
#include "includes/network.h"
void main()
{
DSL_network theNet; // The Bayesian network
DSL_stringArray someNames; // String array used by libraries
DSL_stringArray * theNames;
DSL_doubleArray theProbs; // Array of doubles used to store probabilities
DSL_sysCoordinates theCoordinates; //
int intrusion; // Contains ID number for intrusion node
int traffic; // Contains ID number for traffic node
int alarm; // Contains ID number for alarm node
int Packet_size; // Contains ID number forPacket size node (jim)
int TCP_por_info; // Contains ID number for Traffic info request node (mary)
int true_value; // Contains ID number for true value of node
int false_value; // Contains ID number for false value of node
double current_belief;
intrusion = theNet.AddNode(DSL_CPT, "Intrusion");
someNames.Flush(); // Empty string array
someNames.Add("True"); // First Value
someNames.Add("False"); // Second Value
theNet.GetNode(intrusion) -> Definition() -> SetNumberOfOutcomes(someNames);
traffic = theNet.AddNode(DSL_CPT, "Traffic");
someNames.Flush(); // Empty string array
someNames.Add("True"); // First Value
someNames.Add("False"); // Second Value
theNet.GetNode(traffic) -> Definition() -> SetNumberOfOutcomes(someNames);
alarm = theNet.AddNode(DSL_CPT, "Raise Alarm");
someNames.Flush(); // Empty string array
someNames.Add("True"); // First Value
someNames.Add("False"); // Second Value
theNet.GetNode(alarm) -> Definition() -> SetNumberOfOutcomes(someNames);
Packet_size = theNet.AddNode(DSL_CPT, "Packet size");
someNames.Flush(); // Empty string array
someNames.Add("True"); // First Value
someNames.Add("False"); // Second Value
theNet.GetNode(Packet_size) -> Definition() -> SetNumberOfOutcomes(someNames);
TCP_por_info = theNet.AddNode(DSL_CPT, "TCP Port information");
someNames.Flush(); // Empty string array
someNames.Add("True"); // First Value
someNames.Add("False"); // Second Value
theNet.GetNode(TCP_por_info) -> Definition() -> SetNumberOfOutcomes(someNames);
theNet.AddArc(intrusion, alarm); // Add arc from intrusion to Alarm
theNet.AddArc(traffic, alarm); // Add arc from traffic to Alarm
theNet.AddArc(alarm, Packet_size); // Add arc from Alarm to Packet_size
theNet.AddArc(alarm, TCP_por_info ); // Add arc from Alarm to TCP_por_info
theProbs.SetSize(2);
theProbs[0] = .001;
theProbs[1] = .999;
theNet.GetNode(intrusion) -> Definition() -> SetDefinition(theProbs);
theCoordinates.LinkTo(*theNet.GetNode(traffic) -> Definition());
theCoordinates.UncheckedValue() = .002;
theCoordinates.Next();
theCoordinates.UncheckedValue() = .998;
theCoordinates.Next();
theCoordinates.LinkTo(*theNet.GetNode(alarm) -> Definition());
theCoordinates.UncheckedValue() = 0.95; // I, T, A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.05; // I, T, ~A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.94; // I, ~T, A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.06; // I, ~T, ~A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.29; // ~I, T, A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.71; // ~I, T, ~A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.001; // ~I, ~T, A
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.999; // ~I, ~T, ~A
theCoordinates.Next();
theCoordinates.LinkTo(*theNet.GetNode(Packet_size) -> Definition());
theCoordinates.UncheckedValue() = 0.9; // A, Packet_size
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.1; // A, ~Packet_size
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.05; // ~A, Packet_size
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.95; // ~A, ~Packet_size
theCoordinates.Next();
theCoordinates.LinkTo(*theNet.GetNode(TCP_por_info) -> Definition());
theCoordinates.UncheckedValue() = 0.7; // A, TCP_por_info
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.3; // A, ~TCP_por_info
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.01; // ~A, TCP_por_info
theCoordinates.Next();
theCoordinates.UncheckedValue() = 0.99; // ~A, ~TCP_por_info
theCoordinates.Next();
theNet.WriteFile("taiwo_traffic.dsl");
theNet.SetDefaultBNAlgorithm(DSL_ALG_BN_LAURITZEN); // Sets algorithm used to solve net
theNet.UpdateBeliefs(); // Has net go through and calculate current belief
// Find starting belief that Packet_size will be detected and raise
theCoordinates.LinkTo(*theNet.GetNode(Packet_size) -> Value());
theNames = theNet.GetNode(Packet_size) -> Definition() -> GetOutcomesNames();
true_value = theNames -> FindPosition("True"); // Should always be 0
false_value = theNames -> FindPosition("False"); // Should always be 1
theCoordinates[0] = true_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Starting belief that there is no %f\n", current_belief);
// Find starting belief that TCP_por_info show no intrusion
theCoordinates.LinkTo(*theNet.GetNode(TCP_por_info) -> Value());
theCoordinates[0] = false_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Starting belief that TCP_por_info show no intrusion is %f\n", current_belief);
// Find starting belief that an intrusion is happening
theCoordinates.LinkTo(*theNet.GetNode(intrusion) -> Value());
theCoordinates[0] = true_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Starting belief that a intrusion is happening is %f\n", current_belief);
// Repeat, this time with traffic set to true
theNet.GetNode(traffic) -> Value() -> SetEvidence(0);
theNet.UpdateBeliefs();
theCoordinates.LinkTo(*theNet.GetNode(Packet_size) -> Value());
theCoordinates[0] = 0; // Notice the change from true_value to 0
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that Packet_size will raise alarm if traffic happens is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(TCP_por_info) -> Value());
theCoordinates[0] = 1; // Notice the change from false_value to 1
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that TCP_port_info does not have intrusion is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(intrusion) -> Value());
theCoordinates[0] = true_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that a intrusion is happening during an traffic is %f\n", current_belief);
// Repeat, this time with alarm set to true
theNet.GetNode(traffic) -> Value() -> ClearEvidence();
theNet.GetNode(alarm) -> Value() -> SetEvidence(0);
theNet.UpdateBeliefs();
theCoordinates.LinkTo(*theNet.GetNode(Packet_size) -> Value());
theCoordinates[0] = 0;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that Packet_size will raise alarm if there is intrusion is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(TCP_por_info) -> Value());
theCoordinates[0] = 1;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that TCP_port_info will not raise alarm if intrusion happens is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(intrusion) -> Value());
theCoordinates[0] = true_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that an intrusion is happening when alarm goes off is %f\n", current_belief);
// Now set traffic to true
theNet.GetNode(traffic) -> Value() -> SetEvidence(0);
theNet.UpdateBeliefs();
theCoordinates.LinkTo(*theNet.GetNode(Packet_size) -> Value());
theCoordinates[0] = 0;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that Packet_size will raise alarm if the intrusion happens is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(TCP_por_info) -> Value());
theCoordinates[0] = 1;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that TCP_port_info will not raise alarm intrusion happens is %f\n", current_belief);
theCoordinates.LinkTo(*theNet.GetNode(intrusion) -> Value());
theCoordinates[0] = true_value;
theCoordinates.GoToCurrentPosition();
current_belief = theCoordinates.UncheckedValue();
printf("Belief that a intrusion is happening with alarm and earthquake true is %f\n",
current_belief);
}


