经过两周辛勤的的工作,把实验一实验三完成了,不过其中还是有点不足的,不过主要实验目的完成了,后面还有一些不太要紧的就算了。
后面有空的话 应该还会把实验五做一下
源码:https://github.com/cuixuage/NetWorking_MiniNet
Experiment
1.Switch_stack交换机实验 completed in 2017/11/8
实现对数据结构mac_port_map的所有操作,以及数据包的转发和广播操作
思路:
1.对于收到的packet,根据其des_mac在FDB表中进行查询,存在对应的interface则转发,否则在局域网内广播此packet
2.对于收到的packet,如果其src_mac不在FDB表中则认为是新加入的主机,将其src_mac与interface物理端口的映射关系加入FDB
3.key points: 当交换机从某一个interface收到来自src_mac地址的A主机的packet时,可以确定: des_mac为A主机的packet从其对应的inerface转出即可到达A主机
实现函数:
-iface_info_t *lookup_port(u8 mac[ETH_ALEN]);
-void insert_mac_port(u8 mac[ETH_ALEN], iface_info_t *iface);
-int sweep_aged_mac_port_entry();
-void broadcast_packet(iface_info_t *iface, const char *packet, int len);
-void handle_packet(iface_info_t *iface, cha