A & B
路由器: OSPF 协议
![](https://pic.imgdb.cn/item/61da0b6c2ab3f51d9172196f.png)
接收方要确保报文没有被修改
![](https://pic.imgdb.cn/item/61da3e842ab3f51d91889ef6.png)
将长报文进行精简
报文摘要不容易得到原报文
m & K<sub>B-</sub>(H(m))
不同的报文可能有一样的校验值
advatages of chekpoints:
借助checkpoint进行回滚·
从后往前扫描undo log
Can still do cascadinng rollbacks, but only active transactions can be forced to abort
Cascadeless schedules
A schedule is strict if each transaction in it reads and writes only values that were written by transaction that have already committed
如果调度中的每个事务只读取和写入已经提交的事务写入的值,则调度是严格的
Two approaches for deadlock prevention:
计划事务,以便其效果与在每个事务启动时立即执行相同。
terminology:
link layer has responsibility of transferring datagram from one node to physically adjacent node over a link
transportation analogy:
EDC: error detection and correction bits (e.g., redundancy)
D: data protected by error checking, may include header fields
数据检查并非百分百可靠
3. 两边同除G得到余数 «R=
Transaction
The complication arises from that many might happen at the same time and that computers can fail…
In parctice, problems may arise due to
如果第一位乘客订过这个座位后面的人就没法再定这个座位了
SQL allows us to state that a group of SQL Statements must be executed so that no conflicts arise
Acounts(accountNo, accountHolder, balance)
Goal: transfer 100 gbp from account ‘123’ to account ‘456’
SQL allows to state that a transaction must be executed atomically(as a whole or not at all)
Transaction in SQL: a sequence of SQL statements
Introduce a simplified and lower level view of transaction as well as schedules and notatios for all of these
Employees(e_id, first_name, last_name, birth_day, salary)
read(X): Reads a database item X into a program variable (also named X, for simplicity)
write(X): Writes the value of program variable X into the database item named X
A logical unit of processing using access operations
Schedules hold many transactions for execution
The operations making up the transactions are then executed by the schedule in some order
Two types:
Executes all operations in transaction T1,
then all operations in transaction T2.
For simplicity we will typically ignore
the non-database operations…
Sb: r1(x); w1(x); c1; r2(x); w2(x); c2
A transaction is an atomic unit of processing
Deals with failure(“aborts”)
Abort - an error prevented full execution
Commit - no error, entire transaction executes
A correct execution of the transaction must take the database from one consistent state to another
From definition:
A correct execution of the transaction must take the database from one consistent state to another
A schedule satisfies isolation iff it is serializable (I.e. like last slide: the effect of a serializable schedule is the same as some serial schedule)
Once a transaction commits and changes the database, these changes cannot be lost because of subsequent failure
how much concurrency can be allowed while still being close enough to serial schedule
Serial Schedules
Concurrent Schedules(non-serial)
Efficiency: Say that this table denotes arrival time of
the commands (and that each commands takes 1 time
unit)
Concurrent Schedule not always equilent to a serial Schedual
read(X): Reads a database item X into program variable(also named X, for simplicity)
write(X): Writes the value of program variable X into the database item named X
A schedule S is serializable if there is a serial schedule S’that has the same
effect as S on every initial database state.
Serializable schedules are essentially those schedules
that we are looking for!
Guarantee:
Problem: serializability is difficult to test
Serializable schedules are too complex, so what is DBMS doing instead?
Stronger form of serializability that is used/enforced by most commercial DBMS
Based on the notion of a conflict.
A conflict in a schedule is a pair of operations
Two schedules S and S’ are conflict-equivalent if S’ can be obtained from S by swapping any number of (1) consecutive (2) non-conflicting operations from (3) different transactions
A schedule is conflict-serialisable if it is conflict-equivalentto a serial schedule.
recognize conflict-serializable
The precedence graph for a schedule S is defined as follows:
how conflict-serializable schedules
A transaction has to lock an item before it accesses it.
Locks are requested from & granted by the scheduler:
Each lock has to be released(ublocked) eventually
Extend syntax for schedules by two operations:
Example:
Simple modification of the simple locking mechanism that guarantees conflict-serializability
Two-phase locking(2PL) condition
In each transaction, all lock operations precede all unlocks (所有锁定操作优先于解锁操作)
Find first unlock
Transaction is 2PL iff phase 2 contains no lock
2PL schedules are conflict-serializability
Simple modification of the simple locking mechanism that guarantees conflicy-serializability
Two-phase locking(2PL) condition:
In each transaction, all lock operations precede all unlocks
If S is a schedule containing only 2PL transactions, then S is conflict-serializable
Proof idea
2PL ensures conflict-serializability, but might lead to
Update lock:
New upgrading policy:
Straightforward generalisation:
In each transaction, all lock operations (i.e., shared, exclusive, or update lock requests) precede all unlocks
DBMS may use locks at different levels of granularity
Examples:
1 | SELECT name FROM Student WHERE studentID = 123456; |
Locking at too coarse granularity:
Locking at too fine granularity:
Need to prevent issues such as the following
to guarantee (conflict-) serialisability:
Errors while executing transactions
Idea: write important activities to a log so that a desired database state can be recovered later
Examples of important activities:
Should work even in case of system failures!
Techniques:
other kinds of logging how to get atomicity and durability from logging
redo log是指在回放日志的时候把已经COMMIT的事务重做一遍,对于没有commit的事务按照abort处理,不进行任何操作。
使用redo log时, 要求
使用redo log时事物执行顺序:
使用redo log重做事务
consider error of model M over
model M $\in$ H overfits the training data if there is an alternative model M’ $\in$ such that
Example: overfitting with noisy data
Definition
Speeding up k-NN
Variants of k-NN
Discussions
![](https://pic.imgdb.cn/item/6197ed042ab3f51d91266b92.png)
•https://en.wikipedia.org/wiki/Voronoi_diagram
•https://courses.cs.washington.edu/courses/cse326/00wi/projects/voronoi.html
网络层
控制平面:全局
数据平面:局部
network-layer functions:
analogy: taking a trip
Data plane:
Control plane
Individual routing algorithm components in each and every router interact in the control plane
Remote controller computes, installs forwarding tables in routers
High-level view of generic router architecture:
分散的切换
Longest prefix match
when looking for forwarding table entry for given destination address, use longest address prefix that matches destination address.
Example 1: interface:0
Example 2: interface:1
Transfer packet from input link to appropriate output link
switching rate: rate at which packets can be transfer from inputs to outputs
often measured as multiple of input/output line rate
N inputs: switching rate N times line rate desirable
three major types of switching fabrics:
First generation routers:
Drop policy: which datagrams to drop if no free buffers?
Datagrams can be lost due to congestion, lack of buffers
Priority scheduling - who gets best performance, network neutrality
host, router network layer functions:
Recipe for defining subnets:
CIDR: Classless Inter Domain Routing(pronounced “cider”)
Q: How does a hostget IP address within its network (host part of address)?
Q: How does a networkget IP address for itself (network part of address)
How does hostget IP address?
goal: host dynamically obtain IP address from network server when it “joins” network
DHCP overview
DHCP can return more than just allocated IP address on subnet:
hierarchical addressing allows efficient adverrisement of routing information:
NAT: all devices in local network share just one IPv4 address as far as outside world is concerned
Review: each router contains a forwarding table (aka: flow table)
Router
Switch
Firewall
NAT
Individual routing algorithm components in each and every
router interact in the control plane
Remote controller computes, installs forwarding tables in routers
aggregate routers into regions known as “autonomous systems” (AS) (a.k.a. “domains”)
inter-AS(aka “inter-domain”): routing among AS’es
intra-AS(aka “intra-domain”): routing within same AS(“network”)
most common intra-AS routing protocols:
policy:
scale:
performance:
Remote controller computes, installs forwarding tables in routers
形式规范的代数方法特别适合于接口规范
传输层
Understand priciples behind transport layer services:
Learn about Internet transport layer protocols:
主机与进程之间的区别
传送端:
接收端:
两种服务无法改变延迟,带宽
(吞吐量)
在传送端复用,在接收端解复用
1 | DatagramSocket mySocket1 = new DatagramSocket(12534); |
当接收主机接收到 UDP字段:
IP/UDP datagrams with same dest.port#, but different source IP address and/or source port numbers will be directed to same socket at receiving host
目标端端口一样, 源端IP和端口被引导到同一个接受主机的套接字
Wbhy is there a UDP
![](https://pic.imgdb.cn/item/617bad302ab3f51d91fcccd5.png)
用来检测在传输字段里的错误
Goal: detect errors in transmitted segment
Sender:
Receiver
需要在进入非可靠channel之前加安全协议
可靠传输协议的复杂度由非可靠channel的特征决定
接收端和发送端彼此不知道对方的状态除非经由报文沟通
We will:
channel with bit errors
发送方留副本,接收方检验
channel with bit errors
FSM specifications
Note: 接收端和发送端彼此不知道对方的状态除非经由某种方式沟通
operation with no errors
corrupted packet scenario
has a fatal flaw!
when ACK/NAK corrupted happened
handling duplicates:
sender, handling grabled ACK/NAKs 停止等待协议
发送方:初始化等待上层调用零 ——> 等待 ACK/NAK (没收到/NAK- 重发) ——> 等待上层调用1 ——> 等待 ACK/NAK (没收到/NAK- 重发)
接收方: 等待下层调用0 成功的话提取data 并返回ACK 如果重复数据 重新发送 ——> 等待下层调用1
discussion
sender:
receiver:
a NAK-free protocol
sender, receiver fragments
New channel assumption: underlying channel can also lose packets(data, ACKs)
channel with errors and loss
Approach: sender waits “reasonable” amount of time for ACK
sender
in action
Performance of rdt3.0
stop-and-wait operation
RTT
piplining: sender allows multiple, “in-flight”, yet-to-be-acknoledged packets
Pipelining: increased utilization
Sw = 1 Rw = 1 等停协议 rdt 3.0
流水线协议:
Sw > 1 Rw = 1 GBN协议
Sw > 1 Rw > 1 选择性重发协议
发送缓冲区: 发送方发送完之后将分组放在缓冲区中以用于鉴错重发超时重发
发送窗口: 发送缓冲区的一个范围
sender
接收缓冲区:
接收窗口:
receiver
in action
sender, receiver, windows
sender and receiver
Selective Repeat in action
Sequence numbers:
Acknowledgements:
set TCP timeout
estimate RTT
timeout interval: EstimatedRTT plus “safety margin”
event: data received from application
event: timeout
event: ACK received
![](https://pic.imgdb.cn/item/617ef3aa2ab3f51d910414ff.png)
累加ACK 覆盖了先前丢失的ACK
if sender receives 3 additional ACKs for same data(“triple duplicate ACKs”), resned unACKed segment with smallest seq#
当网络层传输信息的速度大于应用层从套接字缓冲区移除信息的速度
Application removing data from TCP socket buffers
before exchanging data, sender/receiver “handshake”:
Agreeing to eatablish a connection
2-way handshake in network
2-way handshake scenarios
TCP 3-way handshake
Closing a TCP connection
End-end congestion control
Network-assisted congestion control:
Fairness goal: if K TCP sessions share same bottleneck link of banwidth R, each should have average rate of R/K
Is TCP Fair?
Example: 两个竞争的TCP会话
1 | /************************************* |
1 | /********************************** |
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是yilia根目录)执行以下命令:
npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置:
jsonContent: meta: false pages: false posts: title: true date: true path: true text: false raw: false content: false slug: false updated: false comments: false link: false permalink: false excerpt: false categories: false tags: true