2017년 12월 6일 수요일

Updated on Dec 13. [Computer Networks , Probability, and Platform-based Programming] Topics covered by midterm exams

[Computer Networks]


[Updated on Dec. 13] Do not study the DNS, TCP cumulative ACK, TCP state machine.
 In the NAT, just study the concept of NAT (what information is required?). Do not study the details of NAT operation procedures

ARP, network Layer discussed in Internetworking, and TCP discussed in the class.
You do not have to study some topics, which will be discussed on Dec. 7. 

[Platform-based programming]
You should study all topics related to object (such as constructor overloading, inheritance and constructor call sequences, polymorphism, abstract, interface, and threads)

[Probability]
Chaps 3 (Conditional Probability) and 4 (Discrete Random Variables) are covered by the final exam
(Further study, odd-numbered problems among review questions in Chapters 3 and 4)

Keep up with your study~

Wish you best luck!!


[Platform-based Programming] Thread Cooperation Codes

Source code

2017년 11월 27일 월요일

2017년 11월 17일 금요일

[Platform] HW#7 (Due: Dec.1)

HW#7


Use HashTable class provided by Java

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313 by 7:00 pm (or much earlier is possible).


[Platform] HW#6 (Due: Nov. 24)

HW#6

Use list class provided by Java

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313 by 7:00 pm (or much earlier is possible).


2017년 11월 7일 화요일

[Probability: HW5] Due: Nov. 9 (New Due)

HW5

HW5 Solutions

[Notice]
- You do not have to solve problem 27 and 29-(b)

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).

[1] Type your homework using the MS-Word.
     Otherwise, you will get ZERO point when you submit your handwritten homework!!

[2] Don't copy solutions as itself posted in this page!! Do it for yourself with your idea and solutions posted as here!!



2017년 11월 1일 수요일

[Computer Networks] Homework 3 (Nov. 6) with tips

Homework 3

With out-of-order delivery allowed, packets up to 1 minute apart must be
distinguishable via sequence number.
Thus, the sequence number can be derived from the following metrics:
         Bandwidth, 1 minute, packet size
 
Please submit your HW to the report box in front of NC Lab, where located at office #319, 자연대연구실험동 (c-26) by 7:00 pm (or much earlier is possible).



2017년 10월 31일 화요일

[Platform-based Programming: HW5] Due: Nov. 8 (Modified on Oct. 30)

HW5


Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313 by 7:00 pm (or much earlier is possible).


Don't copy soruce codes available by Googling into your homework!!

You will get ZERO!!

Modularize your source codes; At least 4 functions are required including main()


2017년 10월 20일 금요일

[Computer Networks] Homework 4 (Due: Nov. 17)

HW4

Please submit your HW to the report box in front of NC Lab, where located at office #319, 자연대연구실험동 (c-26) by 7:00 pm (or much earlier is possible).

No more homew...... 🚫



[Java Lab Programming] Correct typos of programming practice on Oct. 19

private static boolean isPalindrome(String s, int low, int high) {

if (high <= low)
return true;
else if (s.charAt(low) != s.charAt(high))
return false;
else return isPalindrome(s, low + 1, high - 1);
}

2017년 10월 15일 일요일

[Platform-based Programming] Homework 4 (Due: Oct. 31)

HW4

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).


[Probability: Homework 4] Due: Oct. 23

HW4

HW4 Solutions

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).

[1] Type your homework using the MS-Word.
     Otherwise, you will get ZERO point when you submit your handwritten homework!!

[2] Don't copy solutions as itself posted in this page!! Do it for yourself with your idea and solutions posted as here!!



2017년 10월 9일 월요일

[Lecture Note #11: OOP] Java Thread States

Click

[Lecture Note #8: O-O Java] Network Programming Part 1 - Chat

Client

Server

Source


[Lecture Note #7: OOP] Chap 31 - Socket sample codes

Socket sample codes

[OOP - Lab #7-2] Recursion - Basics

Lab #7 - 2 Materials

[OOP - Lab #7] Basic Object Oriented Technique

Lab #7 - Materials

[OOP - Lab #5] Array

Lab #5 Materials

[Lecture Note #9: Computer Networks] How to measure network performance

Performance




[Lecture Note #8: Computer Networks] MPLS

MPLS


[Lecture Note #7: Computer Network] NAT and DNS

NAT

DNS



[Lecture Note #6: Computer Networks] TCP - UDP

TCP





[Lecture Note #5: Computer Networks] Internetworking

Internetworking - Part 1



[Lecture Note #4: Computer Networks] ARP

ARP protocol

Packet Delivery Procedure


2017년 9월 24일 일요일

[Java: Homework #3] Due: Oct. 11

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).

Don't copy soruce codes available by Googling into your homework!!

You will get ZERO!!


Modularize your source codes; At least 5 functions are required including main()

HW3



2017년 9월 22일 금요일

[Computer Networks] HW2 (Due Date: Oct. 11)

Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).

HW2



[Lecture Note #2: Networks] Foundation Part 2 & Protocol Architecture

Foundation Part 2

Protocol Architecture



[Probability Homework] A new version of homework 2 [Update: Sep. 19] (Due: Sep 26)

HW 2

Porker games

[Additional notes]1. You don't have to make a program.
   Just use spreadsheet tools, such as the Excel...
2. you do not have to generate all possible cases. 
   Just derive some equations and calculate them with the Excel

Type your homework using the MS-Word.
Otherwise, you will get ZERO point when you submit your handwritten homework!!






2017년 9월 15일 금요일

[Java: Homework #2] Due: Sep. 22

Homework 2

Please submit your HW to the report box, where located at office #318, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).


2017년 9월 8일 금요일

[Computer Networks] Homework#1 (Due: Sep. 20)

HW1

Type your homework using the MS-Word


Please submit your HW to the report box in front of NC Lab, where located at office #319, Building 313.
Due Date:by 7:00 pm (or much earlier is possible).


2017년 9월 6일 수요일

Recommended Book for network beginners















- English version
















- Korean version





Some students want me to recommend some books for computer networking.
The book entitled with "Computer networking: A Top-Down Approach" is one of popular text books for undergraduate students.

Luckily, we can find out tons of resources related to computer networks by googling.

Just googling

2017년 5월 30일 화요일

[Open S/W] Source codes we worked on May 30

Source codes

[store.c]===========================================================



#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "mylib.h"

struct address* store(i, top)
struct address* i;
struct address* top;
{

}

[mylib.h]===========================================================

#ifndef MYLIB_H_
#define MYLIB_H_

struct address {
    char name[40];
    char zip[10];
    struct address *next;
} list_entry;

extern struct address* start;
extern struct address* last;

int  menuSelect(void);
void enter(void);
struct address* store(struct address* i, struct address* top);

#endif

[main.c]===========================================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mylib.h"

int main(void)
{
    int choice;

    for(;;) {
       
        choice = menuSelect();
        
        switch(choice) {
            case 1:
                   enter();
                   break;
            case 2:
                   break;
            case 7:
                   exit(0);
                   break;
        }

    }
    return 0;
}

[enter.c]===========================================================

#include <stdio.h>
#include "mylib.h"

void enter(void)
{
    printf("\n enter() is called ....\n");
}

[menu.c]===========================================================

#include <stdio.h>
#include <stdlib.h>
#include "mylib.h"

int menuSelect(void)
{
    char select[80];
    int  num;

    do {
           printf("=================================\n");
           printf("Welcome to the PNU Mailing System\n");
           printf("1. Enter a name\n");
           printf("2. Delete a name\n");
           printf("7. Exit\n"); 
           printf("=================================\n");

           printf(">>> Enter your choice: ");
           fgets(select, 80, stdin);
           num = atoi(select);

    } while (num < 0 || num > 7);

    return num;
}

[Makefile]======================================================

all: mailing

mailing: main.c menu.o enter.o store.o
 gcc -o mailing main.c menu.o enter.o store.o

menu.o:
 gcc -c menu.c 

enter.o:
 gcc -c enter.c

store.o:
 gcc -c store.c

clean:
 rm -rf *.o



2017년 5월 25일 목요일

[Open S/W] Source codes (May 25)

[Makefile] ===========================================

all: main

main: main.c display.o search.o
    gcc -o addrman main.c display.o search.o

display.o:
    gcc -c display.c

search.o:
    gcc -c search.c

clear:
    rm -rf *.o

[mylib.h] ===========================================

#ifndef MYLIB_H_
#define MYLIB_H_

struct address {
    char name[40];
    char zip[40];
    struct address *next;
} list_entry;

extern struct address *start;
extern struct address *last;

void display (struct address *top);
struct address* search(struct address *top, char *);

#endif  // MYLIB_H_

[main.c] ===========================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "mylib.h"

struct address *start;
struct address *last;

int main()
{
    struct address *info;
    struct address *info2;

    // Initialize list point: empty state
    start = last = NULL;

    info = (struct address*)malloc(sizeof(list_entry));
    strcpy(info->name, "Tom");
    strcpy(info->zip, "613");
    info->next = NULL;

    start = info;

    info2 = (struct address*)malloc(sizeof(list_entry));
    info->next = info2;
    strcpy(info2->name, "Steve");
    strcpy(info2->zip, "513");
    info2->next = NULL;

    display(start);

    struct address* info3;

    info3  = search(start, "Steve");

    if (info3) {
        display(info3);
    }
    else {
        printf("Not Found!!\n");
    }
   
    free(info);
    free(info2);

    return 0;
}                                                   

[display.c] ===========================================

#include <stdio.h>
#include "mylib.h"

void display(struct address *top)
{
    while(top) {
       printf("Name: %s\n", top->name);
       printf("Zip: %s\n", top->zip);
       top = top->next;
    }
}

[search.c] ===========================================

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "mylib.h"

struct address* search(struct address *top, char *name)
{
    while(top) {
        // if successful
        if (!strcmp(name, top->name))
            return top;

        top = top->next;
    }
   
    return NULL;
}

2017년 5월 23일 화요일

[C++] MyString Copy Assignment (May 23)

#include <iostream>
#include <string>
#include <cstring>

using namespace std;

class MyString {

public:
    char* Buffer;
    //string Buffer;

public:
    /*
    // constructor
    MyString(string mystring) {
        cout << "Constructor: creating new MyString" << endl;
        Buffer = mystring;
        cout << "Buffer points to: 0x" << (void *)&Buffer[0] << endl;
    }
    */

    MyString(const char* mystring) {
        if (mystring != NULL) {
            Buffer = new char [strlen(mystring) + 1];
            strcpy(Buffer, mystring);

            // Display memory address pointed by local buffer
            cout << "Buffer points to: 0x" << hex;
            cout << (unsigned int*)Buffer << endl;
        }
        else
            Buffer = NULL;
    }

    // Copy Constructor
    MyString(const MyString& CopySource) {
        cout << "Copy Constructor" << endl;
        if (CopySource.Buffer != NULL) {
            Buffer = new char[strlen(CopySource.Buffer) + 1];
            strcpy(Buffer, CopySource.Buffer);

            cout << "CopySource Buffer points to: 0x" << hex;
            cout << (unsigned int*)CopySource.Buffer << endl;

            cout << "Buffer points to: 0x" << hex;
            cout << (unsigned int*)Buffer << endl;
        }
    }

    // Copy assignment operator
    MyString& operator= (const MyString& CopySource) {
        if ((this != &CopySource) && (CopySource.Buffer != NULL))
        {
            if (Buffer != NULL)
                delete[] Buffer;
            Buffer = new char [strlen(CopySource.Buffer) + 1];
            strcpy(Buffer, CopySource.Buffer);
        }
        return *this;
    }

    ~MyString() {

        cout << "Invoking destructor" << endl;

        if (Buffer != NULL)
            delete [] Buffer;
    }

    const char* GetString() {
        return Buffer;
    }

    int GetLength() {
        return strlen(Buffer);
    }

    operator const char*() {
        return Buffer;
    }
};

/*
void UseMyString(MyString Input)
{
    cout << "UseMyString Buffer points to : 0x" << (void *)&Input.Buffer[0] << endl;
    cout << "length: " << Input.Buffer.length();
    cout << "Buffer contains: " << Input.Buffer.c_str() << endl;

    return;
}
*/
int main()
{

    MyString SayHello("SayHello from the class");
    MyString String1("Hello");
    MyString String2("World");

    cout << String1 << String2 << endl;

    // UseMyString(SayHello);

    // cout << SayHello.GetString() << endl;

    return 0;
}

[C++] MyString Sample Codes (May 23)

#include <iostream>
#include <string>
#include <cstring>

using namespace std;

class MyString {

public:
    // char* Buffer;
    string Buffer;

public:
    // constructor
    MyString(string mystring) {
        cout << "Constructor: creating new MyString" << endl;
        Buffer = mystring;
        cout << "Buffer points to: 0x" << (void *)&Buffer[0] << endl;
    }


    /*
    MyString(const char* mystring) {
        if (mystring != NULL) {
            Buffer = new char [strlen(mystring) + 1];
            strcpy(Buffer, mystring);

            // Display memory address pointed by local buffer
            cout << "Buffer points to: 0x" << hex;
            cout << (unsigned int*)Buffer << endl;
        }
        else
            Buffer = NULL;
    }

    // Copy Constructor
    MyString(const MyString& CopySource) {
        cout << "Copy Constructor" << endl;
        if (CopySource.Buffer != NULL) {
            Buffer = new char[strlen(CopySource.Buffer) + 1];
            strcpy(Buffer, CopySource.Buffer);

            cout << "CopySource Buffer points to: 0x" << hex;
            cout << (unsigned int*)CopySource.Buffer << endl;

            cout << "Buffer points to: 0x" << hex;
            cout << (unsigned int*)Buffer << endl;
        }
    }
*/
    ~MyString() {

        cout << "Invoking destructor" << endl;

        /*
        if (Buffer != NULL)
            delete [] Buffer;
        */
    }
/*
    const char* GetString() {
        return Buffer;
    }

    int GetLength() {
        return strlen(Buffer);
    }
*/
};

void UseMyString(MyString Input)
{
    cout << "UseMyString Buffer points to : 0x" << (void *)&Input.Buffer[0] << endl;
    cout << "length: " << Input.Buffer.length();
    cout << "Buffer contains: " << Input.Buffer.c_str() << endl;

    return;
}

int main()
{

    MyString SayHello("SayHello from the class");

    UseMyString(SayHello);

    // cout << SayHello.GetString() << endl;

    return 0;
}

2017년 5월 18일 목요일

[C++] Source codes we worked on May 18

#include <iostream>
#include <string>
#include <sstream>   // string stream
#include <memory>   // Include memory to use std::unique_ptr

using namespace std;

template <typename T>
class smart_pointer {
private:
    T* m_pRawPointer;
public:
    // Construcotr
    smart_pointer(T* pData) : m_pRawPointer(pData) {};
    // Destructor
    ~smart_pointer() {
        cout << "Smart pointer destructor is invoked" << endl;
        delete m_pRawPointer;
    }
    // Operator *
    T& operator* () const {
        return *(m_pRawPointer);
    }
    // Operator ->
    T* operator-> () const {
        return m_pRawPointer;
    }
};

class Date {
private:
    int Day;
    int Month;
    int Year;

    string DateString; // class

public:
    Date (int D, int M, int Y)
        : Day(D), Month(M), Year(Y) {};

    Date operator - (int DaystoSub) {

        return Date(Day - DaystoSub, Month, Year);

    }

    // Implement Conversion operator const char *
    operator const char*() {
        ostringstream formattedDate;

        formattedDate << Day << "/" << Month << "/" << Year;

        DateString = formattedDate.str();
        return DateString.c_str();
    }

    void DisplayDate() {
        cout <<  Day << "/" << Month << "/" << Year;
    }
};

int main()
{
    Date today(18, 5, 2017);
    Date yesterday(today - 1);

   //  yesterday = today - 1;
    cout << yesterday << endl;

    /*
    cout << "Today is on: " << today << endl;
    // smart pointer
    // supports automatic deallocation() , which means delete (in C++)
    // Actually, delete implies free() in C language
    smart_pointer<int> pDynamicAllocInteger(new int);
    *pDynamicAllocInteger = 42;

    cout << *pDynamicAllocInteger << endl;

    // local variable => stack => automatically poped (removed) when main() returns
    // The destructor is invoked automatically
    // That's why it is called smart_pointer
    // How can we verify this?
    smart_pointer<Date> tomorrow(new Date(19, 5, 2017));
    tomorrow->DisplayDate();
    */
    return 0;
}

[Source codes] We worked on May 18

#include <stdio.h>

int main()
{
    /*
    char animal[2][10] = {
        {'c', 'a', 't', '\0'},
        {'d', 'o', 'g', '\0'}};
    */

    char animal[][10] = {
        "cat",
        "dog",
        "tiger"};
   
    char* ptr_array[2] = {
        "cat",
        "dog"
    };

    int i = 10;
    int count;
    char *msg = "Test";
  
    int *pi = &i;
    int **ppi = &pi;
    int ***pppi = &ppi;

    printf("i: %d, pi: %d, ppi: %d, pppi: %d\n", i, *pi, **ppi, ***pppi);

    int arr1[4] = {1, 2, 3, 4};
    int arr2[4] = {11, 12, 13,14};
    int arr3[4] = {21, 22, 23, 24};

    int *ptr_ary[3] = {arr1, arr2, arr3};

    printf("ptr_ary: %d\n", ptr_ary[2][2]);

    printf("Total Array Size: %ld\n", sizeof(animal));
    printf("Partial Array  Size(column): %ld\n", sizeof(animal[0]));

    count = sizeof(animal) / sizeof(animal[0]);
    for (i = 0; i < count; i++) {
        msg = animal[i];
        printf("animal: %s\n", msg);
    }

    for (i = 0; i < 2; i++) {
        printf("animal: %s\n", ptr_array[i]);
    }
    return 0;
}

2017년 5월 17일 수요일

[C++]Homework #7 (June 2)

HW#7

Please submit your HW to the report box in front of NC Lab, where located at office #318, 자연대연구실험동 (Building# 313). Due time: by 7:00 pm (or much earlier is possible).


2017년 5월 16일 화요일

[Open S/W] Source code we worked on May 16

#include <stdio.h>

#define PRPTR(p) printf(#p " = %p\n", p)
#define PRCHR(p) printf(#p " = %c\n", p)

int main()
{
    char msg[] = "Good bye yellow brick road~~\n";
    char *myMsg = "PNU Festival is getting started!!\n";
    char *temp;

    temp = msg;

    msg[0] = 'K';
    printf("msg: %s", msg);

    PRPTR(msg + 1);
    PRPTR(msg + 2);
    PRCHR(msg[0]);
    PRCHR(*(temp + 1)) ;
    
   // *myMsg = 'k';
    temp = myMsg;

    myMsg = "Let's have an open Makgulli bar today\n";

    printf("OLD myMsg: %s", temp);
    printf("NEW myMsg: %s", myMsg);

   
    return 0;
}

2017년 5월 12일 금요일

[Open S/W] Source code we worked on May 9 and 11

#include <stdio.h>

int main()
{
    int i;
    int *j;
    int one;
    int to_one;

    to_one = &one;

    j = &i;

    i = 20;

    printf("j value: %d\n", *j);

    return 0;
}

==================================================
#include <stdio.h>

void printAB(int* a, int* b)
{
    printf("a: %d, b: %d\n", *a, *b);
}

void swap(int* a, int* b)
{
    int temp;

    temp = *a;
    *a = *b;
    *b = temp;

    printAB(a, b);
}

int main()
{
    int a = 2, b = 3;
    int array[10];
    int *parray = array;

    // parray = array;
 
    swap(&a, &b);
    printAB(&a, &b);

    for (int i = 0; i < 10; i++) {
        array[i] = i;
    }

    parray = parray + 2;  // parray[2] -> array[2]
    *(parray + 3) = 10;   // parray[3] -> array[3]
    parray = array;
    parray++;
    parray++;
    parray--;
    parray++;
    *parray = 20;
 
    for (int i = 0; i < 10; i++) {
        printf("array[%d]: %d\n", i, array[i]);
    }

     
    return 0;
}


[C++] Source codes used in class (April 27 through May 11)

code 1

code 2



2017년 5월 4일 목요일

[Tips for HW# 6] Code for homework 6!!

Some students ask me a question related to homework 6..
Let me give you some tips ....
Try it and figure it out!!

// From Lecture notes : Inheritance part 1
// Title: [Implementing inheritance] - part 1: basics of inheritance
// pages 13 ~ 14 ..

#include <iostream>

using namespace std;

class A {

protected:
int i;
int j;

public:
A(int tempi, int tempj) {
i = tempi;
j = tempj;
}
};

// A possible way that passes parameters to the base class A
class aa : public A {

protected:
int k;

public:
aa(int aatempi, int aatempj, int aatempk) : A(aatempi, aatempj) {
k = aatempk;
}

void displayaa() {

cout << "i: " << i << endl;
cout << "j: " << j << endl;
cout << "k: " << k << endl;
}

};


int main()
{

aa myaa(2, 3, 5);

myaa.displayaa();

return 0;
}


2017년 5월 3일 수요일

[C++]Review Questions for specialization in a derived class

1. Guess the outcome generated by the following code and run it to verify your outcome!!

#include <iostream>

using namespace std;

class A {

public:
    void  foo() {
        cout << "foo() is called in class A" << endl;
    }

    void  foo(int i) {
        cout << "foo(int i) is called in class A" << endl;
        cout << "i's value: " << i << endl;
    }

};

class aa : public A {
};

int main()
{
   aa myaa;

   myaa.foo();
   myaa.foo(100);
}

2. What's wrong with the following code

#include <iostream>

using namespace std;

class A {

public:
    void  foo() {
        cout << "foo() is called in class A" << endl;
    }

    void  foo(int i) {
        cout << "foo(int i) is called in class A" << endl;
        cout << "i's value: " << i << endl;
    }

};

class aa : public A {
public:
    void foo() {
        cout << "foo() is called in class aa" << endl;
    }
};

int main()
{
   aa myaa;

   myaa.foo();
   myaa.foo(100);
}