这个作业属于哪个课程 https://edu.cnblogs.com/campus/fzu/2022OOP?filter=all
这个作业要求在哪里 https://edu.cnblogs.com/campus/fzu/2022OOP/homework/12442
这个作业的目标 模拟路由数据处理
作业正文 如下
其他参考文献

An overview of my failed project

Lead in

In this project, we need to program a project to match the data_list with the rule_list and output the ans_list.

As a result, however, I failed finally.

The most challenged part, as for me, is that I cannot figure out how to use the File Pointer correctly and it seems to be a huge time-spending task to learn that part of knowledge.

My github website

What We Need To Learn

1.How to use file I/O (learnt,but cannot use it fluently and correctly)

2.How to use *file(as a file pointer)(I will learn this part and will fill in the blank of my project in the winter vacation)

3. Know about TCP/IP and need to deal with CIDR code(failed)

4.use visual stdio to program as a big project (succeed, to some extent)

Here is my thought(as a brief pseudo code)

#include<bits/stdc++.h>
int main () {
	{
		ifstream fin();//fin Rule//输入Rule文件
		f()//对文件进行处理;

		fin.close();;//关掉Rule文件
	}

	{	
		ifstream fin();//fin data i//输入Data文件
		f()//对文件进行处理;

		fin.close();;//关掉Rule文件
	}


		f//f(match)//对两个文件进行匹配 
			//变量如下
		1.data_ip_source & rule_ip_source_low & rule_ip_source_high;
		2.data_ip_destination & rule_ip_destination_low & rule_ip_destination_high;
		3.data_port_source & rule_port_source_low & rule_port_source_high;
		4.data_port_destination & rule_port_destination_low & rule_port_destination_high;
		5.tcp_source & tcp_destination;

		//{
			data源ip == rule源ip;
			data目的ip between rule目的ip范围;
			data源port between rule源port范围;
			data目的port between rule目的port范围;
			data的tcp == rule_tcp or (rule_ctp == 0xFF);

		fout << ();//将结果输出result;


	ofstream fout();


}

Then I Write Down The Match_Function(as below)


bool match(&data,&rule)
{
        if (data_ip_source < rule_ip_source_low ||
        data_ip_source > rule_ip_source_high) {
        return false;
    }        
        if (data_ip_destination < rule_ip_destination_low ||
            data_ip_destination > rule_ip_destination_high) {
        return false;
    }
        if (data_port_source < rule_port_source_low
            || data_port_source > rule_port_source_high) {
            return false;
    }
        return false;
        if (data_port_destination < rule_port_destination_low
            || data_port_destination > rule_port_destination_high) {
            return false;
    }
        return false;
        if (tcp_source != tcp_destination && tcp_destination <= 255) {
            return false;
    }

    return true;
}

Then We Should Figure Out The Function To Deal With Our Binary_IP_Code(both used for data_list and rule_list)

So I write the code to deal with it as below.

void num_10_to_8(int num, char arr[9]) {
	int i;
	for (i = 1; i <= 8; i++) {
		arr[i] = '0';
	}
	for (i = 1; i <= 8; i++) {
		arr[i] = num % 2 + 48;
		num >> 1;
	}
}

Next step, we should input our ip_code in this function.(In my opinion, using pointer and push and pop would be a choice.And I will learn that part of knowledge and finish my code project in the near future.)

So, there will be a blank part for my function. And I promise I will figure out the important part.

Then match.(Have been shown before)

Finally,output our "res.txt"file.

My Harvest & Problems needed to be solved

Learnt to process file's I/O

Learnt to use Visual Studio

Learnt to program a project with several separated files

Need to Learn to process the rule_list & data_list. And need to finish the code.