基础概念 github
用完即删: https://www.cs.cmu.edu/~02710/Lectures/HMMs.pdf
https://stats.stackexchange.com/questions/47846/how-to-define-initial-probabilities-for-hmm
https://kns.cnki.net/KCMS/detail/detail.aspx?dbcode=CJFD&dbname=CJFDLAST2017&filename=JSJA201709027&uid=WEEvREcwSlJHSldRa1FhdXNXaEd2Um5YbmZTc2dJd1FNdWFiNGNMeWI2cz0=$9A4hF_YAuvQ5obgVAqNKPCYcEjKensW4IQMovwHtwkF4VYPoHbKxJw!!&v=MDg4NDV4WVM3RGgxVDNxVHJXTTFGckNVUkxPZll1UnVGQ2psVTc3UEx6N0JiN0c0SDliTXBvOUhZNFI4ZVgxTHU=
http://www.cnblogs.com/pinard/p/6945257.html
https://www.cnblogs.com/pinard/p/6638955.html
https://applenob.github.io/hmm.html
file:///home/yubo/Desktop/essay/ddos-%E5%9B%BD%E9%98%B2%E7%A7%91%E6%8A%80%E5%A4%A7%E5%AD%A6.pdf
-mininet>
退出 输入quit或者exit»
mininet -c
help查看有用的必要信息
node列出所有由mn部署的网络设备
dump展示相应的网络设备信息
net展示相连的网络设备
还可以打开属于其中一个客户端的terminal,比如,如果,你有一个h1,
xterm h1
sudo mn –topo single,4 One switch connected to 4 hosts sudo mn –topo tree,depth=3,fanout=2 Tree of depth 3, with two children per node sudo mn –topo linear,3 3 switches, one aEer the other, and one host per switch 下面是一个简单的命令展示:
sudo mn --topo linear,4
*** Creating network
*** Adding controller
*** Adding hosts:
h1 h2 h3 h4
*** Adding switches:
s1 s2 s3 s4
*** Adding links:
(h1, s1) (h2, s2) (h3, s3) (h4, s4) (s2, s1) (s3, s2) (s4, s3)
*** Configuring hosts
h1 h2 h3 h4
*** Starting controller
c0
*** Starting 4 switches
s1 s2 s3 s4 ...
*** Starting CLI:
mininet>
基本参考来自这里here
因为这个问题在电话面试的时候被问的次数太多了,哈哈,目前,市面上也没有很好的教程去说明这个问题。
再次总结下自己的学习kernel艰苦的路程。我发现了,所谓的自己深入不进去,是自己读的太少或者认真思考的太少,包括这几次面试,都是问的一些基础知识,那为什么掌握不了呢?这需要自己好好反思了。到底哪里出了问题。
千方百计,毛主席说过的话,自己何尝努力了几分之几。对吧,这个样子,是自己不上心的后果之一。
我知道的一个问题就是,自己看不懂的就不记了,其实你说这些都不能记住吗?东西也就是那么多,自己记住一点是一点。
就从网卡说起吧。 版本2.6.x
以这篇文章为例这篇文章不会设计具体的函数,大体记录下简要。
struct pci_device_id {
__u32 vendor, device;
...
}
大多数网卡就是一个PCI设备,然后是一个 **struct pci_device_id **的数组。
static struct pci_device_id e100_id_table[] = {
INTEL_8255X_ETHERNET_DEVICE(0x1029, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1030, 0),
INTEL_8255X_ETHERNET_DEVICE(0x1031, 3),
……/*略过一大堆支持的设备*/}
同时,pci设备需要pci_driver:
struct pci_driver {
struct list_head node;
char *name;
struct module *owner;
const struct pci_device_id *id_table; /* must be non-NULL for probe to be called */
int (*probe) (struct pci_dev *dev, const struct pci_device_id *id); /* New device inserted */
void (*remove) (struct pci_dev *dev); /* Device removed (NULL if not a hot-plug capable driver) */
int (*suspend) (struct pci_dev *dev, pm_message_t state); /* Device suspended */
int (*resume) (struct pci_dev *dev); /* Device woken up */
int (*enable_wake) (struct pci_dev *dev, pci_power_t state, int enable); /* Enable wake event */
void (*shutdown) (struct pci_dev *dev);
struct device_driver driver;
struct pci_dynids dynids;
};
在系统引导的时候,PCI设备可以被发现,其实这个引导的过程应该很有趣,实在是应该探究一番去瞧一瞧。
当内核发现一个已经检测到的设备同驱动注册的id_table中的信息相匹配时, 它就会触发驱动的probe函数,以e100为例:
/*
* 定义一个名为e100_driver的PCI设备
* 1、设备的探测函数为e100_probe;
* 2、设备的id_table表为e100_id_table
*/
static struct pci_driver e100_driver = {
.name = DRV_NAME,
.id_table = e100_id_table,
.probe = e100_probe,
.remove = __devexit_p(e100_remove),
#ifdef CONFIG_PM
.suspend = e100_suspend,
.resume = e100_resume,
#endif
.driver = {
.shutdown = e100_shutdown,
}
};
这样,如果系统检测到与id_table 中对应的设备时, 就会调用驱动的probe函数。 驱动设备在init函数中,调用pci_module_init函数初始化PCI设备e100_driver:
tatic int __init e100_init_module(void)
{
if(((1 << debug) - 1) & NETIF_MSG_DRV) {
printk(KERN_INFO PFX "%s, %s/n", DRV_DESCRIPTION, DRV_VERSION);
printk(KERN_INFO PFX "%s/n", DRV_COPYRIGHT);
}
return pci_module_init(&e100_driver);
}
下面的问题就很重要了,需要记忆的东西比较多
为了节省时间,我在这次安装debian的时候使用了最小化安装的方式,期间遇到了一点小问题,所以记录在这里。
首先申明,我这是在windows上安装虚拟机后安装的debianm,形式上这个方式最简单的,这里澄清了我一直以来的几个疑惑。 先说一下,宿主windows系统的环境.
以太网适配器 VirtualBox Host-Only Network:
连接特定的 DNS 后缀 . . . . . . . :
本地链接 IPv6 地址. . . . . . . . : fe80::d067:c83c:6978:62ce%10
IPv4 地址 . . . . . . . . . . . . : 192.168.56.1
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . :
以太网适配器 以太网:
连接特定的 DNS 后缀 . . . . . . . :
本地链接 IPv6 地址. . . . . . . . : fe80::8412:4c53:e44b:c829%3
IPv4 地址 . . . . . . . . . . . . : 10.7.164.59
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . : 10.7.164.254
也就是说,debian的外部ip(vbox的网卡显示)已经自动b分配了,一开始我还想着这个ip与内部的debian系统有关系 。就我目前的环境,我才明白,最小化安装方式是没有这种联系的。最小化安装方式里面,已经内置了dhcp协议,你可以直接设置。 登录到debian系统中,首先查看网卡接口,使用__ip a__即可。 接着就可以手动修改网络设置了。打开__/etc/network/interfaces/__文件,这样写:
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto enp0s3
iface enp0s3 inet dhcp
#address 192.168.56.5
#netmask 255.255.255.0
#gateway 192.168.56.1
#dns-nameserver 8.8.8.8
然后重启网络服务:
sudo /etc/init.d/networking restart
这个时候你就可以验证一下了:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:dc:fa:06 brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fedc:fa06/64 scope link
valid_lft forever preferred_lft foreveriii
其中,enp0s3是我的debian网络接口,这个你可以设置自己的。#符号开始的,是针对于固定ip的,这个时候你可以忽略。 。这个linux 的主机ip为 10.0.2.15/24
完成网络设置之后,你就应该更新源了,注意自己系统的代号,我就因为这个耽误了很长时间。
首先确保虚拟机的系统安装ssh服务器,debian下的ssh为openssh-server.然后再vbox的网络设置里面设置一个网络端口转发。 vbix界面主机IP默认为空(127.0.0.1或者localhost),主机端口8080(这个你可以自己设置),子系统IP默认就可以,为linux系统的ip地址: 10.0.2.15/24,挺有意思的默认就可以,为linux系统的ip地址: 10.0.2.15/24,挺有意思的。子系统端口为ssh的默认端口就好:22.
在vbox里设置完成之后,就可以使用终端工具登录内部的linux了。
ssh -p 8080 username@localhost
局域网访问的意思是,虚拟机里的主机可以被外部访问,宿主操作系统类似一个网桥,对,也就是你在设置虚拟机链接主机的方式为桥接方式,然后静态的设置一个属于z你这个网段的ipd即可。当然,真实debian环境也是如此.
cat /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
auto enp0s3
#iface enp0s3 inet dhcp
iface enp0s3 inet static
address 10.7.164.78
netmask 255.255.255.0
gateway 10.7.164.254
dns-nameserver 10.7.164.254
这里的debian有一点我不是很理解,这里的DNS服务器为网关地址才可以,不知道我的理解对不对。
这边文章简单记录leetcode的简单数学题目。
Write an algorithm to determine if a number is “happy”.
A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process ends in 1 are happy numbers.
Example:
Input: 19
Output: true
Explanation:
1^2 + 9^2 = 82
8^2 + 2^2 = 68
6^2 + 8^2 = 100
1^2 + 0^2 + 0^2 = 1
这道题目其实很简单,原先没有想到开始的逻辑,后来看到网上的介绍是说可以利用 HashmapSet数据结构来结束无限循环。好是好,但是我利用c语言目前还没有具体实现,所以,先偷个懒,利用一点数学的技巧。
数学上,非快乐数一定会出现4,至于为什么,我也没有搞明白。那么,以后遇到这样的问题怎么办?我觉得最好尝试着写出几个数字,来看看其中有没有相同点。 下面是第一版的解决方法。
bool isHappy(int n){
int sum;
while ( n != 1 && n != 4){
sum = 0;
while(n){
sum += (n % 10) * (n % 10);
n /= 10;
}
n = sum;
}
return n == 1;
}
上面的代码段中有一点是如何统计一个整数的各位数字,这个思想值利用,还有一个就是先除再乘。
计算一个整数范围内质数的个数. 版本1:
bool is_prime(int n){
int i;
int flag = 1;
if (n <= 1)
return false;
for(i = 2; i * i <= n; i++){
if(n % i == 0){
flag = 0;
break;
}
}
return flag;
}
int countPrimes(int n){
int res = 0;
int i;
for(i = 1; i < n;i++){
if(is_prime(i))
res++;
}
return res;
}
求一个int的sqrt,我首先使用的暴力求解, 简直惨不忍睹,
class Solution {
public:
int mySqrt(int x) {
if (x == 0) {
return 0;
}
int i = 0, ret = 0;
while(i * i < x){
i++;
if (i == 46340)
break;
}
if (i * i > x)
return i - 1;
else
return i;
}
};