lab5 done right
This commit is contained in:
parent
fe97e171b4
commit
384cc9500f
@ -17,7 +17,7 @@ void get_URL(const string &host, const string &path) {
|
|||||||
// Then you'll need to print out everything the server sends back,
|
// Then you'll need to print out everything the server sends back,
|
||||||
// (not just one call to read() -- everything) until you reach
|
// (not just one call to read() -- everything) until you reach
|
||||||
// the "eof" (end of file).
|
// the "eof" (end of file).
|
||||||
CS144TCPSocket sock;
|
FullStackSocket sock;
|
||||||
sock.connect(Address(host, "http"));
|
sock.connect(Address(host, "http"));
|
||||||
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
|
string request = "GET " + path + " HTTP/1.1\r\nHost: " + host + "\r\nConnection: close\r\n\r\n";
|
||||||
sock.write(request);
|
sock.write(request);
|
||||||
|
|||||||
@ -5,11 +5,11 @@
|
|||||||
#include "tcp_over_ip.hh"
|
#include "tcp_over_ip.hh"
|
||||||
#include "tun.hh"
|
#include "tun.hh"
|
||||||
|
|
||||||
|
#include <list>
|
||||||
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <map>
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <list>
|
|
||||||
|
|
||||||
//! \brief A "network interface" that connects IP (the internet layer, or network layer)
|
//! \brief A "network interface" that connects IP (the internet layer, or network layer)
|
||||||
//! with Ethernet (the network access layer, or link layer).
|
//! with Ethernet (the network access layer, or link layer).
|
||||||
@ -45,10 +45,10 @@ class NetworkInterface {
|
|||||||
|
|
||||||
//! internal map as arp cache, holding mapping from ipv4(numerical form) to MAC addr with expire time.
|
//! internal map as arp cache, holding mapping from ipv4(numerical form) to MAC addr with expire time.
|
||||||
//! if optinal<EthnernetAddress> has no value, it means that a ARP has been sent for the IP within 5 seconds
|
//! if optinal<EthnernetAddress> has no value, it means that a ARP has been sent for the IP within 5 seconds
|
||||||
std::map<uint32_t, std::pair<std::optional<EthernetAddress>, size_t> > _arp_cache{};
|
std::map<uint32_t, std::pair<std::optional<EthernetAddress>, size_t>> _arp_cache{};
|
||||||
|
|
||||||
//! queue the IP datagrams waiting for ARP reply
|
//! queue the IP datagrams waiting for ARP reply
|
||||||
std::list<std::pair<InternetDatagram, Address> >_suspended_datagrams{};
|
std::list<std::pair<InternetDatagram, Address>> _suspended_datagrams{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//! \brief Construct a network interface with given Ethernet (network-access-layer) and IP (internet-layer) addresses
|
//! \brief Construct a network interface with given Ethernet (network-access-layer) and IP (internet-layer) addresses
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user