Lecture # 25 - Systems and Network Programming

House keeping items:

Lecture 25 (4/15): Section 2 (2:15pm) - video

Lecture 25 (4/15): Section 1 (5:15pm) - video

Lecture 24 (4/13): Section 1 (5:15pm) - video

*** Notices ***

Agenda for Today (04/15/20):

Dr. James Fawcett is a Teaching Professor Emeritus here at Syracuse. He taught graduate software design courses from 1990 to Spring 2019.

Most of my software training was here at Syracuse under Dr. Fawcett.

Today Dr. Fawcett will discuss and demonstrate aspects of the Rust programming language. Rust is a newer systems programming language focused on performance and safety (memory and thread/concurrency). Rust is similar to C++ in some ways and different in other ways. Rust compiles into native code which makes it as fast as C++, and it provides memory safety without using garbage collection.

Rust Programming Resources:

  1. A Tour Of Rust
  2. Rust Models
  3. Rust Models (demo code)
  4. Rust Videos
  5. Note: Dr. Fawcett often schedules summer project meetings in which he reserves a room on campus, we gather as a group and he leads a discussion of specific software topics. In the past we have discussed a variety of topics: C++, design methodologies, web controls, and most recently the Rust programming language. This summer Dr. Fawcett intends to continue meetings on Rust programming, and related software topics of interest. All are welcome to attend! If for some reason campus remains closed, he will likely conduct the meetings using video conferencing tools such as Zoom. You can register to be notified for Dr. Fawcett's summer meetings by joining his Summer Projects group at his Piazza.com site and join Class 1: 001: JimFawcett

    You can also view Dr. Fawcett's github site here for more information
  6. Dr. Fawcett's Message Passing Blog (relevant to current class topics)


Project 2 helpers - Please See Project 2 Statement for instructions: Project 2 statement

***Note:*** I’ve given lots of help.
All that you need to do to complete Project 2 is to supply remaining the code required in Messenger.cpp Specifically, you need complete functions:
MessageHandler::AppProc() and
bool SendMessage(const Message &message, const EndPoint &dstPeerEP)

Download Project 2 helper code here

For insight view the test stubs (bottom) of files: Sender.cpp and Receiver.cpp to see how you might implement these functions.
You are not required to use my helper code! You can build all of your own code, but you do need to meet all of requirements specified in the Project statement (see MPL (Sender/Recveiver/ClientHandler) code below).


File Server code example based on message passing
Demonstrates to how use message passing to support file transfer: sender/receive files a block at time (similar in ways to HW#8 - copyfileBlock) -- Half duplex MPL

  1. cse384_file_server_executive.cpp -- concurrent file server
  2. cse384_client_executive.cpp -- file server client app
  3. README.txt -- getting started (compiling and running) file server example
  4. Download File Server example code here

Message Passing Library (libmpl.a) - Half duplex

  1. Sender Package - client-side message passing
  2. Receiver Package - server-side message passing: listening server and ClientHandler service host
  3. ClientHandler Package - server-side message passing class for defining custom server processing. Register with Receiver

This is a verson of the MPL that supports full duplex (bidirectional TCP socket comm ) between Senders and Receivers. It makes development easier since both the client and server can each send/receive messages. A network (file) copy program: ( i.e. another version a file transfer service and a client have been developed as an example) atop the full duplex version of the MPL. The network file copy service is similar in concept to HW#8 (copyfileBlock), except it sends/receives files across the network one block at a time (as messages)

  1. Full Duplex (Synchronous) network file copy server
  2. network file copy client
  3. README.txt -- getting started (compiling and running)
  4. Download the example code
  5. Full Duplex Message Passing Library -- (version 2, libmpl.a)

    1. Sender Package - client-side message passing
    2. Receiver Package - server-side message passing: listening server and ClientHandler service host
    3. ClientHandler Package - server-side message passing class for defining custom server processing. Register with Receiver

Sockets notes:

C/C++ examples: System calls, serialization, files and I/O

    1. USNA (Systems Programming) lectures
    1. User/Kernel space, System call Overview
    2. File I/O: read, write, open system calls
    3. Process creation and termination: I/O buffering
    4. Fork, Exec system calls, Process management
    5. Process Scheduling
    2. Previous (Lecture 15) Notes and C/C++ Presentation Materials
    1. C/C++ Introduction: Mike C. notes
    2. C++ Survival Guide (basic syntax notes and important concepts): Dr. Fawcett
    3. C and C++ compilation, memory, and computation models
    4. Assessment of the C++
    5. Discussion on the elements that comprise C and C++
    6. Discussion on Packages and Modularity
    7. Important linux/system header files
    8. The structure and data flow in sytems is often documented with standard UML diagramming: You should be aware of it
    3. Code Examples from 03/02 and 03/04
    1. Demo stdout/stderr file streams, write system call
    2. Demo Pass by value, Pass by reference, basic pointers and memory allocation (new/delete, malloc/free)
    3. Demo C-style strings
    4. Demo C++ std::strings
    5. Demo File I/O in C (fopen/fgetc/fprintf,read lines, memory allocation with malloc etc.) Reading/Writing Text Files: C example
    6. Demo File I/O in C++ (ifsteam/ofstream streams: Reading/Writing Text Files: C++ example
    7. Demo structs, serialization, reading/writing binary files: C++ example
    8. Demo reading/writing binary files in C (glibc: fopen/fread/fwrite/fseek etc) C example
    9. Demo reading/writing binary files in C++ (fstream library: command line args, ifstream/oftstream etc.) C example
    4. Type Serialization/Deserialization example 5. C Package example for HW # 7 6. Example of a real C++ package - supports linux file and directory operations (prior to C++ 17 file system) 7. Lecture 14 Examples: Download
  • Note: You will need C and C++ compilers
    • I will use GNU C/C++ (gcc/g++). The Linux Minit distro comes with gcc installed by default, but not g++
    • Install g++ with the following command (Open terminal and type): sudo apt-get install g++
    • You can install and use gcc/g++ on your Mac computer. Use this is option if you don't have a Linux distro
  • Code (C and C++ tutorial) Resources:

    1. Really Nice C tutorial
    2. Excellent C Programming Tutorial: Tutorialpoint
    3. Another Excellent C Programming Tutorial(divided in basic and advanced topics): Learn-C.org
    4. One of the best C++ tutorials I've seen: cpluspluss.com
    5. Dr. Fawcett's Page on Getting Started with C++
    6. A very good C++ tutorial: LearnCpp.com
    7. Program memory layout
    8. Pointers Tutorial
    9. Stat system call
    10. Stat man page
    11. Compiling Programs using make (chapter 23): linux command line
    12. Lectures from a well thought out systems programming course at USNA
    13. Compilation, Linking and Loading article
    14. A series of Systems Programming lectures from U.S. Naval Academy (USNA)

    Dr. Fawcett's developed resources:

    Dr. Fawcett taught graduate software design courses here at Syracuse from 1990 - Spring 2019. Most of my software training was here at SU in Dr. Fawcett's courses from 2005-2019. In retirement he is continuing to develop (current) software training materials, most of which is hosted in his new github website available via the URLs below.

    1. The C++ story provides detailed coverage of the C++ language: specifically how to utilize the language and its features effectively. The intent of the story is to meet people on individual level of experience. Beginning C++ programmers can begin to get handle on using the language, while experienced programmers can get detailed insight into the more advanced aspects.
      View the C++ story here

    2. A series of the C++ videos corresponding to the C++ story
      can be viewed here

    3. Previously taught (Spring 2019) graduate Object-oriented Design course using C++

    Environment Setup Notes:

    1. Install VirtualBox
    2. Install Linux Mint (based on Ubuntu -- I prefer MATE desktop, but many people like Cinnamon)
      • Desktop Comparisons: MATE versus Cinnamon
      • Install Guest Additions - device drivers and system applications that optimize the guest operating system for better performance and usability.
    3. Enable "Shared Clipboard and Drag'nDrop": Settings -> Advanced
    4. Configure shared folders, then run the following commands..
      1. run: sudo usermod -a -G vboxsf `whoami`
      2. run: sudo chown -R `whoami`:users name-of-mount-point
      3. log out, and log back in
    5. Update Mint (run): "sudo apt update && sudo apt upgrade -y"

    Interesting Technologies related to Linux:

    1. Kernel-based Virtual Machine (KVM) - turn Linux into a Hypervisor
    2. Docker (Container Technology)
    3. TCPDump & LIBPCAP
    4. Extended Berkeley Packet Filter (eBPF)