Using tcpdump. tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates.

Slides:



Advertisements
Similar presentations
June 1, 1999Foreground/Background Processing1 Introduction to UNIX H. Foreground/Background Processing.
Advertisements

CSCI 330 T HE UNIX S YSTEM Shell Job Control. T ODAY ’ S CLASS Unix is multi-user, multi-process OS Shell features to control jobs Unix utilities to manage.
Lesson 10-Controlling User Processes. Overview Managing and processing processes. Managing jobs. Exiting/quitting when jobs have been stopped.
CS 497C – Introduction to UNIX Lecture 26: - The Process Chin-Chih Chang
Processes CSCI 444/544 Operating Systems Fall 2008.
Linux+ Guide to Linux Certification, Second Edition
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Process Process: the UNIX abstraction of a stand-along computer that manages resources (memory, CPU, I/O resources) comprising a running program. Processes.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
University of Pennsylvania 9/12/00CSE 3801 Multiprogramming CSE 380 Lecture Note 3.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Phones OFF Please Processes Parminder Singh Kang Home:
5 UNIX Processes. Introduction  Processes  How to list them  How to terminate them  Process priorities  Scheduling jobs  Signals.
UNIX Processes. The UNIX Process A process is an instance of a program in execution. Created by another parent process as its child. One process can be.
UNIX System Administration Handbook Chapter 4. Controlling Processes 3 rd Edition Evi Nemeth et al. Li Song CMSC691X Summer 2002.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Linux in More Detail Shirley Moore CPS5401 August 29,
Introduction to Processes CS Intoduction to Operating Systems.
The process concept (section 3.1, 3.3 and demos)  Process: An entity capable of requesting and using computer resources (memory, CPU cycles, files, etc).
Linux+ Guide to Linux Certification, Third Edition
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Linux+ Guide to Linux Certification, Second Edition Chapter 10 Managing Linux Processes.
RH030 Linux Computing Essentials
The kernel considers each program running on your system to be a process A process lives as it executes, with a lifetime that may be short or long A process.
Agenda  Working with Processes: Purpose Running Programs within same process (execl, execlp, execle, execv, execvp, execve) “Spawning” other process (fork,
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Linux+ Guide to Linux Certification Chapter Eleven Managing Linux Processes.
Processes Dr. Yingwu Zhu. Process Concept Process – a program in execution – What is not a process? -- program on a disk - a process is an active object,
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
1 Lecture 6 Introduction to Process Management COP 3353 Introduction to UNIX.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 9 Working.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
CSC414 “Introduction to UNIX/ Linux” Lecture 3
Agenda Managing Processes (Jobs) Command Grouping Running jobs in background (bg) Bringing jobs to foreground (fg), Background job status (jobs) Suspending.
Agenda The Bourne Shell – Part I Redirection ( >, >>,
Process Manipulation. Process Manipulation in UNIX Basic process manipulation: creation, program loading, exiting, … fork(), exec(), wait(), exit() Process.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Multiprogramming. Readings r Chapter 2.1 of the textbook.
Introduction to Kernel
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Avani R.Vasant V.V.P. Engineering College
Chapter 3: Processes.
Processes A process is a running program.
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
System Structure and Process Model
System Structure and Process Model
System Structure B. Ramamurthy.
Processes in Unix, Linux, and Windows
CHAPTER 8 ( , ) John Carelli, Instructor Kutztown University
Process & its States Lecture 5.
Operating System Concepts
CSC 140: Introduction to IT
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix and Windows
Processes – Part I.
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
EECE.4810/EECE.5730 Operating Systems
Lecture 6 Introduction to Process Management
Presentation transcript:

Using tcpdump

tcpdump is a powerful tool that allows us to sniff network packets and make some statistical analysis out of those dumps. tcpdump operates by putting the network card into promiscuous mode in order to capture all the packets Using tcpdump we have a view on any TCP/UDP connection establishment and termination

Using tcpdump Flags can be any of the list S -> SYN (Synchronize sequence numbers Connection establishment) F -> FIN (Ending of sending by sender - Connection termination) R -> RST (Reset connection) P -> PSH (Push data) (No flag is set) ACK -> Acknowledgement URG -> Urgent

Using tcpdump The three way handshake The client sends a SYN segment with the port number of the server it wants to connect to and the client's initial sequence number (Line 1). The server responds with its own SYN segment containing its initial sequence number (Line 2). This segment also contains an ack flag. So this segment acknowledges the client SYN (segment ). The client acknowledges this SYN from the server by sending another segment containing the "." flag and ack (Line 3).

Using tcpdump Some examples: tcpdump -n tcpdump -n host tcpdump -n host port 80 tcpdump -n host port 80 or 443 tcpdump -n host and not port 22 Other switches -i specify the network interface -f send results to -ccapture until specified number of packets are captured

Using tcpdump Now some Demos….

Unix Processes and CRON

What is a Process? A process is an instance of a running program. A process consists of A process ID An owner who created the process A program counter that keeps track of where you are A copy of the stack and registers used by the process An address space (Chunk of Memory) that contains  Text Segment - executable instruction  Data segment - all the data used by the program  User segment - process ID information

Unix is a Multitasking OS In multitasking the OS loads several processes into memory and switches rapidly amongst them. This keeps the processor busy. The processor switches processes when: A program terminates A program has to wait for IO A program has used up its time allotment The challenge of multitasking is scheduling which process should run at any given moment. The kernel is responsible for managing all of the processes.

The Life of a Process 1. The user enters a command at the shell 2. The shell examines the command, finds the program file, and invokes the loader. 3. The loader examines the file and loads the instructions and data into main memory. 4. A process control block (PCB) is created and placed into a ready queue. 5. The CPU scheduler chooses processes from the ready queue and executes them. 6. The process get selected and is loader by the dispatcher. 7. The process runs until it has to wait. After waiting it goes back in the ready queue. 8. Repeat 5-7 until the process terminates.

Parent and Child Processes Every process, save one, has a parent process that created it. Thus, every process is a child of another one. Processes cannot be orphaned, at the very least they belong to the first process, the root process, created when the system booted. All processes have an ancestory, a hierarchy of process between it an the root process. vicat shell1 pine Shell2 root process

Process Creation Functions fork() - processes are created by the fork system call. This call creates a new process that is identical to its parent but has its own ID. exec() - loads a copy of the program to be executed over the address space it currently has. This overwrites the text and data areas of the process with the new code and data. wait() - waits for a child process to end

The Init Process The init process is the ultimate parent of most processes on the computer. It is the second process created by the computer and has a pid of 1. Remember, numbering starts at 0. The following process shows how a shell is run. 1. When the computer boots up it switches into multiuser mode. 2. Upon switching, init forks and executes getty for every terminal port 3. Getty prints a login prompt at each port and then sleeps 4. When user tries to log in getty executes login (overlays itself) 5. Login verifies user info and executes the shell (overlays itself) 6. Init is left as the only parent of the shell 7. When the shell dies, init forks and executes getty again. Thus, the process repeats for a new user.

The Shell Process The shell is a child process of init and is the first process available to the user. The shell runs other processes that are its children. These processes may include another shell or a program. When the primary shell dies, the user is logged out. The shell keeps the same PID for the entire time you are logged in. If you kill this PID, you kill your login session.

Shell Commands for Manipulating Processes The shell provides several commands that allow it to manipulate its child processes. Child processes may execute in the foreground or the background. When run in the foreground, the shell waits for the program and displays its output. When run in the background, the process runs and the shell keeps running and can continue to process commands. The following keys manipulate processes: cntrl-z suspends the foreground processes cntrl-c kill the foreground process

Shell Commands for Manipulating Processes Cont. In addition to keys, the bash shell includes the following commands: bg puts a process (pid) in the background fg puts a process (pid) in the foreground jobs lists active jobs for the shell kill kill a process (pid) stop suspend a background process (pid) wait wait for background processes to finish If a pid is not given for bg or fg, it assumes the process most recently suspended from the foreground. Placing a & after a shell command will run it in the background. Note, that you cannot logout until process ends.

The nohup Command The & option provided by the shell will not allow a background process to run if the shell is killed or the user logs out. Therefore, you cannot logout until all background processes have been dealt with. The nohup command gets around this issue by guaranteeing that the command that follows it will not cause these hangup. If the shell dies, the ppid of the process transfers to 1, the init process. Example nohup sort emp.lst & Standard output from this command may be redirected to nohup.out

Listing Process Status The ps [options] command is used to list the status of all processes. Common ps options a list all processes associated with the current terminal -u user list processes of a particular user (usr) -e list everything including system processes f get a full listing with parent’s ID listed (ppid) l give a long list with memory information Note that the ps options may differ by system. For example, Linuz uses “ax” instead of “e”.

Killing a Process The kill [options] pid command is used to terminate a process. A process can only be killed by its owner or by someone with administrative permissions. The kill command has the following options: l lists all of the signals kill can send 9 sends a special kill signal that cannot be caught

at - Controlling Job Execution The at [options] time command can be used to set a job to run at a later time. The at command takes commands from standard input. You enter the at command, hit enter, type the command to run, and then hit cntrl-D. Examples: at 15 runs the command at 3:00 PM at 5pm runs the command at 5:00 PM at noon runs command at noon At now + 1 year run command a year from now At day run command at 3:00PM tomorrow At 9am tomorrow run command at 9:00AM tomorrow

at and batch at continued The -l option will list all jobs placed in the at queue and their job number The -r # option will remove the job with the provided number from the queue Batch Command The batch command will run a series of commands when time is available on the system. It does not take a time argument. Typically you enter the commands into a file and redirect that file into standard input. For example, batch < cmnds.txt Batch places jobs into the at queue and they can be listed and removed using “at -l” and “at -r” Or use atq or atrm

Cron - Scheduling Periodic Jobs Cron is a complex program that allows you to schedule jobs/processes for periodic execution. For example, if you want to check the file system or run a virus checked each day. Cron requires you to create a file with the commands and times and notify the cron daemon using crontab -e. This creates a file with the user’s name in /var/spool/cron/crontabs