Escolar Documentos
Profissional Documentos
Cultura Documentos
Typical Uses
Pesan-pesan ICMP ping menghasilkan ICMP echo permintaan dan menerima ICMP echo balasan. Protokol routing berpagar OSPF mengimplementasikan protokol routing. Menggunakan paket IP dengan protokol ID 89tidak didukung oleh kernel. Hacking Menghasilkan paket-paket TCP/UDP Anda sendiri dengan header palsu
All IGMP
All other protocols that kernel doesn't understand
Such as OSPF
Exercise
Write a simple Hello exchange program using raw sockets that implements your own protocol on top of IP.
Java
Reference Book Thinking in Java by Bruce Eckel Book is online at http://www.mindview.net/books/TIJ
Levels of abstraction
Object oriented languages (C++, Java) Abstracting the problem as object interactions Abstracting the machine model
Assembly language
Machine
Object
An object has
State (internal data) Behavior (methods that operate on data) Identity (object can be addressed uniquely)
Objects
Class defines properties of a set of similar objects.
Think of it as type of the object
Protection boundaries define what object state is visible to others. Inheritance allows a new class to inherit properties of an earlier class without re-defining them. Interface defines what requests others can make to a particular object
Parent class
Interface
Child classes
Creating a class
class Circle {
public : Circle(int x, int y, float r) {} void draw(){} Methods void erase(){} void move(){} private : int x_; Fields int y_; float radius_;
Creating an object
Circle c = new Circle(10,20,5);
Inheritance
abstract class Shape {
public : Shape(int x, int y) { x_ = x; y_ = y; }
abstract void draw(); abstract void erase(); abstract void move();
Inheritance
class Circle extends Shape { Circle(int x,int y,float r){ super(x,y); radius_ = r; } void draw() {} void erase(){} void move(){}
Inheritance
class Square extends Shape { Square(int x,int y,float w){ super(x,y); width_ = r; } void draw() {} void erase(){} void move(){}
void doStuff(Shape s) { s.erase(); // ... s.draw(); } Circle c = new Circle(); Square s = new Square(); Line l = new Line();
Interfaces
interface DrawObject {
// automatically public void draw(); void erase(); void move(); // Compile-time constant: int SOME_CONST = 5; // static & final
class Shape {
public : Shape(int x, int y) { x_ = x; y_ = y; } protected : int x_; int y_;
class Circle extends Shape implements DrawObject { Circle(int x,int y,float r){ super(x,y); radius_ = r; } void draw() {} void erase(){} void move(){} protected : float radius_;
class Square extends Shape implements DrawObject { Square(int x,int y,float w){ super(x,y); width_ = r; } void draw() {} void erase(){} void move(){} protected : float width_;
static members
static fields or methods have one instance across all object instances
class X { static int i = 0; } x1 = new X(); x2 = new X(); x1.i++; x2.i++; System.out.println(Result = + x2.i); Result = 2
final member/class
final class X {
} Final classes cannot be extended.
class X {
final int m(); } Final methods cannot be overridden.
Applets - Chapter 14
}
}