Operating Systems and Systems
Programming
Semester 1, 2024
Eike Ritter, David Oswald
The University of Birmingham
30 September, 2024
Exercise 1
Deadline: 14 November, 4pm
The Task
Write a set of programs which maintains the firewall configuation.
1. One program is a server program. Once started, the server should run for ever. It waits for requests, process them and produce a specific response.
The server maintains a collection of firewall rules. For each rule in the
collection of rules, the server also maintains a list of pairs of IP addresses
and ports which have been queried and found to match this rule. The
server also maintains a list of all requests submitted to it. The server
program should accept and process requests and return a response as
follows:
❼ Listing all requests in the order they were given. The command for
this request is R
❼ Adding a rule to the stored rules. This request expects a string which
contains a firewall rule as specified below. If the rule is valid, the
rule is added the set of firewall rules. The response is Rule added
if the rule has been added, and Invalid rule if the string is not a
valid rule. The command for this request is
A <rule>
❼ Checking whether a given IP address and port are allowed according
to the rules. If this is the case, the IP address and port are added
to list of matched queries for this rule. If the given address and port
are allowed according to several rules, you should add the IP address
and port to only one rule. If the given IP address and port is checked
again, they may be added to a different rule. If the input does not
provide a valid IP address and a valid port, the response should be
Illegal IP address or port specified. If the IP address and
port are valid and should be accepted according to the rules, the
response should be Connection accepted. If the IP address and
port are valid and should be rejected according to the rules, the
response should be Connection rejected. The command for this
request is
C <IPAddress> <port>
1
❼ Delete a valid rule from the stored rules. This should also delete the
list of IP addresses and ports stored for this rule. The rule should
only be deleted if the server stores exactly the same rule. In all
other cases, no action should be taken except returning a suitable
message. If the specification of the rule is invalid, the response should
be Rule invalid. If the rule is successfully deleted, the response
should be Rule deleted. If the rule is valid but not found on the
server, the response should be Rule not found. The command for
this request is
D <rule>
❼ Return all rules and for each rule list all IP addresses and ports
which are stored with it. More precisely, for each rule, the response
should be
Rule: <rule>
where <rule> is the specification of the rule as given below, followed
by
Query: <IPaddress> <port>
for each query stored with this firewall rule. The command for this
request is L
❼ For any other request, the response should be Illegal request.
There are two ways of interacting with the server program.
❼ The first one is to start the server with
<ServerProgram> -i
where <ServerProgram> is the way to call the server program, typ ically ./server. In this mode the server reads an command from
standard input, prints the response and waits for the next input.
❼ The second way of running the server is
<ServerProgram> <port>
where <ServerProgram> is the way to call the server program, typ ically ./server, and <port> is the port on which the server listens
for incoming connections. A client program, which you will have to
write as well, makes it possible to send commands to the server pro gram and display the results on standard output. The client should
be called with
<ClientProgram> <serverHost> <serverPort> <command>
without any quotes, e.g.
./client localhost 2200 A 147.188.193.15 22
All other ways of calling the client program should return an error
message.
2
The specification of a firewall rule is below.
A rule is of the form
<IPAddresses> <ports>
where <IPAddresses> is either a single IP address, which has the form xxx.xxx.xxx.xxx,
where xxx is a number between 0 and 255, or <IPAddress1>-<IPAddress2>,
where <IPAddress1> and <IPaddress2> are IP addresses, and <IPAddress1> is
smaller than <IPaddress2>. Assume that IP addresses and ports are separated
by exactly one space character.
Similarly, <ports> is either a single port number, which is a number between
0 and 65535, or <port1>-<port2>, where <port1> and <port2> are ports and
<port1> is smaller than <port2>.
Examples of such rules would be
147.188.193.0-147.188.194.255 21-22
147.188.192.41 443
Your server program should maximise the degree of concurrency and not contain
any memory leaks.
Submission and Marking
❼ You should submit the file server.c and client.c on the appropriate
canvas-quiz. The marking scripts will execute the command make with
the Makefile provided in the archive on canvas to produce all required
binaries.
❼ The zip-archive on canvas contains a Makefile and a basic test script is
provided in the file test.sh. The Makefile and the test script will only
work if server.c and client.c are in the same directory as the Makefile
and the test script respectively. The test script tests the cases of adding
a rule both interactively and via sockets. It is run by changing into the
directory containing the binaries and then running
./test.sh
We will use more advanced scripts for marking which test all the specified
functionality, including concurrency and memory leaks. If the basic test
script does not work, all other scripts are likely to fail as well.
❼ Code which does not compile on the virtual machine provided will be
awarded 0 marks.
Hints
❼ You should start by implementing the interactive version of the server
(the version running with server -i) and the R-command. Sockets and
concurrency will be explained in later lectures.
3
❼ You may use the code provided in the lectures in your assignments as you
see fit.
相关推荐
【人工智能】你知道什么是DeepSeek吗?你有去了解过DeepSeek吗?新手要入门DeepSeek的必经之路——初识DeepSeek
【人工智能】初识DeepSeek 详细介绍DeepSeek以及DeepSeek-R1
Operating systems and distributed systems
Modern Distributed Systems: Reinventing OS Primitives Across Networks Distributed systems mirror traditional OS concepts—schedulers become orchestrators (Kubernetes), mutexes turn into distributed locks (Zookeeper), and shared memory evolves into state rep
手把手教你用HiNet实现图像隐藏:可逆神经网络实战指南(附代码)
本文提供了一份基于HiNet框架实现图像隐藏的实战指南。通过详细解析可逆神经网络原理,手把手指导环境搭建、模型构建、损失函数设计及训练流程,并附有完整代码。该方法利用单个可逆网络统一隐藏与恢复过程,结合小波变换提升隐蔽性,为信息隐藏应用提供了高效解决方案。
Operating Systems Design and Implementation, Third Edition
<br /> The popularity of MINIX has continued, as can be observed by examining the number of hits for MINIX found by Google. <br /><br />This third edition of the book has many changes throughout. Nearly all of the material on principles has been revised, a
COMSOL模拟CO2驱替CH4:多物理场耦合建模与工程应用详解
在非常规天然气开发与碳封存工程中,多孔介质内的渗流、吸附与岩石变形相互耦合,使得CO2驱替CH4的产能预测和CO2封存评估无法仅靠经验公式完成。以达西定律描述裂隙流动、以扩展Langmuir方程刻画竞争吸附、用应力-吸附-渗透率关系关联煤岩变形,是多物理场耦合数值模拟的核心路径。COMSOL Multiphysics凭借内置渗流、固体力学与组分传递接口,能够将这些机制整合为可参数化扫描的仿真模型,为注气压力、井距、渗透率演化等方案设计提供量化依据。围绕CO2驱替CH4模拟的建模流程、参数取法与结果判读,可形
FAGLB03余额显示异常排查与修复指南
本文针对SAP新总账中FAGLB03报表余额显示异常问题,提供了专业的排查与修复指南。文章深入剖析了数据不一致的核心原因,如FAGLFLEXT汇总表与凭证明细不同步、年度余额结转(FAGLGVTR)失败等,并详细介绍了使用FAGLF03进行精准诊断、通过SE38执行标准调整程序TFC_ADJUST_VZ进行修复的标准操作流程,帮助用户快速恢复数据一致性,确保财务报表的准确性。
Operating Systems Design and Implementation
最近一直在持AST的这本书,果然是名著啊,写得相当牛X了。不光是原理讲得透彻,而且给我影响最深的就是很多有趣的例子。像The Dining Philosophers Problem.有时候看着看着都觉得好笑,哈哈。continue........... 转载于:https://www.cnblogs.com/linuxkernel/archive/2009/07/30/1854973.html...
Windows下高效部署llama.cpp:从环境配置到模型量化的完整指南
本文提供了一份详尽的Windows系统下部署llama.cpp的完整指南。内容涵盖从Python环境配置、使用CMake与MinGW编译工具链的搭建,到编译llama.cpp项目、获取并转换模型为GGUF格式,以及执行模型量化和基础推理测试的全过程。指南旨在帮助开发者在普通Windows电脑上,无需高端显卡,仅凭CPU即可高效运行大语言模型,并重点解决了部署过程中常见的环境与编译错误。
Operating Systems Principles and Practice 2——The Kernel Abstraction
进程的抽象:什么是进程?它和程序之间有什么区别? 程序可以被编译器转化为可执行的映像(就是一个文件,里面有机器指令以及执行这些指令所需要的数据),而操作系统会将可执行映像拷贝到物理内存。操作系统首先开辟一个栈来承载本地变量的相关状态,同时也会开辟一块空间叫做堆来动态的为数据结构和程序开辟空间。一旦一个程序被载入内存,操作系统可以通过设置该程序的栈顶指针并跳转到该程序的第一条指令来执行它。为了运行多个相同指令的拷贝,操作系统可以拷贝多份这样的指令 +栈+堆+静态数据的组合。因此,一个进程是一个程序的实例,就好
《UDS协议从入门到精通》系列——图解0x27:安全访问
什么是安全访问服务?应用场景和基本原理是什么?全网最直观详细的图解UDS-0x27:安全访问服务!!
华为OD机试 - 商品推荐多属性排序 - 数组(Python/JS/C/C++ 双机位A卷 100分)
本专栏收录于《华为OD机试真题(Python/JS/C/C++)》。刷的越多,抽中的概率越大,私信哪吒,备注华为OD,加入华为OD刷题交流群,每一题都有详细的答题思路、详细的代码注释、3个测试用例、为什么这道题采用XX算法、XX算法的适用场景,发现新题目,随时更新。双十一来临,小王准备买某个购物平台买坚果。在输入坚果时,页面默认按照综合推荐列表。小王想知道这个综合排序时如何完成的,于是便开始思考算法题。经过一番操作后,完成它的多个关键词排序算法。希望你给小王提供一份正确的排序结果,验证其实现算法结果的准确性
Operating Systems Basic Concepts and Principles
4 在请求分页系统的硬件支持中,当所要访问的页面不在内存时,由缺页中断机构实现。3 在死锁的条件中,不剥夺条件是指进程已获得的资源只能在使用完时由自己释放。5 按设备的固有属性分类中,独占设备属于临界资源,即进程临界区访问的资源。3 在死锁的条件中,互斥条件是指在一段时间内,某资源只能被一个进程占用。3 现代操作系统产生死锁的条件中,互斥条件是不能被摒弃来预防死锁的发生。3 资源的按序分配法是摒弃死锁条件中的环路等待条件来预防死锁的发生。5 在假脱机打印机系统中,按设备的固有属性分类,实现了虚拟设备功能。
【RT-DETR改进涨点】ResNet18、34、50、101等多个版本移植到ultralytics仓库(RT-DETR官方一比一移植)
本文是本专栏的第一篇改进,我将RT-DETR官方版本中的ResNet18、ResNet34、ResNet50、ResNet101移植到ultralytics仓库,网上很多改进机制是将基础版本的也就是2015年发布的ResNet移植到ultralytics仓库中,但是其实RT-DETR实验的ResNet和其是有很大区别的在其中有很多细节上的不同(文章中我也会列出举例)
Operating Systems : Design and implementation 读书笔记
Thus the MINIX 3 source code to support partitions on IBM computers is put in drvlib.c, rather than being included in driver.c, for two reasons. First, not all disk types support partitions. As not
Data-Structures-and-Algorithm-Analysis-in-Java.pdf
作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...
VB摄像头监控
该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制
Operating Systems Principles and Practice 2——The Programming Interface
Process management 我们当然可以在内核中为用户实现一切,但是在今天,程序可以创建并管理诸如界面管理,web服务器,shell命令行等进程,这些程序的源码可以直接控制一些系统,数据库,编译器。 一个早期的动机去管理用户进程是去允许开发者在shell上写自己的命令。 shell是个任务控制系统 ...
Probability and Statistics - 4th edition
Probability and Statistics - 4th edition
Understanding Operating Systems and the Basics of Processes
Understanding Operating Systems and the Basics of Processes1. What is an Operating System?The Role of an OSWhy It Matters2. Core Functions of an Operating SystemProcess ManagementMemory ManagementFile System ManagementDevice ManagementSecurity and Protec
温度PID控制PLC程序
温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值
Operating Systems and Systems Programming Semester 1 2024 Exercise 1Haskell
ACDRule:Query:-i./test .sh。
UMDF Versions and Operating Systems
https://msdn.microsoft.com/en-us/library/windows/hardware/ff561356(v=vs.85).aspx UMDF version Release method Included in this version of Windows Drivers using it can run on †
Can We Make Operating Systems Reliable and Secure?
Andrew S. Tanenbaum, Jorrit N. Herder, and Herbert Bos Vrije Universiteit, Amsterdam
Operating Systems Design and Implementation (3rd Edition)
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.youkuaiyun.com/topmvp - topmvpMost books on operating systems deal with theory while ignoring practice. While the usual principles are cove
159.342 - Operating Systems and Networks
OBJECTIVE:endl;for(i=0;i++) {FREE(n[k]);#endifif(n[k]!= NULL){#endifs[k]=size;} else {#endifExample:completed.
Configure Time Synchronization Between Guest and Host Operating Systems
Configure Time Synchronization Between Guest and Host Operating Systems When you turn on periodic time synchronization, VMware Tools sets the time of the guest operating system to be the same
对Can We MakeOperating SystemsReliable and Secure 的翻译
摘要:微内核—相对于大内核(monolithic kernels)来说,由于它的 lower performance,长期以来被认为是不可接受的。而现在,由于它潜 在的高可靠性(higher reliability),而这一点被现在的许多研究人员认为 是比性能(performance)更加的重要,因此在操作系统的研究中获得了新 生
12th USENIX Symposium on Operating Systems Design and Implementation
https://www.usenix.org/conference/osdi16/program
Creating INF Files for Multiple Platforms and Operating Systems
转自:http://msdn.microsoft.com/en-us/library/ff540206(v=VS.85).aspx 0 out of 1 rated this helpful - Rate this topic By using system-defined platform extensions to INF file sections and direc
Sharing Files Between Guest and Host Operating Systems
To share files between a host computer and a virtual machine or between two virtual machines, you use the networking features of VMware Work
3428



被折叠的 条评论
为什么被折叠?



