Appendix B Development Tools
Total Page:16
File Type:pdf, Size:1020Kb
Appendix B Development Tools Problem Statement Although more proprietary packages are available, there are abundant open source packages, giving its users unprecedented flexibility and freedom of choice, that most users can find an application that exactly meets their needs. However, it is also this pool of choices that drive individuals to share a wide range of preferences and biases. As a result, Linux/Open source packages (and softeware in general) is flooded with religious wars over programming languages, editors, licences, etc. Some are worthwhile debates, others are meaningless flamewars. Throughout Appendix B and next chapter, Appendix C, we intend to summarize a few essential tools (from our point of view) that may help readers to know the aspects and how-to of (1) development tools including programming, debugging, and maintaining, and (2) network experiment tools including name-addressing, perimeter probing, traffic-monitoring, benchmarking, simulating/emulating, and finally hacking. Section B.1 guides readers to begin the developing journey with programming tools. A good first step would be writing the first piece of codes using a Visual Improved (vim) text editor. Then compiling it to binary executables with GNU C compiler (gcc), and furthermore offloading some repetitive compiling steps to the make utility. The old 80/20 rule still works on programming where 80% of your codes come from 20% of your efforts leaving 80% of your efforts go buggy about your program. Therefore you would need some debugging tools as dicussed in Section 1.2. including source-level debugging, GNU Debugger (gdb), or a GUI fasion approach, Data Display Debugger (ddd), and debug the kernel itself using remote Kernel GNU Debugger (kgdb). As source of contribution is becoming more scattered and dependency of software is more sophisticated nowadays, Section B.3 illustrates how codevelopers should agree on a version control system, Concurrent Version System (cvs), to achieve ease of collaboration avoiding development chaos and how Red-hat Package Manager (rpm) gives end-users ease of installation by hiding software transparency. Since the world is tightly networked, users may equip themselves with tools introduced in Appendix C to enforce more interactions with others. Section C.1 discusses how name-addressing helps in knowing Internet’s who-is-who using host to query DNS, and acquire local (e.g. LAN) who-is-who with the Address Resolution Protocol (arp) utility. Certainly, there are times network doesn’t work as 1 expected. One should employ perimeter-checking as dicussed in Section C.2 either ping for the availability or trace the route (traceroute) for any bottleneck. Once troubleshooting is done, packets would begin to flow and traffic are generated. Section C.3 teaches readers to manipulate traffic monitoring. Packets can be dumped for examing its header/payload in great details with tcpdump, as well as some useful network statistics and information can be collected using netstat. As the performance issue is getting more important, a connected network is only considered workable when no benchmarks have been measure. Hence, Section C.4 introduces two benchmarking tools, one for host-to-host throughput analysis such as Test TCP (ttcp), while one for Web server performance analysis, e.g. WebStone. Furthermore, it is not always practical to wire a complete real network especially for research purpose. In this case, either simulation such as Network Simulator (ns) or emulation of the network such as NIST Net, which are discussed in Section C.5, should be taken. Finally, a few hacking methodology including eploits-scanning with nessus, sniffing with ettercap, and Distributed Denial-of-Services (DdoS) with TFN-style attacks are investigated at the end of this chapter, which might be a controversial issue yet it is placed here as a complement to Chapter 7. B.1 Programming With the advent of computers, writing a program (or programming), which instructs the computer to do certain task, has became an art. Quite a few people not only gets their works done but also programs them in a graceful way as well as an individual style. Nevertheless, the essence of programming languages shall not be discussed here, instead you should approach a programming language text for details. B.1.1 Text Editor – vim Irrespective of your choice of programming language, you will need an editor, which is a program that can be used to create and modify text files. It plays an essential role in a programmer’s life since a clumsy text editor would waste your time simply to handle it while a handy one would offload these efforts and let you spend more time on thinking and innovating. What is vim Out of numerous text editor, i.e. pico, joe, and emacs, Visual Improved (vim) is perhaps (personal bias) the prevailing text editor nowadays. It takes a leverage 2 between ease of use and powerfulness making it more handy than emacs yet way feature-riched than pico. Vim has extensible syntax dictionary, which highlights the syntax with different colors for documents it recognized, including c codes and html files. Advance users would use vim to compile their codes, to write macros, to use it as a file brwoser, and even to write a game, e.g. the TicTacToe. With its popularity, a ported windows version of vim, known as gvim for windoze, is now available. How to vim Before getting started with vim, one should be awared that vim operates in two phases (or modes) instead of one phase like pico or any other ordinary text editor. Try this, you start vim (type vim for editing a new file or vim filename to open an existing file) and edit for a minute. If you didn’t luck out to type any special character, you would find nothing on the screen. Then you try to move around by pressing the arrow keys and you find the cursor stays unmoved. Things get even worse that you couldn’t find a way out (the solution would be provided later, so just read on) . These initial barriers do frustrate quite a few of the newbies. However, the world would begin to shine as you get to know when to insert a text and when to issue a command. In Normal mode (command mode), characters are treated as commands, meaing they would trigger special actions, e.g. pressing h,j,k, and l would move the cursor to the left, up, down, and right, respectively. However, characters would be simply inserted as text in Insert mode. Obviously, editing would become chaotic when you had a mode confusion, where you should always press <ESC> to escape from such chaos and get back to normal mode. Most commands and keys can be concatenated in a more sophisticated operation, [#1] commands/keys [#2] target , where anything enclosed within brackets is optional; #1 is an optional number, i.e. 3, specifiying commands/keys are to be done 3 times; commands/keys are any valid vim operation, i.e. y for yanks(copies) the text; #2 is an optional number, similar to #1, specifying the number (or range) of targets being affected by the commands/keys; and target is the text that you ant to apply the commands/keys on, i.e. G for end of file. Although most of the commands are played (simply press it) on the main screen, some colon commands (commands that start with a colon) are keyed at the very bottom of the screen. When dealing with these colon commands, you would need to type a colon, which moves the cursor to the last line of the screen, then issue your command string and terminate it by pressing the <Enter> key, e.g. :wq would save your current file and quit. The overall 3 operating modes of the vim text editor are clearly illustrated in Figure B.1 while leaving a more in-depth motion, yanking and deleting commands in Table B.1. Figure B.1 Operating modes of the vim text editor Command mode Effects h , j , k , l left, down, up, right w , W forward next word, blank delimited word e , E forward end of word, of blank delimited word b , B backward beginning of word, of blank delimited word ( , ) sentence back, forward Motion { , } paragraph back, forward 0 , $ beginning, end of line 1G , G beginning, end of file nG or :n line n fc , Fc forward, back to char c H , M , L top, middle, bottom of screen yy Copy current line Yanking :y Copy current line Y Copy until end of line dd Delete current line Deleting :d Delete current line D Delete until end of line Table B.1 Important keys for cursor movement and text editing 4 B.1.2 Compiler – gcc With a text editor at hand, one could begin to write a program. However, this program is likely to be written in high-level language which is not machine understandable, and hence far from machine executable. Therefore, you need a software called a compiler, which converts a program (source code) written in a high-level language (C/C++, etc.) to binary machine code (object code). Notably, the translation from source code to object code only needs to be performed once and it is then stored and used repeatedly at this almost-machine level. Since it is common to incorporate old routines already compiled, a second-stage process using an utility called a linker is often used to process the compiled code to create the final executable application. This multiple-stage processes of a gcc compiler is shown in Figure B.2. What is gcc The GNU C compiler (gcc), which by default expects ANSI C 1 , is a well-known C compiler on most Unix systems.