当前位置: 首页 > news >正文

C CS3214

Understanding Processes and Pipes
In this exercise we consider a program ‘dpipe,’ which, in connection with a ‘netcat’ utility program, can be used to turn any ordinary program into a network server. A ‘netcat’ utility program is a program that extends the standard Unix ‘cat‘ utility over a network.
iuww520iuww520iuww520iuww520iuww520iuww520iuww520iuww520
The learning goals of this exercise are:
• Understand how to write C code that makes system calls.
• Understand how to start and wait for processes in Unix with the fork() and waitpid() system calls.
• Understand how to create pipes as an example of an IPC (interprocess communication) facility.
• Understand how to manipulate a process’s standard input and standard output file streams using standard Unix system call facilities (e.g. dup2() ) that affect low-level file descriptors. A very similar file descriptor manipulation is performed by a shell when it sets up I/O redirection or pipes.
• Understand how to use the strace facility to trace a process’s system calls.
• Understand how to use the /proc file system to obtain information about processes in a system.
• Gain a deeper understanding of process states using a practical example application that combines process management, IPC, and network I/O.
In this exercise, you are asked to observe, reverse-engineer, and then reimplement the dpipe program. The dpipe binary is provided in ~cs3214/bin/dpipe.variants/ dpipe-ABC on our machines, where ABC is the unique id created for you. For netcat, use the ~cs3214/bin/gnetcat6 binary.
To allow you to invoke those commands directly, make sure that ~cs3214/bin and (optionally) ~cs3214/bin/dpipe.variants are included in your PATH environment variable.1 You should already have your PATH set up from exercise 0 to include the firstdirectory. If you haven’t, do this now.
Here’s an example session of how to use it. Say you’re logged in to the machine ‘locust’ and run the command dpipe-ABC wc gnetcat6 -l 15999 2 . This will produce output as follows:
[cs3214@locust sys1]$ ~cs3214/bin/dpipe.variants/dpipe-ABC wc gnetcat6 -l 15999
Starting: wc
Starting: gnetcat6
Running in server mode
Note that the shell is still waiting for dpipe to complete at this point. The questions listed in part 1 must be answered at this point, after you have started dpipe, but before the next step. You may wish to continue reading and then return to this point, after opening a second terminal on the same machine.3
The next command can be run on any rlogin machine, but you must replace locust with the name of the machine on which started the earlier command:
[cs3214@chinkapin ~]$ gnetcat6 locust-rlogin.cs.vt.edu 15999 < /etc/passwd
Running in client mode 47 119 2690
[cs3214@chinkapin ~]$
The gnetcat6 instance started here connected to the gnetcat6 instance running on locust 4 , and sent its input there (in this case, the content of file /etc/passwd ). Gnetcat (running on locust) outputs this data to its standard output stream, which is connected via a pipe to the standard input stream of the ‘wc’ program. The standard output stream of ‘wc’ is connected to the standard input stream of locust’s gnetcat6 instance. Anything out
put by ‘wc’ will then be forwarded to chinkapin’s gnetcat6 instance, which outputs it to its standard output, thus appearing on the user’s terminal on chinkapin. You have just turned the ordinary ‘wc’ program into a networkservice! The entire scenario is shown in Figure 1.

http://www.mrgr.cn/news/29422.html

相关文章:

  • 产品经理有必要学习大模型技术吗?
  • 数据治理新时代:掌握关键的数据提取技术
  • ai头像免费软件有哪些?卡哇伊头像用这些
  • 【Springboot】——响应与分层解耦架构
  • 如何利用AI进行有效的科技产品发布
  • idea 中MyBatisX插件没有出现蓝色鸟
  • 突破空间限制:4个远程控制电脑的办法
  • 十大最佳电子商务市场广告工具,助力提升你的业务
  • go-orm接口原生到框架
  • 印度2024年节日季节的数字营销趋势
  • 国产开源大语言模型优劣大盘点
  • GaussDB关键技术原理:高弹性(五)
  • 碳化硅肖特基二极管B3D50120H2高速开关与低损耗的完美结合
  • 金言问卷:国外问卷调查可以做吗?
  • 教程 | ArcGIS Pro如何自动保存数据编辑内容
  • 我的AI工具箱Tauri版-VideoClipMixingCut视频批量混剪
  • 镍镉离子电池
  • 运动耳机什么牌子质量好?五大超赞顶流机型汇总
  • 超详细!CEC2017测试函数最全公式图像介绍与调用方法 Matlab代码免费获取
  • 【LeetCode】每日一题 2024_9_18 坐上公交的最晚时间(排序,模拟)